feat:完善项目
This commit is contained in:
42
app/api/admin/model/technology_product.go
Normal file
42
app/api/admin/model/technology_product.go
Normal file
@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TechnologyProduct struct {
|
||||
*model.TechnologyProduct
|
||||
}
|
||||
|
||||
type TechnologyProductInfo struct {
|
||||
model.Model
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Product 产品信息
|
||||
func (m *TechnologyProduct) Product(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName() + " AS p").
|
||||
Select("p.id").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON p.tenant_id = t.id", model.NewSysTenant().TableName()))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*TechnologyProductInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewTechnologyProduct() *TechnologyProduct {
|
||||
return &TechnologyProduct{model.NewTechnologyProduct()}
|
||||
}
|
Reference in New Issue
Block a user