feat:完善项目信息
This commit is contained in:
@ -5,8 +5,10 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -25,6 +27,14 @@ type (
|
||||
*model.TechnologyAchievementInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// AchievementMatchInfo 成果匹配信息
|
||||
AchievementMatchInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.TechnologyAchievementInstance
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Customers []string `json:"customers"`
|
||||
}
|
||||
// AchievementDetail 成果详情
|
||||
AchievementDetail struct {
|
||||
ID string `json:"id"`
|
||||
@ -69,6 +79,53 @@ func (c *Achievement) Instance(status, page, pageSize int) (*controller.ReturnPa
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Match 匹配信息
|
||||
func (c *Achievement) Match(title string, industrys, keywords []string) ([]*AchievementMatchInfo, error) {
|
||||
params := strings.Join([]string{
|
||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||
}, ",")
|
||||
achievement := service.NewESAchievement(
|
||||
service.WithAchievementTitle(params),
|
||||
service.WithAchievementIndustry(params),
|
||||
service.WithAchievementKeyword(params),
|
||||
)
|
||||
out, err := achievement.Search(0, 0)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range out.([]interface{}) {
|
||||
val := v.(*service.ESAchievement)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
achievements := make([]*model.TechnologyAchievementInstance, 0)
|
||||
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
|
||||
if achievements, err = mTechnologyAchievement.Instance(model2.NewWhereIn("a.id", ids),
|
||||
model2.NewWhere("a.shelf_status", model2.ShelfStatusForUp)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*AchievementMatchInfo, 0)
|
||||
|
||||
for _, v := range achievements {
|
||||
mTechnologyAchievement.Industry = v.Industry
|
||||
mTechnologyAchievement.Keyword = v.Keyword
|
||||
mTechnologyAchievement.Customer = v.Customer
|
||||
|
||||
list = append(list, &AchievementMatchInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyAchievementInstance: v,
|
||||
Industrys: mTechnologyAchievement.GetIndustryAttribute(),
|
||||
Keywords: mTechnologyAchievement.GetKeywordAttribute(),
|
||||
Customers: mTechnologyAchievement.GetCustomerAttribute(),
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详情信息
|
||||
func (c *Achievement) Detail(id uint64) (*AchievementDetail, error) {
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
|
@ -5,10 +5,12 @@ import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -27,6 +29,14 @@ type (
|
||||
ShelfStatus model2.ShelfStatusKind
|
||||
Status model2.SysParentStatus
|
||||
}
|
||||
// PatentMatchInfo 专利匹配信息
|
||||
PatentMatchInfo struct {
|
||||
ID string `json:"id"`
|
||||
Kind model2.SysParentKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
ApplyAt string `json:"apply_at"`
|
||||
}
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
@ -182,6 +192,46 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Search 搜索信息
|
||||
func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMatchInfo, error) {
|
||||
params := strings.Join([]string{
|
||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||
}, ",")
|
||||
patent := service.NewESPatent(
|
||||
service.WithPatentTitle(params),
|
||||
service.WithPatentIndustry(params),
|
||||
)
|
||||
out, err := patent.Search(0, 0)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range out.([]interface{}) {
|
||||
val := v.(*service.ESAchievement)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
mSysPatent := model.NewSysPatent()
|
||||
|
||||
patents := make([]*model2.SysPatent, 0)
|
||||
|
||||
if err = model2.ScanFields(mSysPatent.SysPatent, &patents, []string{"id", "kind", "title", "description", "apply_at"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereIn("id", ids),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*PatentMatchInfo, 0)
|
||||
|
||||
for _, v := range patents {
|
||||
list = append(list, &PatentMatchInfo{
|
||||
ID: v.GetEncodeID(), Title: v.Title, Description: v.Description, ApplyAt: v.ApplyAt,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Patent) Detail(id uint64) (*PatentDetailInfo, error) {
|
||||
mUserPatent := model.NewUserPatent()
|
||||
|
@ -23,7 +23,7 @@ type (
|
||||
// ProductInfo 产品信息
|
||||
ProductInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyProduct
|
||||
*model.TechnologyProductInfo
|
||||
}
|
||||
// ProductDetailInfo 产品详细信息
|
||||
ProductDetailInfo struct {
|
||||
@ -49,44 +49,60 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *Product) List(title string, status, page, pageSize int) ([]*ProductInfo, error) {
|
||||
var matchHandle = map[int]func(title string, industrys, keywords []string) (interface{}, error){
|
||||
1: matchAchievement, 2: matchPatent, 3: matchExpect, 4: matchLaboratory, 5: matchCompany,
|
||||
}
|
||||
|
||||
// matchAchievement 成果匹配
|
||||
func matchAchievement(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return (&Achievement{}).Match(title, industrys, keywords)
|
||||
}
|
||||
|
||||
// matchPatent 专利匹配
|
||||
func matchPatent(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return (&Patent{}).Match(title, industrys, keywords)
|
||||
}
|
||||
|
||||
// matchExpect 专家匹配
|
||||
func matchExpect(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return nil, nil
|
||||
|
||||
}
|
||||
|
||||
// matchLaboratory 实验室匹配
|
||||
func matchLaboratory(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// matchCompany 公司匹配
|
||||
func matchCompany(title string, industrys, keywords []string) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Instance 列表信息
|
||||
func (c *Product) Instance(title string, status, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("local", c.local),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
},
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
out := make([]*model2.TechnologyProduct, 0)
|
||||
where := []*model2.ModelWhere{model2.NewWhere("p.uid", c.UID), model2.NewWhere("p.status", status)}
|
||||
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("p.title", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mTechnologyProduct.TechnologyProduct, &out, []string{},
|
||||
page, pageSize, &count, where...); err != nil {
|
||||
out, err := mTechnologyProduct.Product(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ProductInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ProductInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyProduct: v,
|
||||
ID: v.GetEncodeID(), TechnologyProductInfo: v,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 产品详情
|
||||
@ -110,8 +126,13 @@ func (c *Product) Detail(id uint64) (*ProductDetailInfo, error) {
|
||||
}
|
||||
|
||||
// Match 匹配结果
|
||||
func (c *Product) Match(id uint64) {
|
||||
func (c *Product) Match(kind int, title string, industrys, keywords []string) (interface{}, error) {
|
||||
handle, has := matchHandle[kind]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("操作错误,未知的匹配模式")
|
||||
}
|
||||
return handle(title, industrys, keywords)
|
||||
}
|
||||
|
||||
// Visit 访问信息
|
||||
|
Reference in New Issue
Block a user