feat:完善项目管理,增加科研机构下实验室列表信息
This commit is contained in:
75
app/api/enterprise/controller/manage/research.go
Normal file
75
app/api/enterprise/controller/manage/research.go
Normal file
@ -0,0 +1,75 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Research struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type ResearchHandle func(session *session.Enterprise, local string) *Research
|
||||
|
||||
type (
|
||||
// ResearchLaboratory 科研机构下实验室信息
|
||||
ResearchLaboratory struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageLaboratoryInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
)
|
||||
|
||||
// Laboratory 实验室信息
|
||||
func (c *Research) Laboratory(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询用户科研机构信息
|
||||
mUserResearch := model.NewUserResearch()
|
||||
|
||||
isExist, err := model2.FirstField(mUserResearch.UserResearch, []string{"id", "research_id"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,无权限查看")
|
||||
}
|
||||
where := []*model2.ModelWhere{model2.NewWhere("research_id", mUserResearch.ResearchID)}
|
||||
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("title", title))
|
||||
}
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
out := make([]*model.ManageLaboratoryInfo, 0)
|
||||
|
||||
var count int64
|
||||
|
||||
if out, err = mManageLaboratory.Laboratory(page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchLaboratory, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mManageLaboratory.Industry = v.Industry
|
||||
|
||||
list = append(list, &ResearchLaboratory{
|
||||
ID: v.GetEncodeID(),
|
||||
ManageLaboratoryInfo: v,
|
||||
Industrys: mManageLaboratory.GetIndustryAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewResearch() ResearchHandle {
|
||||
return func(session *session.Enterprise, local string) *Research {
|
||||
return &Research{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user