feat:完善项目信息
This commit is contained in:
@ -13,7 +13,7 @@ type (
|
|||||||
// AchievementInfo 成果信息
|
// AchievementInfo 成果信息
|
||||||
AchievementInfo struct {
|
AchievementInfo struct {
|
||||||
*model.TechnologyAchievementsInfo
|
*model.TechnologyAchievementsInfo
|
||||||
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
Config *model2.TechnologyAchievementConfig `json:"config"`
|
||||||
}
|
}
|
||||||
// ProjectInfo 项目信息
|
// ProjectInfo 项目信息
|
||||||
ProjectInfo struct {
|
ProjectInfo struct {
|
||||||
@ -78,7 +78,7 @@ func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, er
|
|||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &AchievementInfo{
|
list = append(list, &AchievementInfo{
|
||||||
TechnologyAchievementsInfo: v,
|
TechnologyAchievementsInfo: v,
|
||||||
ChargeInfo: v.GetChargeInfoAttribute(),
|
Config: v.GetConfigAttribute(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
@ -45,7 +45,7 @@ func (*Technology) Demand(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := technology.NewDemand()(nil).Instance(form.Title, form.Industry, form.Kind, form.Page, form.PageSize)
|
data, err := technology.NewDemand()(getSession(c)).Instance(form.Title, form.Industry, form.Kind, form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ func (*Technology) DemandDetail(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := technology.NewDemand()(nil).Detail(form.Convert())
|
data, err := technology.NewDemand()(getSession(c)).Detail(form.Convert())
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,18 +71,41 @@ func (*Technology) Achievement(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := technology.NewAchievement()(nil).Instance(form.Title, form.Industry, form.Page, form.PageSize)
|
data, err := technology.NewAchievement()(getSession(c)).Instance(form.Title, form.Industry, form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Technology) AchievementDetail(c *gin.Context) {
|
func (*Technology) AchievementDetail(c *gin.Context) {
|
||||||
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := technology.NewAchievement()(getSession(c)).Detail(form.Convert())
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Technology) Product(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
api.IDStringForm
|
Title string `json:"title" form:"title"`
|
||||||
|
api.PageForm
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := technology.NewAchievement()(nil).Detail(form.Convert())
|
data, err := technology.NewProduct()(getSession(c)).Instance(form.Title, form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Technology) ProductDetail(c *gin.Context) {
|
||||||
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := technology.NewProduct()(getSession(c)).Detail(form.Convert())
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ type (
|
|||||||
// AchievementInfo 成果信息
|
// AchievementInfo 成果信息
|
||||||
AchievementInfo struct {
|
AchievementInfo struct {
|
||||||
*model.TechnologyAchievementInfo
|
*model.TechnologyAchievementInfo
|
||||||
ChargeInfo *model2.TechnologyAchievementChargeInfo `json:"charge_info"`
|
Config *model2.TechnologyAchievementConfig `json:"config"`
|
||||||
}
|
}
|
||||||
// ProjectInfo 项目信息
|
// ProjectInfo 项目信息
|
||||||
ProjectInfo struct {
|
ProjectInfo struct {
|
||||||
@ -67,7 +67,7 @@ func achievement(uids []uint64, page, pageSize int) (*controller.ReturnPages, er
|
|||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &AchievementInfo{
|
list = append(list, &AchievementInfo{
|
||||||
TechnologyAchievementInfo: v,
|
TechnologyAchievementInfo: v,
|
||||||
ChargeInfo: v.GetChargeInfoAttribute(),
|
Config: v.GetConfigAttribute(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
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) {
|
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
// TODO:缺少会员判断标准
|
// TODO:缺少会员判断标准
|
||||||
// ES标准判定
|
// ES标准判定
|
||||||
s := service.NewESPatent(
|
manage := service.NewESPatent()
|
||||||
service.WithPatentTitle(title),
|
|
||||||
service.WithPatentIndustry(industry),
|
if title != "" {
|
||||||
)
|
service.WithPatentTitle(title)(manage)
|
||||||
out, count1, err := s.Search(page, pageSize)
|
}
|
||||||
|
if industry != "" {
|
||||||
|
service.WithPatentIndustry(industry)(manage)
|
||||||
|
}
|
||||||
|
out, count1, err := manage.Search(page, pageSize)
|
||||||
|
|
||||||
list := make([]*PatentInfo, 0)
|
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}
|
||||||
|
}
|
||||||
|
}
|
@ -14,12 +14,12 @@ type TechnologyAchievement struct {
|
|||||||
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
Title string `gorm:"column:title;type:varchar(100);default:'';comment:成果名称" json:"title"`
|
||||||
Image
|
Image
|
||||||
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
File string `gorm:"column:file;type:varchar(255);default:'';comment:证明材料" json:"file"`
|
||||||
ChargeInfo string `gorm:"column:charge_info;type:varchar(255);default:'';comment:收费信息" json:"charge_info"`
|
|
||||||
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
|
||||||
Customer string `gorm:"column:customer;type:varchar(255);default:'';comment:应用客户" json:"-"`
|
Customer string `gorm:"column:customer;type:varchar(255);default:'';comment:应用客户" json:"-"`
|
||||||
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
|
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
|
||||||
LeadStandard TechnologyProductLeadStandard `gorm:"column:lead_standard;type:tinyint(1);default:0;comment:领先标准" json:"lead_standard"`
|
LeadStandard TechnologyProductLeadStandard `gorm:"column:lead_standard;type:tinyint(1);default:0;comment:领先标准" json:"lead_standard"`
|
||||||
CooperationMode config.TechnologyCooperationMode `gorm:"column:cooperation_mode;type:tinyint(1);default:0;comment:合作模式" json:"cooperation_mode"`
|
CooperationMode config.TechnologyCooperationMode `gorm:"column:cooperation_mode;type:tinyint(1);default:0;comment:合作模式" json:"cooperation_mode"`
|
||||||
|
Config string `gorm:"column:config;type:varchar(255);default:'';comment:配置信息" json:"config"`
|
||||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
|
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
|
||||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||||
Source string `gorm:"source:introduce;type:text;comment:成果来源" json:"source"`
|
Source string `gorm:"source:introduce;type:text;comment:成果来源" json:"source"`
|
||||||
@ -29,8 +29,8 @@ type TechnologyAchievement struct {
|
|||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
|
||||||
// TechnologyAchievementChargeInfo 成果收费参数信息
|
// TechnologyAchievementConfig 成果收费参数信息
|
||||||
type TechnologyAchievementChargeInfo struct {
|
type TechnologyAchievementConfig struct {
|
||||||
VideoFile string `json:"video_file"` // 视频文件
|
VideoFile string `json:"video_file"` // 视频文件
|
||||||
VideoPrice float64 `json:"video_price"` // 视频价格
|
VideoPrice float64 `json:"video_price"` // 视频价格
|
||||||
VideoFreeTime int `json:"video_free_time"` // 视频观看免费时长
|
VideoFreeTime int `json:"video_free_time"` // 视频观看免费时长
|
||||||
@ -64,15 +64,15 @@ func (m *TechnologyAchievement) TableName() string {
|
|||||||
return "technology_achievement"
|
return "technology_achievement"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TechnologyAchievement) GetChargeInfoAttribute() *TechnologyAchievementChargeInfo {
|
func (m *TechnologyAchievement) GetConfigAttribute() *TechnologyAchievementConfig {
|
||||||
out := new(TechnologyAchievementChargeInfo)
|
out := new(TechnologyAchievementConfig)
|
||||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
_ = json.Unmarshal([]byte(m.Config), &out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TechnologyAchievement) SetChargeInfoAttribute(value *TechnologyAchievementChargeInfo) {
|
func (m *TechnologyAchievement) SetConfigAttribute(value *TechnologyAchievementConfig) {
|
||||||
_bytes, _ := json.Marshal(value)
|
_bytes, _ := json.Marshal(value)
|
||||||
m.ChargeInfo = string(_bytes)
|
m.Config = string(_bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TechnologyAchievement) GetIndustryAttribute() []string {
|
func (m *TechnologyAchievement) GetIndustryAttribute() []string {
|
||||||
|
@ -18,7 +18,7 @@ type UserVisitKind int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// UserVisitKindForLaboratory 实验室
|
// UserVisitKindForLaboratory 实验室
|
||||||
UserVisitKindForLaboratory UserCollectKind = iota + 1
|
UserVisitKindForLaboratory UserVisitKind = iota + 1
|
||||||
// UserVisitKindForExpert 专家
|
// UserVisitKindForExpert 专家
|
||||||
UserVisitKindForExpert
|
UserVisitKindForExpert
|
||||||
// UserVisitKindForCompany 公司
|
// UserVisitKindForCompany 公司
|
||||||
|
@ -137,6 +137,8 @@ func registerAPI(app *gin.Engine) {
|
|||||||
technologyV1.POST("/demand/detail", _api.DemandDetail)
|
technologyV1.POST("/demand/detail", _api.DemandDetail)
|
||||||
technologyV1.POST("/achievement", _api.Achievement)
|
technologyV1.POST("/achievement", _api.Achievement)
|
||||||
technologyV1.POST("/achievement/detail", _api.AchievementDetail)
|
technologyV1.POST("/achievement/detail", _api.AchievementDetail)
|
||||||
|
technologyV1.POST("/product", _api.Product)
|
||||||
|
technologyV1.POST("/product/detail", _api.ProductDetail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user