feat:完善项目信息
This commit is contained in:
@ -2,9 +2,13 @@ package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Company 公司信息
|
||||
@ -29,6 +33,16 @@ type (
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
// CompanyMatchInfo 公司匹配信息
|
||||
CompanyMatchInfo struct {
|
||||
ID string `json:"id"`
|
||||
Kind model2.ManageCompanyKind `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
Product string `json:"product"`
|
||||
Url string `json:"url"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
)
|
||||
|
||||
// Detail 详细信息
|
||||
@ -88,6 +102,53 @@ func (c *Company) Product(id uint64, page, pageSize int) ([]*CompanyProductInfo,
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Match 匹配信息
|
||||
func (c *Company) Match(title string, industrys, keywords []string) ([]*CompanyMatchInfo, error) {
|
||||
params := strings.Join([]string{
|
||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||
}, ",")
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForCompany),
|
||||
)
|
||||
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)
|
||||
}
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
companys := make([]*model2.ManageCompany, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageCompany.ManageCompany, &companys, []string{"id", "kind", "name", "image", "url", "keyword"},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]*CompanyMatchInfo, 0)
|
||||
|
||||
for _, v := range companys {
|
||||
list = append(list, &CompanyMatchInfo{
|
||||
ID: v.GetEncodeID(), Kind: v.Kind, Name: v.Name,
|
||||
Image: v.Image.Analysis(config2.SettingInfo.Domain),
|
||||
Url: v.Url,
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func NewCompany() CompanyHandle {
|
||||
return func(session *session.Enterprise, local string) *Company {
|
||||
return &Company{
|
||||
|
@ -91,7 +91,7 @@ func (c *Laboratory) Match(title string, industrys, keywords []string) ([]*Labor
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Instance 实验室信息
|
||||
// Detail 实验室信息
|
||||
func (c *Laboratory) Detail(id uint64) (*LaboratoryMatchInfo, error) {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
out, err := mManageLaboratory.Instance(model2.NewWhere("l.id", id))
|
||||
|
@ -1,6 +1,7 @@
|
||||
package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/manage"
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
@ -65,13 +66,13 @@ func matchPatent(title string, industrys, keywords []string) (interface{}, error
|
||||
|
||||
// matchExpect 专家匹配
|
||||
func matchExpect(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return nil, nil
|
||||
return (&manage.Expert{}).Match(title, industrys, keywords)
|
||||
|
||||
}
|
||||
|
||||
// matchLaboratory 实验室匹配
|
||||
func matchLaboratory(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return nil, nil
|
||||
return (&manage.Laboratory{}).Match(title, industrys, keywords)
|
||||
}
|
||||
|
||||
// matchCompany 公司匹配
|
||||
|
Reference in New Issue
Block a user