소스 검색

需求池海外研究

xingzai 2 년 전
부모
커밋
4f277eb4b3
2개의 변경된 파일57개의 추가작업 그리고 49개의 파일을 삭제
  1. 36 29
      controllers/report.go
  2. 21 20
      models/report_mapping.go

+ 36 - 29
controllers/report.go

@@ -83,32 +83,27 @@ func (this *MobileReportController) TradeList() {
 	}
 
 	for k, v := range list {
-		list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
-		count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
-			return
-		}
-		if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
-			list[k].IsRed = true
-		}
+
 		var condition string
 		var pars []interface{}
 
-		categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(v.CategoryId)
-		if errCategory != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(v.CategoryId)
-			return
-		}
-		if categoryIdSet != "" {
-			condition = ` AND a.category_id IN(` + categoryIdSet + `)`
+		//categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(v.CategoryId)
+		//if errCategory != nil {
+		//	br.Msg = "获取信息失败"
+		//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(v.CategoryId)
+		//	return
+		//}
+		//if categoryIdSet != "" {
+		//	condition = ` AND a.category_id IN(` + categoryIdSet + `)`
+		//} else {
+		//	condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
+		//}
+
+		if v.PolymerizationId != "" {
+			condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
 		} else {
 			condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
 		}
-		//condition = " AND  a.category_id_two =  " + strconv.Itoa(v.CategoryId)
-		//condition += " OR  a.category_id =  " + strconv.Itoa(v.CategoryId)
 
 		if ChartPermissionId != utils.CE_LUE_ID {
 			var pageSize int
@@ -125,6 +120,19 @@ func (this *MobileReportController) TradeList() {
 				br.Msg = "GetHomeList,Err:" + err.Error()
 				return
 			}
+
+			if len(listArticle) > 0 {
+				list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+				count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+					return
+				}
+				if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
+					list[k].IsRed = true
+				}
+			}
 			list[k].ListArticle = listArticle
 		} else {
 			if mapCategory[v.CategoryId] > 0 {
@@ -134,7 +142,6 @@ func (this *MobileReportController) TradeList() {
 		}
 	}
 	resp := new(models.TradeReportMappingResp)
-
 	if len(list) == 0 {
 		list = make([]*models.TradeReportMapping, 0)
 	}
@@ -527,14 +534,14 @@ func (this *MobileReportController) List() {
 		//condition += ` AND category_id_two=? `
 		//pars = append(pars, categoryId)
 
-		categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
-		if errCategory != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-			return
-		}
-		if categoryIdSet != "" {
-			condition = ` AND category_id IN(` + categoryIdSet + `)`
+		//categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
+		//if errCategory != nil {
+		//	br.Msg = "获取信息失败"
+		//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
+		//	return
+		//}
+		if detail.PolymerizationId != "" {
+			condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
 		} else {
 			condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
 		}

+ 21 - 20
models/report_mapping.go

@@ -12,6 +12,8 @@ type ReportMapping struct {
 	ChartPermissionId   int    `description:"行业ID"`
 	IsRed               bool   `description:"是否标红"`
 	PermissionType      int    `description:"1主观,2客观"`
+	CategoryIdSet       int    `description:"分类映射id"`
+	PolymerizationId    string `description:"分类聚合ID"`
 }
 
 type ReportMappingHome struct {
@@ -22,13 +24,15 @@ type ReportMappingHome struct {
 }
 
 type TradeReportMapping struct {
-	CategoryId    int            `description:"分类ID"`
-	MatchTypeName string         `description:"匹配类型"`
-	IsRed         bool           `description:"是否标红"`
-	IsFollow      bool           `description:"是否关注"`
-	UpdateTime    string         `description:"更新时间"`
-	Readnum       int            `description:"阅读数量"`
-	ListArticle   []*HomeArticle `description:"文章列表"`
+	CategoryId       int            `description:"分类ID"`
+	CategoryIdSet    int            `description:"分类映射id"`
+	PolymerizationId string         `description:"分类聚合ID"`
+	MatchTypeName    string         `description:"匹配类型"`
+	IsRed            bool           `description:"是否标红"`
+	IsFollow         bool           `description:"是否关注"`
+	UpdateTime       string         `description:"更新时间"`
+	Readnum          int            `description:"阅读数量"`
+	ListArticle      []*HomeArticle `description:"文章列表"`
 }
 
 type ReportMappingResp struct {
@@ -75,22 +79,19 @@ ORDER BY
 func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-		MAX( art.publish_date ) AS update_time,
-		re.category_id,
-		re.sub_category_name,
-		re.match_type_name 
+			re.category_id,
+			re.category_id_set,
+			re.polymerization_id,
+			re.sub_category_name,
+			re.match_type_name 
 		FROM
-		cygx_report_mapping AS re
-		INNER JOIN cygx_article AS art ON re.category_id = art.category_id 
+			cygx_report_mapping AS re 
 		WHERE
-		re.chart_permission_id =? 
-		AND re.report_type = 1 
-		AND art.is_class = 1 
-		AND re.category_id NOT IN (67)
-		GROUP BY
-		art.category_id 
+			re.chart_permission_id = ? 
+			AND re.report_type = 1 
+			AND re.category_id NOT IN ( 67 ) 
 		ORDER BY
-		update_time DESC`
+			re.sort DESC`
 	_, err = o.Raw(sql, ChartPermissionId).QueryRows(&items)
 	return
 }