浏览代码

产业文章列表添加产业ID查询

xingzai 2 年之前
父节点
当前提交
a709afe0a4
共有 2 个文件被更改,包括 35 次插入8 次删除
  1. 17 0
      controllers/report.go
  2. 18 8
      models/industrial_management.go

+ 17 - 0
controllers/report.go

@@ -402,6 +402,7 @@ func (this *MobileReportController) ArticleCategoryList() {
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   CategoryId   query   int  true       "分类ID"
+// @Param   IndustrialManagementId   query   int  false       "产业ID"
 // @Success 200 {object} models.TacticsListResp
 // @router /articleList/byCategoryId [get]
 func (this *MobileReportController) List() {
@@ -420,6 +421,7 @@ func (this *MobileReportController) List() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	categoryId, _ := this.GetInt("CategoryId")
+	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
 
 	var startSize int
 	if pageSize <= 0 {
@@ -480,6 +482,21 @@ func (this *MobileReportController) List() {
 	condition += ` AND category_id_two=? `
 	pars = append(pars, categoryId)
 
+	if industrialManagementId > 0 {
+		industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
+			return
+		}
+		articleIdList := make([]string, 0)
+		for _, v := range industrialManageentList {
+			articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
+		}
+		condition += ` AND a.article_id IN (  ` + utils.GetOrmInReplace(len(articleIdList)) + ` )  `
+		pars = append(pars, articleIdList)
+	}
+
 	total, err = models.GetHomeCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 18 - 8
models/industrial_management.go

@@ -226,14 +226,6 @@ func GetIndustrialSubjectAllByIndustrialId(industrialIdArr []int) (items []*Indu
 	return
 }
 
-//标的列表
-func GetIndustrialSubjectAllByIndustrialId111(industrialIdArr []int) (items []*IndustrialSubject, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_industrial_subject WHERE industrial_management_id IN  (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   `
-	_, err = o.Raw(sql, industrialIdArr).QueryRows(&items)
-	return
-}
-
 //获取标的列表
 func GetIndustrialListByarticleId(pars []interface{}, condition string) (items []*IndustrialManagementIdInt, err error) {
 	o := orm.NewOrm()
@@ -268,3 +260,21 @@ func GetIndustryArtCountByCondition(condition string, pars []interface{}) (list
 	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
 	return
 }
+
+type IndustrialArticleGroupManagementResp struct {
+	IndustrialManagementId int `description:"产业Id"`
+	ArticleId              int `description:"文章ID"`
+}
+
+// GetIndustrialArticleGroupManagementByIndustrialManagementId 获取产业文章关联的文章ID
+func GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId int) (list []*IndustrialArticleGroupManagementResp, err error) {
+	sql := `SELECT
+				*
+			FROM
+				cygx_industrial_article_group_management 
+			WHERE
+				industrial_management_id = ? `
+
+	_, err = orm.NewOrm().Raw(sql, industrialManagementId).QueryRows(&list)
+	return
+}