feat:完善项目管理,增加科研机构下实验室列表信息

This commit is contained in:
henry
2021-12-13 10:55:53 +08:00
parent fdcd46bf49
commit b9cc39d37a
11 changed files with 216 additions and 10 deletions

View File

@ -6,6 +6,7 @@ import (
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"errors"
"fmt"
"strings"
)
@ -32,11 +33,13 @@ func (c *Expert) research(page, pageSize int, count *int64, where ...*model2.Mod
// 实验室下存在专家
mUserResearch := model.NewUserResearch()
_, err := model2.FirstField(mUserResearch.UserResearch, []string{"id", "research_id"},
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()
@ -107,6 +110,7 @@ func (c *Expert) Instance(name, mobile string, page, pageSize int) (*controller.
out, err = c.research(page, pageSize, &count, where...)
// 实验室
} else if c.Identity == config.TenantUserIdentityForLaboratory {
out, err = c.laboratory(page, pageSize, &count, where...)
}
if err != nil {
return nil, err

View File

@ -0,0 +1,32 @@
package manage
import (
"SciencesServer/app/basic/controller"
"SciencesServer/app/session"
)
type Laboratory struct {
*session.Enterprise
local string
}
type LaboratoryHandle func(session *session.Enterprise, local string) *Laboratory
func (c *Laboratory) Instance() (*controller.ReturnPages, error) {
//mManageLaboratory := model.NewManageLaboratory()
//out := make([]*model2.ManageLaboratory, 0)
//model2.PagesFields(mManageLaboratory.ManageLaboratory, &out)
return nil, nil
}
func NewLaboratory() LaboratoryHandle {
return func(session *session.Enterprise, local string) *Laboratory {
return &Laboratory{
Enterprise: session,
local: local,
}
}
}

View 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,
}
}
}