feat:完善项目信息
This commit is contained in:
@ -44,7 +44,7 @@ func (*Manage) CompanyProduct(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
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)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package manage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
@ -29,6 +30,7 @@ type (
|
|||||||
// CompanyInstanceInfo 公司信息
|
// CompanyInstanceInfo 公司信息
|
||||||
CompanyInstanceInfo struct {
|
CompanyInstanceInfo struct {
|
||||||
CompanyBasicInfo
|
CompanyBasicInfo
|
||||||
|
KindTitle string `json:"kind_title"`
|
||||||
Industrys []string `json:"industrys"`
|
Industrys []string `json:"industrys"`
|
||||||
Directions []string `json:"directions"`
|
Directions []string `json:"directions"`
|
||||||
Introduce string `json:"introduce"`
|
Introduce string `json:"introduce"`
|
||||||
@ -36,9 +38,13 @@ type (
|
|||||||
// CompanyProductInfo 公司产品信息
|
// CompanyProductInfo 公司产品信息
|
||||||
CompanyProductInfo struct {
|
CompanyProductInfo struct {
|
||||||
*model.ManageCompanyProduct
|
*model.ManageCompanyProduct
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Industrys []string `json:"industrys"`
|
IsCollect bool `json:"is_collect"`
|
||||||
Keywords []string `json:"keywords"`
|
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,
|
Url: mManageCompany.Url,
|
||||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||||
},
|
},
|
||||||
|
KindTitle: mManageCompany.KindTitle(),
|
||||||
Industrys: mManageCompany.GetIndustryAttribute(),
|
Industrys: mManageCompany.GetIndustryAttribute(),
|
||||||
Directions: mManageCompany.GetDirectionAttribute(),
|
Directions: mManageCompany.GetDirectionAttribute(),
|
||||||
Introduce: mManageCompany.Introduce,
|
Introduce: mManageCompany.Introduce,
|
||||||
@ -77,10 +84,23 @@ func (c *Company) Product(id uint64, page, pageSize int) (*controller.ReturnPage
|
|||||||
list := make([]*CompanyProductInfo, 0)
|
list := make([]*CompanyProductInfo, 0)
|
||||||
|
|
||||||
for _, v := range out {
|
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{
|
list = append(list, &CompanyProductInfo{
|
||||||
ManageCompanyProduct: v,
|
ManageCompanyProduct: v,
|
||||||
ID: v.GetEncodeID(),
|
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(),
|
Keywords: v.GetKeywordAttribute(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ type ManageCompany struct {
|
|||||||
type ManageCompanyProduct struct {
|
type ManageCompanyProduct struct {
|
||||||
*model.TechnologyProduct
|
*model.TechnologyProduct
|
||||||
VisitCount int `json:"visit_count"`
|
VisitCount int `json:"visit_count"`
|
||||||
IsCollect uint64 `json:"is_collect"`
|
IsCollect uint64 `json:"-"`
|
||||||
CollectCount int `json:"collect_count"`
|
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").
|
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",
|
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",
|
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)).
|
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",
|
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)).
|
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",
|
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)).
|
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)).
|
mNewUserCollect.TableName(), uid, model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("")).
|
Joins(fmt.Sprintf("")).
|
||||||
Where("u_c.company_id = ?", id).
|
Where("u_c.company_id = ?", id).
|
||||||
|
Where("p.id > ?", 0).
|
||||||
Where("u_c.invalid_status = ?", model.InvalidStatusForNot).
|
Where("u_c.invalid_status = ?", model.InvalidStatusForNot).
|
||||||
Where("u_c.is_deleted = ?", model.DeleteStatusForNot)
|
Where("u_c.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
@ -122,6 +122,24 @@ const (
|
|||||||
TechnologyMaturityForProduce
|
TechnologyMaturityForProduce
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetTechnologyMaturityTitle(key TechnologyMaturity) string {
|
||||||
|
switch key {
|
||||||
|
case TechnologyMaturityForDev:
|
||||||
|
return "正在研发"
|
||||||
|
case TechnologyMaturityForTest:
|
||||||
|
return "小试阶段"
|
||||||
|
case TechnologyMaturityForTestFinish:
|
||||||
|
return "通过小试"
|
||||||
|
case TechnologyMaturityForModerateTest:
|
||||||
|
return "中试阶段"
|
||||||
|
case TechnologyMaturityForModerateTestFinish:
|
||||||
|
return "通过中试"
|
||||||
|
case TechnologyMaturityForProduce:
|
||||||
|
return "可规模生产"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// TechnologyCooperationMode 科技合作模式
|
// TechnologyCooperationMode 科技合作模式
|
||||||
type TechnologyCooperationMode int
|
type TechnologyCooperationMode int
|
||||||
|
|
||||||
@ -145,3 +163,27 @@ const (
|
|||||||
// TechnologyCooperationModeForOther 其他
|
// TechnologyCooperationModeForOther 其他
|
||||||
TechnologyCooperationModeForOther
|
TechnologyCooperationModeForOther
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetTechnologyCooperationModeTitle(key TechnologyCooperationMode) string {
|
||||||
|
switch key {
|
||||||
|
case TechnologyCooperationModeForJSTransfer:
|
||||||
|
return "技术转让"
|
||||||
|
case TechnologyCooperationModeForJSPermit:
|
||||||
|
return "技术许可"
|
||||||
|
case TechnologyCooperationModeForJSShare:
|
||||||
|
return "技术入股"
|
||||||
|
case TechnologyCooperationModeForCooperation:
|
||||||
|
return "合作开发"
|
||||||
|
case TechnologyCooperationModeForFinancing:
|
||||||
|
return "融资"
|
||||||
|
case TechnologyCooperationModeForCompany:
|
||||||
|
return "公司"
|
||||||
|
case TechnologyCooperationModeForAgentJoin:
|
||||||
|
return "代理加盟"
|
||||||
|
case TechnologyCooperationModeForMarketing:
|
||||||
|
return "市场推广"
|
||||||
|
case TechnologyCooperationModeForOther:
|
||||||
|
return "其他"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
@ -131,6 +131,8 @@ func (this *Instance) Handle() {
|
|||||||
&synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()},
|
&synchronized{iModel: model.NewUserCompany()}, &synchronized{iModel: model.NewUserExpert()},
|
||||||
&synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()},
|
&synchronized{iModel: model.NewUserLaboratory()}, &synchronized{iModel: model.NewUserResearch()},
|
||||||
&synchronized{iModel: model.NewUserAgent()},
|
&synchronized{iModel: model.NewUserAgent()},
|
||||||
|
&synchronized{iModel: model.NewUserVisit()},
|
||||||
|
&synchronized{iModel: model.NewUserCollect()},
|
||||||
// 数据管理
|
// 数据管理
|
||||||
&synchronized{iModel: model.NewManageCompany()}, &synchronized{iModel: model.NewManageExpert()},
|
&synchronized{iModel: model.NewManageCompany()}, &synchronized{iModel: model.NewManageExpert()},
|
||||||
&synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()},
|
&synchronized{iModel: model.NewManageLaboratory()}, &synchronized{iModel: model.NewManageResearch()},
|
||||||
|
@ -50,6 +50,18 @@ func (m *ManageCompany) TableName() string {
|
|||||||
return "manage_company"
|
return "manage_company"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ManageCompany) KindTitle() string {
|
||||||
|
switch m.Kind {
|
||||||
|
case ManageCompanyKindForListedEnterprise:
|
||||||
|
return "上市企业"
|
||||||
|
case ManageCompanyKindForHighQuality:
|
||||||
|
return "优质企业"
|
||||||
|
case ManageCompanyKindForOrdinary:
|
||||||
|
return "普通企业"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ManageCompany) GetIndustryAttribute() []string {
|
func (m *ManageCompany) GetIndustryAttribute() []string {
|
||||||
out := make([]string, 0)
|
out := make([]string, 0)
|
||||||
_ = utils.FromJSON(m.Industry, &out)
|
_ = utils.FromJSON(m.Industry, &out)
|
||||||
|
@ -69,6 +69,20 @@ func (m *TechnologyProduct) TableName() string {
|
|||||||
return "technology_product"
|
return "technology_product"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TechnologyProduct) GetLeadStandardTitle() string {
|
||||||
|
switch m.LeadStandard {
|
||||||
|
case TechnologyProductLeadStandardForDomesticXJ:
|
||||||
|
return "国内先进"
|
||||||
|
case TechnologyProductLeadStandardForDomesticLX:
|
||||||
|
return "国内领先"
|
||||||
|
case TechnologyProductLeadStandardForInternationalXJ:
|
||||||
|
return "国际先进"
|
||||||
|
case TechnologyProductLeadStandardForInternationalLX:
|
||||||
|
return "国际领先"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (m *TechnologyProduct) GetIndustryAttribute() []string {
|
func (m *TechnologyProduct) GetIndustryAttribute() []string {
|
||||||
out := make([]string, 0)
|
out := make([]string, 0)
|
||||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||||
|
@ -83,17 +83,25 @@ func TestNewInstance2(t *testing.T) {
|
|||||||
|
|
||||||
query := elastic.NewBoolQuery()
|
query := elastic.NewBoolQuery()
|
||||||
query.Must(elastic.NewMatchQuery("title", "一种"))
|
query.Must(elastic.NewMatchQuery("title", "一种"))
|
||||||
query.Must(elastic.NewMatchPhraseQuery("industry", "你是"))
|
//query.Must(elastic.NewMatchPhraseQuery("industry", "你是"))
|
||||||
|
|
||||||
service := client.Search().Index("es_patent_index")
|
service := client.Search().
|
||||||
|
//Index("es_patent_index")
|
||||||
|
Index("es_manage_index_1")
|
||||||
|
|
||||||
result, err := service.From(1).Size(1).TrackTotalHits(true).Pretty(true).Query(query).Do(context.Background())
|
result, err := service.From(0).Size(10).
|
||||||
|
//Explain(true).
|
||||||
|
AllowPartialSearchResults(true).
|
||||||
|
TrackTotalHits(true).
|
||||||
|
TrackScores(true).Query(query).Do(context.Background())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
t.Log(utils.AnyToJSON(result))
|
||||||
t.Log(utils.AnyToJSON(result.Hits.TotalHits.Value))
|
t.Log(utils.AnyToJSON(result.Hits.TotalHits.Value))
|
||||||
for _, v := range result.Hits.Hits {
|
for _, v := range result.Hits.Hits {
|
||||||
|
t.Log(*v.Score)
|
||||||
t.Log(string(v.Source))
|
t.Log(string(v.Source))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user