package controllers import ( "encoding/json" "github.com/rdlucklib/rdluck_tools/paging" "hongze/hongze_clpt/models" "hongze/hongze_clpt/services" "hongze/hongze_clpt/utils" "strconv" "strings" "time" ) type MobileResearchController struct { BaseAuthMobileController } // @Title 研选文章类型列表 // @Description 研选文章类型列表接口 // @Success 200 {object} models.CygxArticleTypeListResp // @router /article/typeList [get] func (this *MobileResearchController) ArticleType() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } key := utils.YAN_XUAN_TAB_KEY conf, e := models.GetConfigByCode(key) if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error() return } if conf.ConfigValue == "" { br.Msg = "获取失败" br.ErrMsg = "首页头部导航配置值有误" return } list := new(models.CygxArticleTypeListResp) if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil { br.Msg = "获取失败" br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error() return } resp := new(models.CygxArticleTypeListResp) resp = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 研选最新报告列表 // @Description 研选最新报告列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Param ArticleTypeIds query array true "文章类型ID多个用 , 隔开" // @Success 200 {object} models.IndustrialManagementNewList // @router /article/newList [get] func (this *MobileResearchController) ArticleNewList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") articleTypeIds := this.GetString("ArticleTypeIds") var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = paging.StartIndex(currentIndex, pageSize) var condition string var conditiontype string var pars []interface{} condition = ` AND publish_status = 1 ` if articleTypeIds == "" || strings.Contains(articleTypeIds, "999") { conditiontype = " AND is_show_yanx = 1 " } else { conditiontype = ` AND group_id IN (` + articleTypeIds + `) ` } listType, err := models.GetCygxArticleTypeListCondition(conditiontype) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } needYanxuanSpecial := true if articleTypeIds != "" && !strings.Contains(articleTypeIds, "999") { needYanxuanSpecial = false } //只勾选了研选专栏时去掉文章的统计 if articleTypeIds == "999" { condition += ` AND 1<0 ` } articleTypeIds = "" for _, v := range listType { articleTypeIds += strconv.Itoa(v.ArticleTypeId) + "," } articleTypeIds = strings.TrimRight(articleTypeIds, ",") condition += ` AND a.article_type_id IN (` + articleTypeIds + `) ` total, err := models.GetArticleResearchCount(condition, pars, needYanxuanSpecial) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error() return } list, err := models.GetArticleResearchListYx(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } list, err = services.HandleArticleCategoryImg(list, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error() return } //处理对应的文章类型标签按钮 nameMap, styleMap, err := services.GetArticleTypeMap() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } page := paging.GetPaging(currentIndex, pageSize, total) resp := new(models.ArticleResearchListResp) for _, v := range list { item := models.ArticleResearchResp{ ArticleId: v.ArticleId, ArticleTypeId: v.ArticleTypeId, Title: v.Title, PublishDate: v.PublishDate, DepartmentId: v.DepartmentId, NickName: v.NickName, IsCollect: v.IsCollect, Pv: v.Pv, CollectNum: v.CollectNum, Abstract: v.Abstract, Annotation: v.Annotation, ImgUrlPc: v.ImgUrlPc, ArticleTypeName: nameMap[v.ArticleTypeId], ButtonStyle: styleMap[v.ArticleTypeId], List: v.List, SpecialColumnId: v.SpecialColumnId, TopTime: v.TopTime, } if v.IsSpecial == 1 { //去除图片标签 item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation) item.Annotation, err = utils.ExtractText(item.Annotation) item.IsSpecial = true item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC if v.CompanyTags != "" { item.CompanyTags = strings.Split(v.CompanyTags, ",") } else { item.CompanyTags = []string{} } if v.IndustryTags != "" { item.IndustryTags = strings.Split(v.IndustryTags, ",") } else { item.IndustryTags = []string{} } item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL if v.SpecialType == 1 { item.Title = "【笔记】" + item.Title } else if v.SpecialType == 2 { item.Title = "【观点】" + item.Title } if v.MyCollectNum > 0 { item.IsCollect = true } } if item.ArticleTypeName == "纪要" || item.ArticleTypeName == "沙龙" || item.ArticleTypeName == "专家访谈" { item.Annotation = "核心结论:" + item.Annotation } else if !item.IsSpecial { item.Annotation = "核心观点:" + item.Annotation } resp.List = append(resp.List, &item) } resp.Paging = page br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title KOL榜列表 // @Description KOL榜列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Param ThemeType query int true "主题类型,1关注度、2更新时间 " // @Success 200 {object} models.DepartmentListResp // @router /kolList [get] func (this *MobileResearchController) KolList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } themeType, _ := this.GetInt("ThemeType") pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") var startSize int if pageSize <= 0 { pageSize = utils.PageSize15 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) total, err := models.GetDepartmentlistCount("") if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } var condition string var conditionOrder string if themeType == 2 { conditionOrder = `ORDER BY publish_date DESC ` } else { conditionOrder = `ORDER BY sum_num DESC ` } list, err := models.GetDepartmentList(condition, conditionOrder, user.UserId, startSize, pageSize) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } listIndustrial, err := models.GetIndustrialDepartmentList() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } mapHot := make(map[int]bool) //if themeType == 2 { conditionHot := `ORDER BY sum_num DESC ` listhot, err := models.GetDepartmentList(condition, conditionHot, user.UserId, 0, 3) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } for _, v := range listhot { mapHot[v.DepartmentId] = true } //} departmentMap := make(map[string]string) for k, v := range list { if v.FllowNum > 0 { list[k].IsFollow = true } list[k].IsHot = mapHot[v.DepartmentId] list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 for _, v2 := range listIndustrial { if v2.DepartmentId == v.DepartmentId { if departmentMap["D"+strconv.Itoa(v2.DepartmentId)+"In"+strconv.Itoa(v2.IndustrialManagementId)] == "" && len(list[k].List) < 4 { list[k].List = append(list[k].List, v2) departmentMap["D"+strconv.Itoa(v2.DepartmentId)+"In"+strconv.Itoa(v2.IndustrialManagementId)] = v.NickName } } } } resp := new(models.DepartmentListResp) page := paging.GetPaging(currentIndex, pageSize, total) resp.Paging = page resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 主题热度/近期更新更多,列表 // @Description 主题热度/近期更新更多,列表接口 // @Param ThemeType query int true "主题类型,1主题热度、2近期更新 默认1" // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Success 200 {object} models.IndustrialManagementHotListResp // @router /hotList [get] func (this *MobileResearchController) HotList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } themeType, _ := this.GetInt("ThemeType") pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") var startSize int if pageSize <= 0 { pageSize = utils.PageSize15 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) var condition string var conditionOrder string articleTypeIds, err := services.GetYanXuanArticleTypeIds() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error() return } if articleTypeIds == "" { br.Msg = "获取信息失败" br.ErrMsg = "研选分类ID不能为空" return } condition = ` AND a.article_type_id IN (` + articleTypeIds + `) ` if themeType == 2 { conditionOrder = `ORDER BY publish_date DESC ` } else { conditionOrder = `ORDER BY sum_num DESC ` } total, err := models.GetThemeHeatListCount(condition) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } list, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, startSize, pageSize) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } listSubjcet, err := models.GetThemeHeatSubjectList(condition) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取标的信息失败,Err:" + err.Error() return } mapHot := make(map[int]bool) mapNew, err := services.GetYanXuanIndustrialManagementIdNewMap(articleTypeIds) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error() return } //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] list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 if v.FllowNum > 0 { list[k].IsFollow = true } for _, v2 := range listSubjcet { if v2.IndustrialManagementId == v.IndustrialManagementId { list[k].IndustrialSubjectList = append(list[k].IndustrialSubjectList, v2) } } } page := paging.GetPaging(currentIndex, pageSize, total) resp := new(models.IndustrialManagementHotListResp) resp.Paging = page resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 主题详情 // @Description 主题详情接口 // @Param IndustrialManagementId query int true "分类ID" // @Success 200 {object} models.GetThemeDetailResp // @router /theme/detail [get] func (this *MobileResearchController) ThemeDetail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } industrialManagementId, _ := this.GetInt("IndustrialManagementId") if industrialManagementId < 1 { br.Msg = "请输入产业ID" return } detailIndustrial, err := models.GetIndustrialManagementDetail(industrialManagementId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } var condition string articleTypeIds, err := services.GetYanXuanArticleTypeIds() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error() return } if articleTypeIds != "" { condition = ` AND a.article_type_id IN (` + articleTypeIds + `) ` } else { br.Msg = "获取信息失败" br.ErrMsg = "研选分类ID不能为空" return } resp := new(models.GetThemeDetailResp) list, err := models.GetThemeDetail(user.UserId, industrialManagementId, condition) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } list, err = services.HandleArticleCategoryImg(list, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error() return } //处理对应的文章类型标签按钮 nameMap, styleMap, err := services.GetArticleTypeMap() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } var articleIds []int for _, v := range list { item := models.ArticleResearchResp{ ArticleId: v.ArticleId, ArticleTypeId: v.ArticleTypeId, Title: v.Title, PublishDate: v.PublishDate, DepartmentId: v.DepartmentId, NickName: v.NickName, IsCollect: v.IsCollect, Pv: v.Pv, CollectNum: v.CollectNum, Abstract: v.Abstract, Annotation: v.Annotation, ImgUrlPc: v.ImgUrlPc, ArticleTypeName: nameMap[v.ArticleTypeId], ButtonStyle: styleMap[v.ArticleTypeId], List: v.List, } if item.ArticleTypeName == "纪要" || item.ArticleTypeName == "沙龙" || item.ArticleTypeName == "专家访谈" { item.Annotation = "核心结论:" + item.Annotation } else { item.Annotation = "核心观点:" + item.Annotation } resp.List = append(resp.List, &item) articleIds = append(articleIds, v.ArticleId) } //处理用户数是否关注该产业 userFollowIndustrialMap, err := services.GetUserFollowIndustrialMap(user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } if _, ok := userFollowIndustrialMap[industrialManagementId]; ok { resp.IsFollow = true } listSub, err := models.GetcygxIndustrialSubject(industrialManagementId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } //处理文章关联的标的 articleGroupSubjectMap, subjectMap, err := services.GetArticleGroupSubjectMap(articleIds) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } if len(articleGroupSubjectMap) > 0 { for k, v := range resp.List { resp.List[k].ListSubject = articleGroupSubjectMap[v.ArticleId] } } for _, v := range listSub { itemSubJect := new(models.IndustrialSubject) itemSubJect.SubjectName = v.SubjectName itemSubJect.IndustrialSubjectId = v.IndustrialSubjectId if subjectMap[v.IndustrialSubjectId] != "" { resp.ListSubject = append(resp.ListSubject, itemSubJect) } } resp.IndustryName = detailIndustrial.IndustryName resp.IndustrialManagementId = detailIndustrial.IndustrialManagementId br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 研选作者详情 // @Description 研选作者详情接口 // @Param DepartmentId query int true "作者ID" // @Success 200 {object} models.DepartmentDetailResp // @router /departmentId/detail [get] func (this *MobileResearchController) DepartmentIdDetail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = paging.StartIndex(currentIndex, pageSize) departmentId, _ := this.GetInt("DepartmentId") if departmentId < 1 { br.Msg = "请输入作者ID" return } var condition string var pars []interface{} articleTypeIds, err := services.GetYanXuanArticleTypeIds() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error() return } needYanxuanSpecial := true if articleTypeIds != "" && !strings.Contains(articleTypeIds, "999") { needYanxuanSpecial = false } //只勾选了研选专栏时去掉文章的统计 if articleTypeIds == "999" { condition += ` AND 1<0 ` } if articleTypeIds != "" { condition = ` AND a.article_type_id IN (` + articleTypeIds + `) ` } else { br.Msg = "获取信息失败" br.ErrMsg = "研选分类ID不能为空" return } resp := new(models.DepartmentDetailResp) detail, err := models.GetDepartmentDetail(user.UserId, departmentId, condition) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取作者信息失败,Err:" + err.Error() return } resp.DepartmentId = detail.DepartmentId resp.NickName = detail.NickName resp.ImgUrl = detail.ImgUrl resp.FllowNum = detail.FllowNum resp.ArticleNum = detail.ArticleNum resp.CollectNum = detail.CollectNum if detail.MyFllowNum > 0 { resp.IsFollow = true } condition += ` AND a.department_id = ` + strconv.Itoa(departmentId) total, err := models.GetArticleResearchCount(condition, pars, needYanxuanSpecial) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error() return } list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } list, err = services.HandleArticleCategoryImg(list, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error() return } //处理对应的文章类型标签按钮 nameMap, styleMap, err := services.GetArticleTypeMap() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } //resp := new(models.ArticleResearchListResp) for _, v := range list { item := models.ArticleResearchResp{ ArticleId: v.ArticleId, ArticleTypeId: v.ArticleTypeId, Title: v.Title, PublishDate: v.PublishDate, DepartmentId: v.DepartmentId, NickName: v.NickName, IsCollect: v.IsCollect, Pv: v.Pv, CollectNum: v.CollectNum, Abstract: v.Abstract, Annotation: v.Annotation, ImgUrlPc: v.ImgUrlPc, ArticleTypeName: nameMap[v.ArticleTypeId], ButtonStyle: styleMap[v.ArticleTypeId], List: v.List, } if item.ArticleTypeName == "纪要" || item.ArticleTypeName == "沙龙" || item.ArticleTypeName == "专家访谈" { item.Annotation = "核心结论:" + item.Annotation } else { item.Annotation = "核心观点:" + item.Annotation } resp.List = append(resp.List, &item) } condition = ` AND a.department_id = ` + strconv.Itoa(departmentId) listIndustrial, err := models.GetIndustrialManagementNewList(condition) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取品种信息失败,Err:" + err.Error() return } page := paging.GetPaging(currentIndex, pageSize, total) resp.ListIndustrial = listIndustrial resp.Paging = page br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 关注作者/取消关注作者 // @Description 关注作者/取消关注作者 接口 // @Param request body models.CygxArticleDepartmentId true "type json string" // @Success 200 // @router /fllowDepartment [post] func (this *MobileResearchController) FllowDepartment() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } uid := user.UserId var req models.CygxArticleDepartmentId err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } departmentId := req.DepartmentId var condition string countDepartment, err := models.GetDepartmentCount(departmentId) if err != nil { br.Msg = "获取数据失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } if countDepartment == 0 { br.Msg = "作者不存在!" br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId) return } countUser, err := models.GetArticleDepartmentFollowByUid(uid) count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition) if err != nil { br.Msg = "获取数据失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } resp := new(models.CygxArticleDepartmentFollowResp) if countUser == 0 { resp.GoFollow = true } if count == 0 { item := new(models.CygxArticleDepartmentFollow) item.DepartmentId = departmentId item.UserId = uid item.Email = user.Email item.Mobile = user.Mobile item.RealName = user.RealName item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.Type = 1 item.CreateTime = time.Now() item.ModifyTime = time.Now() _, err = models.AddArticleDepartmentFollow(item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } resp.Status = 1 } else { var doType int condition = ` AND type = 1` count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition) if err != nil { br.Msg = "操作失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } if count == 1 { resp.Status = 2 doType = 2 } else { resp.Status = 1 doType = 1 } err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType) if err != nil { br.Msg = "操作失败" br.ErrMsg = "取消关注失败,Err:" + err.Error() return } } br.Msg = "操作成功" br.Ret = 200 br.Success = true br.Data = resp } // @Title 研选月度收藏榜 // @Description 研选月度收藏榜接口 // @Param PageSize query int true "每页数据条数" // @Success 200 {object} models.ReportBillboardListResp // @router /article/billboard [get] func (this *MobileResearchController) Billboard() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请重新登录" br.Ret = 408 return } pageSize, _ := this.GetInt("PageSize", 15) var condition string var pars []interface{} articleTypeIds, err := services.GetYanXuanArticleTypeIds() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error() return } if articleTypeIds != "" { condition = ` AND a.article_type_id IN (` + articleTypeIds + `) ` } else { br.Msg = "获取信息失败" br.ErrMsg = "研选分类ID不能为空" return } // 根据关注时间一个月前至昨日的增量数据排序 nowTime := time.Now().Local() startTime := nowTime.AddDate(0, -1, 0) endTime := nowTime.AddDate(0, 0, -1) condition += ` AND ac.create_time BETWEEN ? AND ?` pars = append(pars, startTime, endTime) list, err := models.GetReportCollectionBillboardListYx(pageSize, pars, condition) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + err.Error() return } list, err = services.HandleArticleCategoryImg(list, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error() return } //处理对应的文章类型标签按钮 nameMap, styleMap, err := services.GetArticleTypeMap() if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetArticleTypeMap Err:" + err.Error() return } resp := new(models.ArticleResearchListResp) for _, v := range list { item := models.ArticleResearchResp{ ArticleId: v.ArticleId, ArticleTypeId: v.ArticleTypeId, Title: v.Title, PublishDate: v.PublishDate, DepartmentId: v.DepartmentId, NickName: v.NickName, IsCollect: v.IsCollect, Pv: v.Pv, CollectNum: v.CollectNum, Abstract: v.Abstract, Annotation: v.Annotation, ImgUrlPc: v.ImgUrlPc, ArticleTypeName: nameMap[v.ArticleTypeId], ButtonStyle: styleMap[v.ArticleTypeId], List: v.List, } resp.List = append(resp.List, &item) } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp }