Browse Source

Merge branch 'cygx_10.9' into debug

# Conflicts:
#	models/db.go
ziwen 1 year ago
parent
commit
e4f269c8b5
2 changed files with 65 additions and 13 deletions
  1. 47 10
      controllers/home.go
  2. 18 3
      models/report.go

+ 47 - 10
controllers/home.go

@@ -639,7 +639,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 
 // @Title 首页列表接口
 // @Description 首页列表接口
-// @Param   TagId   query   int  true       "标签选择"
+// @Param   TagIds   query   string  true       "标签选择"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.HomeArtAndChartListResp
@@ -659,7 +659,7 @@ func (this *HomeController) NewList() {
 	}
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
-	//tagId, _ := this.GetInt("TagId")
+	tagIds := this.GetString("TagIds")
 
 	var startSize int
 	if pageSize <= 0 {
@@ -682,14 +682,51 @@ func (this *HomeController) NewList() {
 		br.ErrMsg = "GetCountCompanyProductCompanyId,Err:" + err.Error()
 		return
 	}
-	//if tagId > 0 {
-	//	tagInfo, err := models.GetCygxTagByTagId(tagId)
-	//	if err != nil && err.Error() != utils.ErrNoRow() {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
-	//		return
-	//	}
-	//}
+	var articleTypes, activityTypes, industries, subjectNames string
+
+	if tagIds != "" {
+		tags := strings.Split(tagIds, ",")
+		for _, tagIdStr := range tags {
+			tagId, err := strconv.Atoi(tagIdStr)
+			if err != nil {
+				br.Msg = "转换失败"
+				br.ErrMsg = "tagid转换失败,Err:" + err.Error()
+				return
+			}
+			tagInfo, err := models.GetCygxTagByTagId(tagId)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取失败"
+				br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
+				return
+			}
+			activityTypes += tagInfo.ActivityTypes + ","
+			articleTypes += tagInfo.ArticleTypes + ","
+			industries += tagInfo.Industries + ","
+			subjectNames += tagInfo.SubjectNames + ","
+		}
+	}
+	activityTypes = strings.TrimRight(activityTypes,",")
+	articleTypes = strings.TrimRight(articleTypes,",")
+	industries = strings.TrimRight(industries,",")
+	subjectNames = strings.TrimRight(subjectNames,",")
+
+	articleTypesCond := ``
+	if articleTypes != "" {
+		articleTypesCond += ` AND sub_category_name In (`+ activityTypes +`) `
+	}
+	activityTypesCond := ``
+	if activityTypes != "" {
+		activityTypesCond += ` AND sub_category_name In (`+ activityTypes +`) `
+	}
+	industriesCond := ``
+	if industries != "" {
+		industriesCond += ` AND sub_category_name In (`+ activityTypes +`) `
+	}
+	subjectNamesCond := ``
+	if subjectNames != "" {
+		subjectNamesCond += ` AND sub_category_name In (`+ activityTypes +`) `
+	}
+
 	//condition += " AND source = 'article' "
 	//查询近一个月的数据
 	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"

+ 18 - 3
models/report.go

@@ -1135,7 +1135,7 @@ type TimeLineReportItem struct {
 	SubCategoryName string `description:"二级分类"`
 	IsRed           bool   `description:"是否标红"`
 	Readnum         int    `description:"阅读数量"`
-	Resource        int    `description:"来源类型,1:文章、2:产品内测、3:晨报点评"`
+	Resource        int    `description:"来源类型,1:文章、2:产品内测、3:晨报点评 4:活动回放"`
 }
 
 // 获取产业报告+晨会点评列表
@@ -1192,12 +1192,27 @@ FROM
 	WHERE
 		p.product_interior_id = pm.product_interior_id 
 		AND p.visible_range = 1 
-	AND pm.industrial_management_id = ? 
+	AND pm.industrial_management_id = ? UNION ALL
+ 	SELECT 
+		ca.activity_id AS id,
+		cav.video_name AS title,
+		ca.activity_time AS publish_time,
+		cav.video_url AS video_url,
+		'' AS sub_category_name,
+		'' AS content,
+		4 AS resource,
+		( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.activity_id = ca.activity_id ) AS readnum 
+	FROM 
+		cygx_activity AS ca 
+		INNER JOIN cygx_activity_video AS cav ON ca.activity_id = cav.activity_id 
+		INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
+	WHERE 
+		cam.industrial_management_id = ? AND cam.source = 1 
 	) AS t 
 `
 	sql += ` ORDER BY 
 	t.publish_time DESC LIMIT ?,? `
-	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
 	return
 }