feat:完善项目信息
This commit is contained in:
@ -44,7 +44,7 @@ func (*Manage) CompanyProduct(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewCompany()(nil).Product((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
|
||||
data, err := manage.NewCompany()(getSession(c)).Product((&api.IDStringForm{ID: form.CompanyID}).Convert(), form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
@ -29,6 +30,7 @@ type (
|
||||
// CompanyInstanceInfo 公司信息
|
||||
CompanyInstanceInfo struct {
|
||||
CompanyBasicInfo
|
||||
KindTitle string `json:"kind_title"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Directions []string `json:"directions"`
|
||||
Introduce string `json:"introduce"`
|
||||
@ -36,9 +38,13 @@ type (
|
||||
// CompanyProductInfo 公司产品信息
|
||||
CompanyProductInfo struct {
|
||||
*model.ManageCompanyProduct
|
||||
ID string `json:"id"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
ID string `json:"id"`
|
||||
IsCollect bool `json:"is_collect"`
|
||||
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"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -59,6 +65,7 @@ func (c *Company) Instance(id uint64) (*CompanyInstanceInfo, error) {
|
||||
Url: mManageCompany.Url,
|
||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||
},
|
||||
KindTitle: mManageCompany.KindTitle(),
|
||||
Industrys: mManageCompany.GetIndustryAttribute(),
|
||||
Directions: mManageCompany.GetDirectionAttribute(),
|
||||
Introduce: mManageCompany.Introduce,
|
||||
@ -77,10 +84,23 @@ func (c *Company) Product(id uint64, page, pageSize int) (*controller.ReturnPage
|
||||
list := make([]*CompanyProductInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
v.Video = (&model2.Image{Image: v.Video}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
v.Material = (&model2.Image{Image: v.Material}).Analysis(config2.SystemConfig[config2.SysImageDomain])
|
||||
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range v.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/").Value)
|
||||
}
|
||||
list = append(list, &CompanyProductInfo{
|
||||
ManageCompanyProduct: v,
|
||||
ID: v.GetEncodeID(),
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
IsCollect: v.IsCollect > 0,
|
||||
LeadStandardTitle: v.GetLeadStandardTitle(),
|
||||
MaturityTitle: config.GetTechnologyMaturityTitle(v.Maturity),
|
||||
CooperationModeTitle: config.GetTechnologyCooperationModeTitle(v.CooperationMode),
|
||||
Industrys: _industrys,
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ type ManageCompany struct {
|
||||
type ManageCompanyProduct struct {
|
||||
*model.TechnologyProduct
|
||||
VisitCount int `json:"visit_count"`
|
||||
IsCollect uint64 `json:"is_collect"`
|
||||
IsCollect uint64 `json:"-"`
|
||||
CollectCount int `json:"collect_count"`
|
||||
}
|
||||
|
||||
@ -24,17 +24,18 @@ func (m *ManageCompany) Product(id, uid uint64, page, pageSize int, count *int64
|
||||
|
||||
db := orm.GetDB().Table(model.NewUserCompany().TableName()+" u_c").
|
||||
Select("p.id", "p.title", "p.image", "p.industry", "p.maturity", "p.lead_standard", "p.cooperation_mode",
|
||||
"p.keyword", "v.count AS visit_count", "IFNULL(c_u.id, 0) AS is_collect", "c.count AS collect_count").
|
||||
"p.keyword", "v.count AS visit_count", "c_u.id AS is_collect", "c.count AS collect_count").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_c.uid = p.uid AND p.shelf_status = %d AND p.status = %d AND p.is_deleted = %d",
|
||||
model.NewTechnologyProduct().TableName(), model.ShelfStatusForUp, model.TechnologyProductStatusForAgree, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
|
||||
model.NewUserVisit().TableName(), model.UserVisitKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON p.id = c.object_id",
|
||||
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c_u ON p.id = c_u.product_id AND c_u.uid = %d AND c_u.kind = %d AND c_u.is_deleted = %d",
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c_u ON p.id = c_u.object_id AND c_u.uid = %d AND c_u.kind = %d AND c_u.is_deleted = %d",
|
||||
mNewUserCollect.TableName(), uid, model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("")).
|
||||
Where("u_c.company_id = ?", id).
|
||||
Where("p.id > ?", 0).
|
||||
Where("u_c.invalid_status = ?", model.InvalidStatusForNot).
|
||||
Where("u_c.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
Reference in New Issue
Block a user