瀏覽代碼

Merge branch 'cygx4.2_web' of http://8.136.199.33:3000/cxzhang/hongze_clpt into debug

xingzai 1 年之前
父節點
當前提交
3d9a92be76
共有 3 個文件被更改,包括 61 次插入15 次删除
  1. 26 9
      controllers/report.go
  2. 4 1
      controllers/report_selection.go
  3. 31 5
      models/xzs_choose_category.go

+ 26 - 9
controllers/report.go

@@ -83,7 +83,7 @@ func (this *MobileReportController) TradeList() {
 				return
 			}
 			for _, v := range categoryList {
-				mapCategory[v.CategoryId] = v.CategoryId
+				mapCategory[v.IdCygx] = v.IdCygx
 			}
 		}
 		//for k, v := range list {
@@ -833,18 +833,34 @@ func (this *ReportController) CategoryFllow() {
 	}
 	categoryId := req.CategoryId
 	var condition string
-	countCategory, err := models.GetCategoryCount(categoryId)
+	//countCategory, err := models.GetCategoryCount(categoryId)
+	//if err != nil {
+	//	br.Msg = "获取数据失败!"
+	//	br.ErrMsg = "获取数据失败,Err:" + err.Error()
+	//	return
+	//}
+	//if countCategory == 0 {
+	//	br.Msg = "产业不存在!"
+	//	br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
+	//	return
+	//}
+	listMap, err := models.GetCygxXzsChooseCategoryMapList()
 	if err != nil {
-		br.Msg = "获取数据失败!"
+		br.Msg = "操作失败!"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
-	if countCategory == 0 {
-		br.Msg = "产业不存在!"
-		br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
+	mapReport := make(map[int]int)
+	for _, v := range listMap {
+		mapReport[v.Id] = v.CategoryId
+	}
+	if mapReport[categoryId] == 0 {
+		br.Msg = "操作失败!"
+		br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
 		return
 	}
-	count, err := models.GetCountCategoryFllow(categoryId, user.Mobile, condition)
+
+	count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
 	if err != nil {
 		br.Msg = "获取数据失败!"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -853,7 +869,8 @@ func (this *ReportController) CategoryFllow() {
 	resp := new(models.CygxIndustryFllowResp)
 	if count == 0 {
 		item := new(models.CygxXzsChooseCategory)
-		item.CategoryId = categoryId
+		item.CategoryId = mapReport[categoryId]
+		item.IdCygx = categoryId
 		item.UserId = uid
 		item.Email = user.Email
 		item.Mobile = user.Mobile
@@ -871,7 +888,7 @@ func (this *ReportController) CategoryFllow() {
 		resp.Status = 1
 		br.Msg = "关注成功"
 	} else {
-		err = models.RemoveCygxCategoryFllow(user.Mobile, categoryId)
+		err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
 		if err != nil {
 			br.Msg = "操作失败"
 			br.ErrMsg = "取消关注失败,Err:" + err.Error()

+ 4 - 1
controllers/report_selection.go

@@ -134,7 +134,10 @@ func (this *ReportSelectionController) Detail() {
 					listSonLog[k2].OverviewArticleId = articleStockMap[v2.SubjectName]
 					listSonLog[k2].List = listIndustrial
 					if v2.Label != "" {
-						v2.CompanyLabel = strings.Split(v2.Label, "{|}")
+						CompanyLabelSlice := strings.Split(v2.Label, "{|}")
+						for _, vCompanyLabel := range CompanyLabelSlice {
+							v2.CompanyLabel = append(v2.CompanyLabel, vCompanyLabel+"#")
+						}
 					}
 				}
 				itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: v2.IsNew, IndustrialSubjectId: v2.IndustrialSubjectId})

+ 31 - 5
models/xzs_choose_category.go

@@ -16,9 +16,10 @@ type CygxXzsChooseCategory struct {
 	CategoryId  int       `description:"权益文章对应分类,cygx_article"`
 	CreateTime  time.Time `description:"创建时间"`
 	ModifyTime  time.Time `description:"更新时间"`
+	IdCygx      int       `description:"cygx_report_mapping_cygx 表主键ID"`
 }
 
-//根据手机号获取用户关注的产业
+// 根据手机号获取用户关注的产业
 func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_xzs_choose_category WHERE mobile = ?`
@@ -26,14 +27,14 @@ func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory
 	return
 }
 
-//添加
+// 添加
 func AddCygxCategoryFllow(item *CygxXzsChooseCategory) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//删除
+// 删除
 func RemoveCygxCategoryFllow(mobile string, CategoryId int) (err error) {
 	o := orm.NewOrm()
 	sql := `DELETE FROM cygx_xzs_choose_category WHERE mobile=? AND category_id=? `
@@ -41,7 +42,7 @@ func RemoveCygxCategoryFllow(mobile string, CategoryId int) (err error) {
 	return
 }
 
-//获取产业数量
+// 获取产业数量
 func GetCategoryCount(categoryId int) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_report_mapping WHERE category_id=? `
 	o := orm.NewOrm()
@@ -49,9 +50,34 @@ func GetCategoryCount(categoryId int) (count int, err error) {
 	return
 }
 
-//获取关注数量
+// 获取关注数量
 func GetCountCategoryFllow(categoryId int, mobile, condition string) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_xzs_choose_category WHERE mobile=? AND category_id=? ` + condition
 	err = orm.NewOrm().Raw(sql, mobile, categoryId).QueryRow(&count)
 	return
 }
+
+type XzsChooseMapResp struct {
+	Id                  int    `description:"id"`
+	CategoryId          int    `description:"权益文章对应分类,cygx_article"`
+	CharPpermissionName string `description:"权限名称"`
+	MatchTypeName       string `description:"分类名称"`
+}
+
+// 根据手机号获取用户关注的产业
+func GetCygxXzsChooseCategoryMapList() (items []*XzsChooseMapResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			r.id,
+			r.chart_permission_name,
+			r.match_type_name,
+			c.category_id 
+		FROM
+			cygx_report_mapping_cygx AS r
+			INNER JOIN cygx_report_mapping_group AS p ON p.id_cygx = r.id
+			INNER JOIN cygx_report_mapping_celue AS c ON c.category_id = p.category_id_celue 
+		WHERE
+			r.chart_permission_id IN (23,100000)`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}