feat:完善项目管理
This commit is contained in:
@ -6,6 +6,8 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Research struct {
|
||||
@ -22,6 +24,11 @@ type (
|
||||
*model.ManageLaboratoryInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// ResearchVisit 浏览信息
|
||||
ResearchVisit struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageExpertCompanyVisitInfo
|
||||
}
|
||||
)
|
||||
|
||||
// Laboratory 实验室信息
|
||||
@ -65,6 +72,53 @@ func (c *Research) Laboratory(title string, page, pageSize int) (*controller.Ret
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Visit 访问记录
|
||||
func (c *Research) Visit(page, pageSize int) (interface{}, 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("操作错误,无权限查看")
|
||||
}
|
||||
// 查询科研机构下所有实验室
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
// 用String去接受参数
|
||||
laboratoryIDs := make([]string, 0)
|
||||
|
||||
if err = model2.Pluck(mManageLaboratory.ManageLaboratory, "id", &laboratoryIDs,
|
||||
model2.NewWhere("research_id", mUserResearch.ResearchID)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
where = append(where, model2.NewWhere("e.research_id = ?", mUserResearch.ResearchID),
|
||||
model2.NewWhereValue(fmt.Sprintf("(e.laboratory_id = %d) OR (e.laboratory_id IN (%v))",
|
||||
0, strings.Join(laboratoryIDs, ","))))
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
var count int64
|
||||
|
||||
out := make([]*model.ManageExpertCompanyVisitInfo, 0)
|
||||
|
||||
if out, err = mManageExpert.CompanyVisit(page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchVisit, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchVisit{
|
||||
ID: v.GetEncodeID(),
|
||||
ManageExpertCompanyVisitInfo: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, err
|
||||
}
|
||||
|
||||
func NewResearch() ResearchHandle {
|
||||
return func(session *session.Enterprise, local string) *Research {
|
||||
return &Research{
|
||||
|
Reference in New Issue
Block a user