xingzai 2 yıl önce
ebeveyn
işleme
d585dfb863
3 değiştirilmiş dosya ile 38 ekleme ve 32 silme
  1. 28 24
      controllers/research.go
  2. 3 3
      models/report.go
  3. 7 5
      services/yan_xuan.go

+ 28 - 24
controllers/research.go

@@ -198,25 +198,24 @@ func (this *ResearchController) HotList() {
 		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
 		return
 	}
-	mapHot := make(map[string]int)
+	mapHot := make(map[int]bool)
 	mapNew, err := services.GetYanXuanIndustrialManagementIdNewMap(articleTypeIds)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
 		return
 	}
-	conditionOrder = ` ORDER BY sum_num DESC `
-	listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-		return
-	}
-	for _, v := range listHot {
-		mapHot[v.IndustryName] = v.IndustrialManagementId
+	if themeType == 2 {
+		mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
+			return
+		}
 	}
 	for k, v := range list {
 		list[k].IsNew = mapNew[v.IndustrialManagementId]
+		list[k].IsHot = mapHot[v.IndustrialManagementId]
 		if v.FllowNum > 0 {
 			list[k].IsFollw = true
 		}
@@ -225,9 +224,6 @@ func (this *ResearchController) HotList() {
 				list[k].IndustrialSubjectList = append(list[k].IndustrialSubjectList, v2)
 			}
 		}
-		if mapHot[v.IndustryName] > 0 {
-			list[k].IsHot = true
-		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.IndustrialManagementHotListResp)
@@ -259,11 +255,6 @@ func (this *ResearchController) KolList() {
 		br.Ret = 408
 		return
 	}
-	//chartPermissionId, _ := this.GetInt("ChartPermissionId")
-	//if chartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
-	//}
 	themeType, _ := this.GetInt("ThemeType")
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -275,24 +266,37 @@ func (this *ResearchController) KolList() {
 		currentIndex = 1
 	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds == "" {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	var condition string
+	var conditionOrder string
+	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
 
-	total, err := models.GetDepartmentlistCount("")
+	total, err := models.GetDepartmentlistCount(condition)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
 
-	var condition string
 	if themeType == 2 {
-		condition = `ORDER BY publish_date DESC `
+		conditionOrder = `ORDER BY publish_date DESC `
 	} else {
-		condition = `ORDER BY fllow_num DESC `
+		conditionOrder = `ORDER BY fllow_num DESC `
 	}
 	mapHot := make(map[int]bool)
 	if themeType == 2 {
 		conditionHot := `ORDER BY fllow_num DESC `
-		listhot, err := models.GetDepartmentList(conditionHot, user.UserId, 0, 3)
+		listhot, err := models.GetDepartmentList(condition, conditionHot, user.UserId, 0, 3)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
@@ -303,7 +307,7 @@ func (this *ResearchController) KolList() {
 		}
 	}
 
-	list, err := models.GetDepartmentList(condition, user.UserId, startSize, pageSize)
+	list, err := models.GetDepartmentList(condition, conditionOrder, user.UserId, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()

+ 3 - 3
models/report.go

@@ -587,7 +587,7 @@ type IndustrialDepartmentListResp struct {
 }
 
 // 作者列表
-func GetDepartmentList(condition string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
+func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			d.nick_name,
@@ -602,9 +602,9 @@ func GetDepartmentList(condition string, userId, startSize, pageSize int) (items
 		WHERE
 			1 = 1
 			AND a.article_type_id > 0 
-			AND publish_status = 1 
+			AND publish_status = 1  ` + condition + `
 		GROUP BY
-				d.department_id ` + condition + ` LIMIT ?,?`
+				d.department_id ` + conditionOrder + ` LIMIT ?,?`
 	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 7 - 5
services/yan_xuan.go

@@ -46,21 +46,23 @@ func GetYanXuanIndustrialManagementIdNewMap(articleTypeIds string) (respMa map[i
 	return
 }
 
-// 处理研选关联的标签
+// 处理研选关联的hot标签
 func GetYanXuanIndustrialManagementIdHotMap(articleTypeIds string) (respMa map[int]bool, err error) {
 	var condition string
+	var conditionOrder string
 	if articleTypeIds == "" {
 		return
 	}
 	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
-	list, e := models.GetIndustrialManagementNewList(condition)
+	conditionOrder = ` ORDER BY sum_num DESC `
+	listHot, e := models.GetThemeHeatList(0, condition, conditionOrder, 0, 3)
 	if e != nil {
 		err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
 		return
 	}
-	newMap := make(map[int]bool)
-	for _, v := range list {
-		newMap[v.IndustrialManagementId] = true
+	newHot := make(map[int]bool)
+	for _, v := range listHot {
+		newHot[v.IndustrialManagementId] = true
 	}
 	return
 }