Răsfoiți Sursa

Merge branches 'clpt_v2' and 'clpt_v1' of http://8.136.199.33:3000/cxzhang/hongze_clpt into clpt_v2

xingzai 2 ani în urmă
părinte
comite
c41e638679
3 a modificat fișierele cu 56 adăugiri și 16 ștergeri
  1. 17 0
      controllers/home.go
  2. 18 1
      controllers/search.go
  3. 21 15
      models/home.go

+ 17 - 0
controllers/home.go

@@ -131,6 +131,23 @@ func (this *MobileHomeController) List() {
 		}
 		chartList[k].IsNeedJump = true
 		chartList[k].Source = 2
+
+		if v.PtagName != "" {
+			labelItem := new(models.LabelList)
+			labelItem.PtagName = v.PtagName
+			labelItem.CtagName = v.CtagName
+			chartList[k].LabelList = append(chartList[k].LabelList, labelItem)
+		}
+
+		if v.PtagNameTwo != "" {
+			labelItemTwo := new(models.LabelList)
+			labelItemTwo.PtagName = v.PtagNameTwo
+			labelItemTwo.CtagName = v.CtagNameTwo
+			chartList[k].LabelList = append(chartList[k].LabelList, labelItemTwo)
+		}
+		if len(chartList[k].LabelList) == 0 {
+			chartList[k].LabelList = make([]*models.LabelList, 0)
+		}
 	}
 
 	if len(chartList) == 0 {

+ 18 - 1
controllers/search.go

@@ -27,7 +27,7 @@ type MobileSearchController struct {
 // @Param   KeyWord   query   string  true       "搜索关键词"
 // @Param   OrderColumn   query   string  false       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
 // @Param   ListType   query   int  false       "列表类型,1最新/全部,2 纪要 ,3图表 默认1"
-// @Success 200 {object} models.SearchItem
+// @Success 200 {object} models.SearchResp
 // @router /list [get]
 func (this *MobileSearchController) ListHomeArtAndChart() {
 	br := new(models.BaseResponse).Init()
@@ -136,6 +136,23 @@ func (this *MobileSearchController) ListHomeArtAndChart() {
 		if v.CtagNameTwo != "" {
 			chartList[k].CtagNamePc += "," + v.CtagNameTwo
 		}
+
+		if v.PtagName != "" {
+			labelItem := new(models.LabelList)
+			labelItem.PtagName = v.PtagName
+			labelItem.CtagName = v.CtagName
+			chartList[k].LabelList = append(chartList[k].LabelList, labelItem)
+		}
+
+		if v.PtagNameTwo != "" {
+			labelItemTwo := new(models.LabelList)
+			labelItemTwo.PtagName = v.PtagNameTwo
+			labelItemTwo.CtagName = v.CtagNameTwo
+			chartList[k].LabelList = append(chartList[k].LabelList, labelItemTwo)
+		}
+		if len(chartList[k].LabelList) == 0 {
+			chartList[k].LabelList = make([]*models.LabelList, 0)
+		}
 	}
 	if len(chartList) == 0 {
 		chartList = make([]*models.HomeChartListResp, 0)

+ 21 - 15
models/home.go

@@ -35,21 +35,27 @@ type HomeArticle struct {
 }
 
 type HomeChartListResp struct {
-	ChartId     int    `description:"图表ID"`
-	Title       string `description:"标题"`
-	TitleEn     string `description:"英文标题 "`
-	CreateDate  string `description:"创建时间"`
-	PtagName    string `description:"父类名称"`
-	CtagName    string `description:"子类名称"`
-	PtagNameTwo string `description:"父类名称"`
-	CtagNameTwo string `description:"子类名称"`
-	CtagNamePc  string `description:"Pc端所有的分类名称"`
-	BodyHtml    string `orm:"column(cover)";description:"图片链接"`
-	HttpUrl     string `orm:"column(iframe)";description:"文章链接跳转地址"`
-	IsNeedJump  bool   `description:"是否需要跳转链接地址"`
-	IsTop       bool   `description:"是否置顶"`
-	NumTop      int    `description:"置顶数量"`
-	Source      int    `description:"来源  1:文章, 2:图表"`
+	ChartId     int          `description:"图表ID"`
+	Title       string       `description:"标题"`
+	TitleEn     string       `description:"英文标题 "`
+	CreateDate  string       `description:"创建时间"`
+	PtagName    string       `description:"父类名称"`
+	CtagName    string       `description:"子类名称"`
+	PtagNameTwo string       `description:"父类名称"`
+	CtagNameTwo string       `description:"子类名称"`
+	CtagNamePc  string       `description:"Pc端所有的分类名称"`
+	BodyHtml    string       `orm:"column(cover)";description:"图片链接"`
+	HttpUrl     string       `orm:"column(iframe)";description:"文章链接跳转地址"`
+	IsNeedJump  bool         `description:"是否需要跳转链接地址"`
+	IsTop       bool         `description:"是否置顶"`
+	NumTop      int          `description:"置顶数量"`
+	Source      int          `description:"来源  1:文章, 2:图表"`
+	LabelList   []*LabelList `description:"图表标签列表"`
+}
+
+type LabelList struct {
+	PtagName string `description:"父类名称"`
+	CtagName string `description:"子类名称"`
 }
 
 func GetHomeCount(condition string, pars []interface{}) (count int, err error) {