feat:完善项目信息
This commit is contained in:
@ -14,7 +14,7 @@ type (
|
||||
// AchievementInfo 成果信息
|
||||
AchievementInfo struct {
|
||||
*model.TechnologyAchievementInfo
|
||||
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
||||
Config *model2.TechnologyAchievementConfig `json:"config"`
|
||||
}
|
||||
// ProjectInfo 项目信息
|
||||
ProjectInfo struct {
|
||||
@ -67,7 +67,7 @@ func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, er
|
||||
for _, v := range out {
|
||||
list = append(list, &AchievementInfo{
|
||||
TechnologyAchievementInfo: v,
|
||||
ChargeInfo: v.GetChargeInfoAttribute(),
|
||||
Config: v.GetConfigAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -30,11 +30,15 @@ type (
|
||||
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// TODO:缺少会员判断标准
|
||||
// ES标准判定
|
||||
s := service.NewESPatent(
|
||||
service.WithPatentTitle(title),
|
||||
service.WithPatentIndustry(industry),
|
||||
)
|
||||
out, count1, err := s.Search(page, pageSize)
|
||||
manage := service.NewESPatent()
|
||||
|
||||
if title != "" {
|
||||
service.WithPatentTitle(title)(manage)
|
||||
}
|
||||
if industry != "" {
|
||||
service.WithPatentIndustry(industry)(manage)
|
||||
}
|
||||
out, count1, err := manage.Search(page, pageSize)
|
||||
|
||||
list := make([]*PatentInfo, 0)
|
||||
|
||||
|
118
app/api/website/controller/technology/product.go
Normal file
118
app/api/website/controller/technology/product.go
Normal file
@ -0,0 +1,118 @@
|
||||
package technology
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type ProductHandle func(session *session.Enterprise) *Product
|
||||
|
||||
type (
|
||||
// ProductInstance 产品信息
|
||||
ProductInstance struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
// ProductDetail 产品详情
|
||||
ProductDetail struct {
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyProduct
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
LeadStandardTitle string `json:"lead_standard_title"`
|
||||
MaturityTitle string `json:"maturity_title"`
|
||||
CooperationModeTitle string `json:"cooperation_mode_title"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Product) Instance(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
|
||||
out := make([]*model2.TechnologyProduct, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}}
|
||||
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mTechnologyProduct.TechnologyProduct, &out, []string{"id", "title", "image", "industry", "keyword"},
|
||||
page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ProductInstance, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
list = append(list, &ProductInstance{
|
||||
ID: v.GetEncodeID(),
|
||||
Title: v.Title,
|
||||
Image: v.Image.Image,
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Product) Detail(id uint64) (*ProductDetail, error) {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
mTechnologyProduct.ID = id
|
||||
|
||||
isExist, err := model2.First(mTechnologyProduct.TechnologyProduct)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,产品信息不存在或已被删除")
|
||||
}
|
||||
mTechnologyProduct.Image.Image = mTechnologyProduct.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
mTechnologyProduct.Video = (&model2.Image{Image: mTechnologyProduct.Video}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
mTechnologyProduct.Material = (&model2.Image{Image: mTechnologyProduct.Material}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mTechnologyProduct.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/").Value)
|
||||
}
|
||||
// 推送访问登记
|
||||
service.Publish(config2.EventForVisitProduce, c.UID, model2.UserVisitKindForTechnologyProduct, id)
|
||||
|
||||
return &ProductDetail{
|
||||
ID: mTechnologyProduct.GetEncodeID(),
|
||||
TechnologyProduct: mTechnologyProduct.TechnologyProduct,
|
||||
LeadStandardTitle: mTechnologyProduct.GetLeadStandardTitle(),
|
||||
MaturityTitle: config.GetTechnologyMaturityTitle(mTechnologyProduct.Maturity),
|
||||
CooperationModeTitle: config.GetTechnologyCooperationModeTitle(mTechnologyProduct.CooperationMode),
|
||||
Industrys: _industrys,
|
||||
Keywords: mTechnologyProduct.GetKeywordAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewProduct() ProductHandle {
|
||||
return func(session *session.Enterprise) *Product {
|
||||
return &Product{session}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user