feat:完善项目信息
This commit is contained in:
96
app/api/admin/controller/manage/instance.go
Normal file
96
app/api/admin/controller/manage/instance.go
Normal file
@ -0,0 +1,96 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller"
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
*service.Session
|
||||
gorm.Model
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *service.Session, local string) *Instance
|
||||
|
||||
type (
|
||||
// InstanceForExpert 专家信息
|
||||
InstanceForExpert struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Industry []string `json:"industry"`
|
||||
ResearchName string `json:"research_name"`
|
||||
LaboratoryName string `json:"laboratory_name"`
|
||||
Address string `json:"address"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) Company(name string, status int, page, pageSize int) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
}
|
||||
|
||||
var count int64
|
||||
|
||||
mManageCompany.Companys(page, pageSize, &count)
|
||||
}
|
||||
|
||||
// Expert 专家信息
|
||||
func (c *Instance) Expert(name string, status int, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("name", name))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageExpert.Experts(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InstanceForExpert, 0)
|
||||
|
||||
for _, v := range out {
|
||||
industry := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(v.Industry, ";") {
|
||||
industry = append(industry, config.GetIndustryInfo(v, "-"))
|
||||
}
|
||||
// 研究机构,实验室
|
||||
researchName := v.LaboratoryName
|
||||
laboratoryName := ""
|
||||
|
||||
if v.LaboratoryName != "" {
|
||||
researchName = v.ResearchName
|
||||
laboratoryName = v.LaboratoryName
|
||||
}
|
||||
list = append(list, &InstanceForExpert{ID: v.GetEncodeID(), Name: v.Name, Industry: industry,
|
||||
ResearchName: researchName, LaboratoryName: laboratoryName,
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *service.Session, local string) *Instance {
|
||||
return &Instance{
|
||||
Session: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user