|
@@ -3,6 +3,7 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"strconv"
|
|
|
"time"
|
|
@@ -47,18 +48,63 @@ func (this *IndustryController) Fllow() {
|
|
|
var pars []interface{}
|
|
|
var industrialIds []int
|
|
|
if source == "article" {
|
|
|
- pars = make([]interface{}, 0)
|
|
|
- condition = ` AND article_id = ? `
|
|
|
- pars = append(pars, sourceId)
|
|
|
- industrialList, err := models.GetIndustrialArticleGroupManagementList(condition, pars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ articleDetail, err := models.GetArticleDetailById(sourceId)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if len(industrialList) > 0 {
|
|
|
- for _, v := range industrialList {
|
|
|
- industrialIds = append(industrialIds, v.IndustrialManagementId)
|
|
|
+ //判读是否属于策略的文章类型
|
|
|
+ reportMappingMap, _ := services.GetReportMappingMap()
|
|
|
+ if reportMappingMap[articleDetail.CategoryId] {
|
|
|
+ chooseCategoryMap, _ := services.GetChooseCategoryMap(user)
|
|
|
+ //判断用户是否关注策略对应分类
|
|
|
+ if !chooseCategoryMap[articleDetail.CategoryId] {
|
|
|
+ item := new(models.CygxXzsChooseCategory)
|
|
|
+ item.CategoryId = articleDetail.CategoryId
|
|
|
+ item.UserId = uid
|
|
|
+ item.Email = user.Email
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ _, err = models.AddCygxCategoryFllow(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.Status = 1
|
|
|
+ } else {
|
|
|
+ err = models.RemoveCygxCategoryFllow(user.Mobile, articleDetail.CategoryId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "取消关注失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.Status = 2
|
|
|
+ }
|
|
|
+ br.Msg = "操作成功"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND article_id = ? `
|
|
|
+ pars = append(pars, sourceId)
|
|
|
+ industrialList, err := models.GetIndustrialArticleGroupManagementList(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(industrialList) > 0 {
|
|
|
+ for _, v := range industrialList {
|
|
|
+ industrialIds = append(industrialIds, v.IndustrialManagementId)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if source == "activity" {
|