Răsfoiți Sursa

PC端图表添加分类展示

xingzai 2 ani în urmă
părinte
comite
9832af6f5c
3 a modificat fișierele cu 42 adăugiri și 12 ștergeri
  1. 12 0
      controllers/chart.go
  2. 21 12
      models/chart.go
  3. 9 0
      services/chart.go

+ 12 - 0
controllers/chart.go

@@ -141,6 +141,18 @@ func (this *ChartController) Collection() {
 			listCollection[k].IsTop = true
 		}
 		listCollection[k].Source = 2
+		if v.PtagName != "" {
+			listCollection[k].CtagNamePc = v.PtagName
+		}
+		if v.CtagName != "" {
+			listCollection[k].CtagNamePc += "," + v.CtagName
+		}
+		if v.PtagNameTwo != "" {
+			listCollection[k].CtagNamePc += "," + v.PtagNameTwo
+		}
+		if v.CtagNameTwo != "" {
+			listCollection[k].CtagNamePc += "," + v.CtagNameTwo
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = listCollection

+ 21 - 12
models/chart.go

@@ -44,6 +44,8 @@ type ChartResultApidate struct {
 	Iframe        string `json:"iframe"`
 	Ptag          Ptag   `json:"ptag"`
 	Ctag          Ptag   `json:"ctag"`
+	PtagTwo       Ptag   `json:"ptag1"`
+	CtagTwo       Ptag   `json:"ctag1"`
 }
 
 type Ptag struct {
@@ -64,6 +66,8 @@ type CygxChart struct {
 	ChartId       int       `description:"图表id"`
 	PtagId        int       `description:"图表父类分类id"`
 	CtagId        int       `description:"图表子类分类id"`
+	PtagIdTwo     int       `description:"图表父类分类id"`
+	CtagIdTwo     int       `description:"图表子类分类id"`
 	Title         string    `description:"标题"`
 	TitleEn       string    `description:"英文标题 "`
 	CreateDate    string    `description:"本地创建时间"`
@@ -73,6 +77,8 @@ type CygxChart struct {
 	CtagName      string    `description:"子类名称"`
 	Cover         string    `description:"图表图片"`
 	Iframe        string    `description:"图表详情跳转地址"`
+	PtagNameTwo   string    `description:"父类名称"`
+	CtagNameTwo   string    `description:"子类名称"`
 }
 
 type CygxChartDetail struct {
@@ -133,18 +139,21 @@ type ChartUserTokenResultApi struct {
 }
 
 type HomeChartListResp struct {
-	ChartId    int    `description:"图表ID"`
-	Title      string `description:"标题"`
-	TitleEn    string `description:"英文标题 "`
-	CreateDate string `description:"创建时间"`
-	PtagName   string `description:"父类名称"`
-	CtagName   string `description:"子类名称"`
-	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:图表"`
 }
 
 type HomeChartListItem struct {

+ 9 - 0
services/chart.go

@@ -70,6 +70,11 @@ func GetChartListByApi(cont context.Context) (err error) {
 		item.PublishStatus = v.PublishStatus
 		item.PtagName = v.Ptag.Name
 		item.CtagName = v.Ctag.Name
+
+		item.PtagNameTwo = v.PtagTwo.Name
+		item.CtagNameTwo = v.CtagTwo.Name
+		item.PtagIdTwo = v.PtagTwo.Id
+		item.CtagIdTwo = v.CtagTwo.Id
 		item.Cover = v.Cover
 		item.Iframe = v.Iframe
 		count, err := models.GetChartCountById(v.ChartId)
@@ -91,6 +96,10 @@ func GetChartListByApi(cont context.Context) (err error) {
 			updateParams["PublishStatus"] = v.PublishStatus
 			updateParams["PtagName"] = v.Ptag.Name
 			updateParams["CtagName"] = v.Ctag.Name
+			updateParams["PtagNameTwo"] = v.PtagTwo.Name
+			updateParams["CtagNameTwo"] = v.CtagTwo.Name
+			updateParams["PtagIdTwo"] = v.PtagTwo.Id
+			updateParams["CtagIdTwo"] = v.CtagTwo.Id
 			updateParams["Cover"] = v.Cover
 			updateParams["Iframe"] = v.Iframe
 			whereParam := map[string]interface{}{"chart_id": v.ChartId}