feat:完善项目
This commit is contained in:
47
app/api/admin/model/service_demand.go
Normal file
47
app/api/admin/model/service_demand.go
Normal file
@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ServiceDemand struct {
|
||||
*model.ServiceDemand
|
||||
}
|
||||
|
||||
type ServiceDemandInfo struct {
|
||||
*model.ServiceDemand
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Demand 需求信息
|
||||
func (m *ServiceDemand) Demand(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceDemandInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS d").
|
||||
Select("d.*", "t.province", "t.city").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON ", model.NewSysTenant().TableName())).
|
||||
Where("d.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("d.status IN (?)", []model.ServiceDemandStatus{
|
||||
model.ServiceDemandStatusForPublish, model.ServiceDemandStatusForAcceptance,
|
||||
model.ServiceDemandStatusForComplete,
|
||||
})
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceDemandInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("d.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewServiceDemand() *ServiceDemand {
|
||||
return &ServiceDemand{model.NewServiceDemand()}
|
||||
}
|
12
app/api/admin/model/technology_demand.go
Normal file
12
app/api/admin/model/technology_demand.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
// TechnologyDemand 技术需求
|
||||
type TechnologyDemand struct {
|
||||
*model.TechnologyDemand
|
||||
}
|
||||
|
||||
func NewTechnologyDemand() *TechnologyDemand {
|
||||
return &TechnologyDemand{model.NewTechnologyDemand()}
|
||||
}
|
Reference in New Issue
Block a user