feat:完善信息
This commit is contained in:
42
app/api/admin/model/technology_project.go
Normal file
42
app/api/admin/model/technology_project.go
Normal file
@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TechnologyProject struct {
|
||||
*model.TechnologyProject
|
||||
}
|
||||
|
||||
type TechnologyProjectInfo struct {
|
||||
*model.TechnologyProject
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Projects 项目信息
|
||||
func (m *TechnologyProject) Projects(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProjectInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON p.tenant_id = t.id", model.NewSysTenant().TableName()))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*TechnologyProjectInfo, 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 NewTechnologyProject() *TechnologyProject {
|
||||
return &TechnologyProject{model.NewTechnologyProject()}
|
||||
}
|
Reference in New Issue
Block a user