feat:完善项目信息
This commit is contained in:
98
app/api/website/controller/manage/expert.go
Normal file
98
app/api/website/controller/manage/expert.go
Normal file
@ -0,0 +1,98 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Expert struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type ExpertHandle func(session *session.Enterprise) *Expert
|
||||
|
||||
type (
|
||||
// ExpertBasicInfo 基本信息
|
||||
ExpertBasicInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
School string `json:"school"`
|
||||
Major string `json:"major"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
PatentTitles []string `json:"patent_titles"`
|
||||
}
|
||||
// ExpertInstanceInfo 专家信息
|
||||
ExpertInstanceInfo struct {
|
||||
ExpertBasicInfo
|
||||
Researchs []string `json:"researchs"`
|
||||
Introduce string `json:"introduce"`
|
||||
}
|
||||
// ExpertAchievementInfo 专家成果信息
|
||||
ExpertAchievementInfo struct {
|
||||
*model.TechnologyAchievementInfo
|
||||
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 专家信息
|
||||
func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
out, err := mManageExpert.Detail(3, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExpertInstanceInfo{
|
||||
ExpertBasicInfo: ExpertBasicInfo{
|
||||
ID: out.GetEncodeID(),
|
||||
Name: out.Name,
|
||||
School: out.School,
|
||||
Major: out.Major,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
PatentTitles: strings.Split(out.PatentTitle, "&&"),
|
||||
},
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
Introduce: out.Introduce,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Expert) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询专家身份下用户信息
|
||||
mUserExpert := model.NewUserExpert()
|
||||
|
||||
uids := make([]*uint64, 0)
|
||||
|
||||
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
var count int64
|
||||
|
||||
out := make([]*model.TechnologyAchievementInfo, 0)
|
||||
|
||||
if out, err = mTechnologyAchievement.Achievement(page, pageSize, &count, model2.NewWhereIn("uid", uids)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ExpertAchievementInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ExpertAchievementInfo{
|
||||
TechnologyAchievementInfo: v,
|
||||
ChargeInfo: v.GetChargeInfoAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewExpert() ExpertHandle {
|
||||
return func(session *session.Enterprise) *Expert {
|
||||
return &Expert{session}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user