feat:完善项目信息
This commit is contained in:
1
app/api/admin/controller/account.go
Normal file
1
app/api/admin/controller/account.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package controller
|
1
app/api/admin/controller/tenant.go
Normal file
1
app/api/admin/controller/tenant.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package controller
|
253
app/api/enterprise/controller/manage/common.go
Normal file
253
app/api/enterprise/controller/manage/common.go
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
package manage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/controller/technology"
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 公用参数信息
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AchievementInfo 成果信息
|
||||||
|
AchievementInfo struct {
|
||||||
|
*model.TechnologyAchievementInfo
|
||||||
|
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
||||||
|
}
|
||||||
|
// ProjectInfo 项目信息
|
||||||
|
ProjectInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model2.TechnologyProject
|
||||||
|
}
|
||||||
|
// PatentInfo 专利信息
|
||||||
|
PatentInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model.PatentInfo
|
||||||
|
}
|
||||||
|
// PaperInfo 论文信息
|
||||||
|
PaperInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model2.TechnologyPaper
|
||||||
|
Keywords []string `json:"keywords"`
|
||||||
|
}
|
||||||
|
// CooperateInfo 合作的企业信息
|
||||||
|
CooperateInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
PatentCount int `json:"patent_count"`
|
||||||
|
PaperCount int `json:"paper_count"`
|
||||||
|
}
|
||||||
|
// CooperateDetailInfo 合作的企业详细信息
|
||||||
|
CooperateDetailInfo struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Patent []*technology.PatentInfo `json:"patent"`
|
||||||
|
Paper []*technology.PaperInfo `json:"paper"`
|
||||||
|
}
|
||||||
|
EquipmentInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model2.ManageEquipment
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// achievement 技术成果信息
|
||||||
|
func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out, err := mTechnologyAchievement.Achievement(page, pageSize, &count, model2.NewWhereIn("uid", uids))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*AchievementInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &AchievementInfo{
|
||||||
|
TechnologyAchievementInfo: v,
|
||||||
|
ChargeInfo: v.GetChargeInfoAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// project 项目信息
|
||||||
|
func project(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mTechnologyProject := model.NewTechnologyProject()
|
||||||
|
out := make([]*model2.TechnologyProject, 0)
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err := model2.Pages(mTechnologyProject.TechnologyProject, &out, page, pageSize, &count,
|
||||||
|
&model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("uid", uids),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*ProjectInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &ProjectInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
TechnologyProject: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// patent 专利信息
|
||||||
|
func patent(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out, err := mUserPatent.Patent(page, pageSize, &count, model2.NewWhereIn("u_p.uid", uids))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*PatentInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &PatentInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
PatentInfo: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
func paper(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mTechnologyPaper := model.NewTechnologyPaper()
|
||||||
|
|
||||||
|
out := make([]*model2.TechnologyPaper, 0)
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err := model2.PagesFields(mTechnologyPaper.TechnologyPaper, &out, []string{"id", "title", "ext", "keyword"},
|
||||||
|
page, pageSize, &count, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("uid", uids),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*PaperInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &PaperInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
TechnologyPaper: v,
|
||||||
|
Keywords: v.GetKeywordAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cooperate 合作的信息
|
||||||
|
func cooperate(uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mUserCooperateEnterprise := model.NewUserCooperateEnterprise()
|
||||||
|
|
||||||
|
out := make([]*model2.UserCooperateEnterprise, 0)
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err := model2.PagesFields(mUserCooperateEnterprise.UserCooperateEnterprise, &out, []string{"id", "title", "paper", "patent"},
|
||||||
|
page, pageSize, &count, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("uid", uids),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("kind", model2.UserCooperateEnterpriseModeForCooperateAlready)}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := make([]*CooperateInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &CooperateInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
Title: v.Title,
|
||||||
|
PatentCount: len(v.GetPatentAttribute()),
|
||||||
|
PaperCount: len(v.GetPaperAttribute()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cooperateDetail 合作企业详情
|
||||||
|
func cooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
||||||
|
mUserCooperateEnterprise := model.NewUserCooperateEnterprise()
|
||||||
|
mUserCooperateEnterprise.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserCooperateEnterprise.UserCooperateEnterprise, []string{"id", "title", "paper", "patent"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,企业信息不存在或已被删除")
|
||||||
|
}
|
||||||
|
out := &CooperateDetailInfo{
|
||||||
|
Title: mUserCooperateEnterprise.Title,
|
||||||
|
Patent: make([]*technology.PatentInfo, 0),
|
||||||
|
Paper: make([]*technology.PaperInfo, 0),
|
||||||
|
}
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
|
||||||
|
patents := make([]*model.SysPatentInfo, 0)
|
||||||
|
|
||||||
|
if patents, err = mSysPatent.Instance(model2.NewWhereIn("p.id", mUserCooperateEnterprise.GetPatentAttribute())); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range patents {
|
||||||
|
out.Patent = append(out.Patent, &technology.PatentInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
SysPatentInfo: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 论文信息
|
||||||
|
mTechnologyPaper := model.NewTechnologyPaper()
|
||||||
|
|
||||||
|
papers := make([]*model2.TechnologyPaper, 0)
|
||||||
|
|
||||||
|
if err = model2.ScanFields(mTechnologyPaper.TechnologyPaper, &papers, []string{"id", "title", "ext", "keyword"},
|
||||||
|
&model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhereIn("id", mUserCooperateEnterprise.GetPaperAttribute()),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range papers {
|
||||||
|
out.Paper = append(out.Paper, &technology.PaperInfo{
|
||||||
|
ID: v.GetEncodeID(), Title: v.Title, Ext: v.Ext, Keywords: v.GetKeywordAttribute(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// equipment 设备信息
|
||||||
|
func equipment(kind model2.ManageEquipmentKind, uids []uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mManageEquipment := model.NewManageEquipment()
|
||||||
|
|
||||||
|
out := make([]*model2.ManageEquipment, 0)
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err := model2.Pages(mManageEquipment.ManageEquipment, &out, page, pageSize, &count, &model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("kind", kind),
|
||||||
|
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||||
|
}, &model2.ModelWhereOrder{Where: model2.NewWhereIn("uid", uids)}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*EquipmentInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &EquipmentInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
ManageEquipment: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
}
|
@ -17,7 +17,7 @@ type Equipment struct {
|
|||||||
type EquipmentHandle func(session *session.Enterprise, local string) *Equipment
|
type EquipmentHandle func(session *session.Enterprise, local string) *Equipment
|
||||||
|
|
||||||
type (
|
type (
|
||||||
EquipmentInfo struct {
|
EquipmentInstance struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model2.ManageEquipment
|
*model2.ManageEquipment
|
||||||
}
|
}
|
||||||
@ -58,10 +58,10 @@ func (c *Equipment) List(kind int, code, title string, page, pageSize int) (*con
|
|||||||
if err := model2.Pages(mManageEquipment.ManageEquipment, &out, page, pageSize, &count, where...); err != nil {
|
if err := model2.Pages(mManageEquipment.ManageEquipment, &out, page, pageSize, &count, where...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list := make([]*EquipmentInfo, 0)
|
list := make([]*EquipmentInstance, 0)
|
||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &EquipmentInfo{
|
list = append(list, &EquipmentInstance{
|
||||||
ID: v.GetEncodeID(), ManageEquipment: v,
|
ID: v.GetEncodeID(), ManageEquipment: v,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"SciencesServer/app/basic/config"
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -18,10 +19,40 @@ type Expert struct {
|
|||||||
|
|
||||||
type ExpertHandle func(session *session.Enterprise, local string) *Expert
|
type ExpertHandle func(session *session.Enterprise, local string) *Expert
|
||||||
|
|
||||||
type ExpertInfo struct {
|
type (
|
||||||
|
// ExpertInfo 专家信息
|
||||||
|
ExpertInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.ManageExpertInfo
|
*model.ManageExpertInfo
|
||||||
Industrys []string `json:"industrys"`
|
Industrys []string `json:"industrys"`
|
||||||
|
}
|
||||||
|
// ExpertMatchInfo 专家匹配信息
|
||||||
|
ExpertMatchInfo 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"`
|
||||||
|
}
|
||||||
|
// ExpertDetailInfo 专家详细信息
|
||||||
|
ExpertDetailInfo struct {
|
||||||
|
ExpertMatchInfo
|
||||||
|
Researchs []string `json:"researchs"`
|
||||||
|
Introduce string `json:"introduce"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// user 用户信息
|
||||||
|
func (c *Expert) user(id uint64) ([]uint64, error) {
|
||||||
|
mUserExpert := model.NewUserExpert()
|
||||||
|
|
||||||
|
uids := make([]uint64, 0)
|
||||||
|
|
||||||
|
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id))
|
||||||
|
|
||||||
|
return uids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// research 研究机构专家信息
|
// research 研究机构专家信息
|
||||||
@ -131,6 +162,137 @@ func (c *Expert) Instance(name, mobile string, page, pageSize int) (*controller.
|
|||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Match 匹配信息
|
||||||
|
func (c *Expert) Match(title string, industrys, keywords []string) ([]*ExpertMatchInfo, error) {
|
||||||
|
params := strings.Join([]string{
|
||||||
|
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||||
|
}, ",")
|
||||||
|
|
||||||
|
manage := service.NewESManage(
|
||||||
|
service.WithManageIdentity(config.TenantUserIdentityForExpert),
|
||||||
|
)
|
||||||
|
out, err := manage.Search(0, 0, map[string]interface{}{
|
||||||
|
"title": params, "industry": params, "keyword": params, "research": params,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ids := make([]uint64, 0)
|
||||||
|
|
||||||
|
for _, v := range out.([]interface{}) {
|
||||||
|
val := v.(*service.ESManage)
|
||||||
|
ids = append(ids, val.ID)
|
||||||
|
}
|
||||||
|
mManageExpert := model.NewManageExpert()
|
||||||
|
|
||||||
|
experts := make([]*model.ManageExpertInstanceInfo, 0)
|
||||||
|
|
||||||
|
if experts, err = mManageExpert.Instance(3, model2.NewWhereIn("e.id", ids)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*ExpertMatchInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range experts {
|
||||||
|
list = append(list, &ExpertMatchInfo{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
Name: v.Name,
|
||||||
|
School: v.School,
|
||||||
|
Major: v.Major,
|
||||||
|
Industrys: v.GetIndustryAttribute(),
|
||||||
|
Keywords: v.GetKeywordAttribute(),
|
||||||
|
PatentTitles: strings.Split(v.PatentTitle, "&&"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 详细信息
|
||||||
|
func (c *Expert) Detail(id uint64) (*ExpertDetailInfo, error) {
|
||||||
|
mManageExpert := model.NewManageExpert()
|
||||||
|
out, err := mManageExpert.Detail(3, id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ExpertDetailInfo{
|
||||||
|
ExpertMatchInfo: ExpertMatchInfo{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Achievement 成果信息
|
||||||
|
func (c *Expert) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return achievement(uids, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Project 项目信息
|
||||||
|
func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return project(uids, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patent 专利信息
|
||||||
|
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return patent(uids, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper 论文信息
|
||||||
|
func (c *Expert) Paper(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return paper(uids, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cooperate 企业信息
|
||||||
|
func (c *Expert) Cooperate(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
// 查询专家身份下用户信息
|
||||||
|
uids, err := c.user(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cooperate(uids, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CooperateDetail 公司企业详细信息
|
||||||
|
func (c *Expert) CooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
||||||
|
return cooperateDetail(id)
|
||||||
|
}
|
||||||
|
|
||||||
func NewExpert() ExpertHandle {
|
func NewExpert() ExpertHandle {
|
||||||
return func(session *session.Enterprise, local string) *Expert {
|
return func(session *session.Enterprise, local string) *Expert {
|
||||||
return &Expert{
|
return &Expert{
|
||||||
|
@ -192,7 +192,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
|||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search 搜索信息
|
// Match 搜索信息
|
||||||
func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMatchInfo, error) {
|
func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMatchInfo, error) {
|
||||||
params := strings.Join([]string{
|
params := strings.Join([]string{
|
||||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||||
|
@ -28,6 +28,69 @@ type ManageExpertCompanyVisitInfo struct {
|
|||||||
VisitAt time.Time `json:"visit_at"`
|
VisitAt time.Time `json:"visit_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ManageExpertInstanceInfo struct {
|
||||||
|
*model.ManageExpert
|
||||||
|
PatentTitle string `json:"-"`
|
||||||
|
Research string `json:"-"`
|
||||||
|
Introduce string `json:"introduce"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expert 专家信息
|
||||||
|
func (m *ManageExpert) Instance(limit int, where ...*model.ModelWhere) ([]*ManageExpertInstanceInfo, error) {
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
// 用户专利信息
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||||
|
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword",
|
||||||
|
"p.title AS patent_title").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||||
|
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||||
|
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||||
|
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||||
|
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||||
|
Where("e.examine_status = ?", model.ExamineStatusForAgree).
|
||||||
|
Where("e.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*ManageExpertInstanceInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Order("e.id " + model.OrderModeToDesc).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail 专家信息
|
||||||
|
func (m *ManageExpert) Detail(limit int, id uint64) (*ManageExpertInstanceInfo, error) {
|
||||||
|
// 专利信息
|
||||||
|
mSysPatent := model.NewSysPatent()
|
||||||
|
// 用户专利信息
|
||||||
|
mUserPatent := model.NewUserPatent()
|
||||||
|
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||||
|
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword", "e.research", "e.introduce",
|
||||||
|
"p.title AS patent_title").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = p.patent_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
|
||||||
|
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||||
|
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title
|
||||||
|
FROM %s AS u LEFT JOIN %s AS p ON u.parent_id = p.id WHERE u.is_deleted = %d AND p.shelf_status = %d) AS p ON e_u.uid = p.uid`,
|
||||||
|
limit, mUserPatent.TableName(), mSysPatent.TableName(), model.DeleteStatusForNot, model.ShelfStatusForUp)).
|
||||||
|
Where("e.id = ?", id)
|
||||||
|
|
||||||
|
out := new(ManageExpertInstanceInfo)
|
||||||
|
|
||||||
|
if err := db.Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Experts 专家信息
|
// Experts 专家信息
|
||||||
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" e").
|
db := orm.GetDB().Table(m.TableName()+" e").
|
||||||
|
@ -98,7 +98,7 @@ func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return paper(uids, page, pageSize)
|
return patent(uids, page, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper 论文信息
|
// Paper 论文信息
|
||||||
|
@ -111,7 +111,7 @@ func (c *Search) Launch(identity int, param, industry string, page, pageSize int
|
|||||||
service.WithManageKeyword(param),
|
service.WithManageKeyword(param),
|
||||||
service.WithManageResearch(param),
|
service.WithManageResearch(param),
|
||||||
)
|
)
|
||||||
out, err := manage.Search(page, pageSize)
|
out, err := manage.Search(page, pageSize, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -30,7 +30,7 @@ func (this *ESManage) Create() error {
|
|||||||
return es.Create(this.Index(), _bytes)
|
return es.Create(this.Index(), _bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ESManage) Search(page, pageSize int) (interface{}, error) {
|
func (this *ESManage) Search(page, pageSize int, params map[string]interface{}) (interface{}, error) {
|
||||||
termParams := make(map[string]interface{}, 0)
|
termParams := make(map[string]interface{}, 0)
|
||||||
shouldParams := make(map[string]interface{}, 0)
|
shouldParams := make(map[string]interface{}, 0)
|
||||||
|
|
||||||
@ -46,6 +46,11 @@ func (this *ESManage) Search(page, pageSize int) (interface{}, error) {
|
|||||||
if this.Research != "" {
|
if this.Research != "" {
|
||||||
shouldParams["research"] = this.Research
|
shouldParams["research"] = this.Research
|
||||||
}
|
}
|
||||||
|
if len(params) > 0 {
|
||||||
|
for k, v := range params {
|
||||||
|
shouldParams[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
out, err := es.Search(this, this.Index(), &es.SearchParams{
|
out, err := es.Search(this, this.Index(), &es.SearchParams{
|
||||||
TermParams: termParams,
|
TermParams: termParams,
|
||||||
ShouldParams: shouldParams,
|
ShouldParams: shouldParams,
|
||||||
|
Reference in New Issue
Block a user