feat:完善信息

This commit is contained in:
henry
2022-01-23 22:59:11 +08:00
parent 5e328ab2da
commit 79c5cbfe74
9 changed files with 340 additions and 7 deletions

View File

@ -0,0 +1,45 @@
package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
)
// TechnologyDemandService 技术需求进度模型
type TechnologyDemandService struct {
*model.TechnologyDemandService
}
// TechnologyDemandServiceInfo 技术需求进度信息
type TechnologyDemandServiceInfo struct {
*model.TechnologyDemandService
Title string `json:"title"`
}
// Services 服务信息
func (m *TechnologyDemandService) Services(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyDemandServiceInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS s").
Select("s.*", "d.title").
Joins(fmt.Sprintf("LEFT JOIN %s AS d ON s.demand_id = d.id", model.NewTechnologyDemand().TableName()))
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
out := make([]*TechnologyDemandServiceInfo, 0)
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("s.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func NewTechnologyDemandService() *TechnologyDemandService {
return &TechnologyDemandService{model.NewTechnologyDemandService()}
}

View File

@ -0,0 +1,12 @@
package model
import "SciencesServer/app/common/model"
// TechnologyDemandServiceProgress 技术需求进度数据模型
type TechnologyDemandServiceProgress struct {
*model.TechnologyDemandServiceProgress
}
func NewTechnologyDemandServiceProgress() *TechnologyDemandServiceProgress {
return &TechnologyDemandServiceProgress{model.NewTechnologyDemandServiceProgress()}
}