feat:完善项目管理,增加专家列表信息
This commit is contained in:
@ -1,64 +0,0 @@
|
||||
package identity
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
type (
|
||||
// InstanceForExpert 专家信息
|
||||
InstanceForExpert struct {
|
||||
ID string `json:"id"`
|
||||
*model.UserIdentityForExpert
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家列表
|
||||
func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("m.name", name))
|
||||
}
|
||||
if mobile != "" {
|
||||
where = append(where, model2.NewWhereLike("u.mobile", mobile))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mUserIdentity.Expert(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]*InstanceForExpert, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mUserIdentity.ID = v.ID
|
||||
|
||||
list = append(list, &InstanceForExpert{
|
||||
ID: mUserIdentity.GetEncodeID(), UserIdentityForExpert: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Enterprise, local string) *Instance {
|
||||
return &Instance{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
137
app/api/enterprise/controller/manage/expert.go
Normal file
137
app/api/enterprise/controller/manage/expert.go
Normal file
@ -0,0 +1,137 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Expert struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type ExpertHandle func(session *session.Enterprise, local string) *Expert
|
||||
|
||||
type ExpertInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageExpertInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
|
||||
// research 研究机构专家信息
|
||||
func (c *Expert) research(page, pageSize int, count *int64, where ...*model2.ModelWhere) ([]*model.ManageExpertInfo, error) {
|
||||
if len(where) <= 0 {
|
||||
where = make([]*model2.ModelWhere, 0)
|
||||
}
|
||||
// 研究科技下存在专家
|
||||
// 实验室下存在专家
|
||||
mUserResearch := model.NewUserResearch()
|
||||
|
||||
_, 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
|
||||
}
|
||||
// 查询科研机构下所有实验室
|
||||
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 = 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()
|
||||
|
||||
out := make([]*model.ManageExpertInfo, 0)
|
||||
|
||||
if out, err = mManageExpert.Experts(page, pageSize, count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// laboratory 实验室专家信息
|
||||
func (c *Expert) laboratory(page, pageSize int, count *int64, where ...*model2.ModelWhere) ([]*model.ManageExpertInfo, error) {
|
||||
if len(where) <= 0 {
|
||||
where = make([]*model2.ModelWhere, 0)
|
||||
}
|
||||
// 实验室信息
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
_, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "research_id"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
where = append(where, model2.NewWhere("e.laboratory_id = ?", mManageLaboratory.ID))
|
||||
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
out := make([]*model.ManageExpertInfo, 0)
|
||||
|
||||
if out, err = mManageExpert.Experts(page, pageSize, count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Instance 专家信息
|
||||
func (c *Expert) Instance(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("e.name", name))
|
||||
}
|
||||
if mobile != "" {
|
||||
where = append(where, model2.NewWhereLike("e.mobile", mobile))
|
||||
}
|
||||
out := make([]*model.ManageExpertInfo, 0)
|
||||
|
||||
var err error
|
||||
|
||||
var count int64
|
||||
// 科研机构
|
||||
if c.Identity == config.TenantUserIdentityForResearch {
|
||||
out, err = c.research(page, pageSize, &count, where...)
|
||||
// 实验室
|
||||
} else if c.Identity == config.TenantUserIdentityForLaboratory {
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ExpertInfo, 0)
|
||||
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
for _, v := range out {
|
||||
mManageExpert.Industry = v.Industry
|
||||
|
||||
list = append(list, &ExpertInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ManageExpertInfo: v,
|
||||
Industrys: mManageExpert.GetIndustryAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewExpert() ExpertHandle {
|
||||
return func(session *session.Enterprise, local string) *Expert {
|
||||
return &Expert{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Project 项目列表
|
||||
type Project struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
|
Reference in New Issue
Block a user