Browse Source

产业关联的文章分类

xingzai 3 years ago
parent
commit
2bc6e3769c
4 changed files with 79 additions and 2 deletions
  1. 38 0
      controllers/report.go
  2. 2 2
      controllers/tactics.go
  3. 14 0
      models/industrial_management.go
  4. 25 0
      models/report_mapping.go

+ 38 - 0
controllers/report.go

@@ -102,6 +102,44 @@ func (this *ReportController) IndustryList() {
 	br.Data = resp
 }
 
+// @Title 产业下所关联的文章分类列表
+// @Description 产业下所关联的文章分类列表接口
+// @Param   IndustrialManagementId   query   int  true       "产业ID"
+// @Success 200 {object} models.IndustrialToArticleCategoryListRep
+// @router /toArticleCategoryList [get]
+func (this *ReportController) ArticleCategoryList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
+	if industrialManagementId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	list, err := models.IndustrialToArticleCategory(industrialManagementId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
+	fmt.Println(detail)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.IndustrialToArticleCategoryListRep)
+	resp.List = list
+	resp.LayoutTime = detail.LayoutTime
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
 // @Title 置顶/取消置顶
 // @Description 置顶
 // @Param	request	body models.CygxIndustryTopRep true "type json string"

+ 2 - 2
controllers/tactics.go

@@ -21,8 +21,8 @@ type TacticsCommonController struct {
 	BaseCommonController
 }
 
-// @Title 策略列表接口
-// @Description 获取策略列表接口
+// @Title 策略、行业、产业列表接口
+// @Description 获取策略、行业、产业通用列表接口
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   CategoryId   query   int  true       "分类ID"

+ 14 - 0
models/industrial_management.go

@@ -4,6 +4,13 @@ import (
 	"rdluck_tools/orm"
 )
 
+type IndustrialManagementRep struct {
+	IndustryName      string `description:"产业名称"`
+	ChartPermissionId int    `description:"权限id"`
+	RecommendedIndex  int    `description:"推荐指数"`
+	LayoutTime        string `description:"布局时间"`
+}
+
 //产业列表
 func GetIndustrialManagementAll(ChartPermissionId int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
@@ -39,3 +46,10 @@ func GetIndustrialManagementCount(IndustrialManagementId int) (count int, err er
 	err = o.Raw(sqlCount, IndustrialManagementId).QueryRow(&count)
 	return
 }
+
+func GetIndustrialManagementDetail(industrialManagementId int) (items *IndustrialManagementRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industrial_management WHERE industrial_management_id = ?`
+	err = o.Raw(sql, industrialManagementId).QueryRow(&items)
+	return
+}

+ 25 - 0
models/report_mapping.go

@@ -38,3 +38,28 @@ func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error)
 	_, err = o.Raw(sql, ChartPermissionId).QueryRows(&items)
 	return
 }
+
+type IndustrialToArticleCategoryRep struct {
+	CategoryId      int    `description:"分类ID"`
+	SubCategoryName string `description:"权限名称"`
+	IsRead          bool   `description:"是否标红"`
+}
+
+type IndustrialToArticleCategoryListRep struct {
+	LayoutTime string `description:"布局时间"`
+	List       []*IndustrialToArticleCategoryRep
+}
+
+//产业下所关联的文章分类列表
+func IndustrialToArticleCategory(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT map.match_type_name,map.category_id
+    FROM cygx_report_mapping AS map
+	INNER JOIN cygx_article AS art ON art.category_id = map.category_id
+	INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
+	WHERE map.report_type = 2 
+	AND man_g.industrial_management_id =?
+	GROUP BY map.match_type_name`
+	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
+	return
+}