123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package controllers
- import (
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/services"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- )
- 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
- }
- var condition string
- condition = " AND is_show_yanx = 1 "
- list, err := models.GetCygxArticleTypeListCondition(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxArticleTypeListResp)
- for _, v := range list {
- item := models.CygxArticleTypeResp{
- ArticleTypeId: v.ArticleTypeId,
- ArticleTypeName: v.ArticleTypeName,
- ButtonStyle: v.ButtonStyle,
- }
- resp.List = append(resp.List, &item)
- }
- 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 pars []interface{}
- condition = ` AND publish_status = 1 `
- if articleTypeIds == "" {
- var conditiontype string
- conditiontype = " AND is_show_yanx = 1 "
- listType, err := models.GetCygxArticleTypeListCondition(conditiontype)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- 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)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
- return
- }
- list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list, err = services.HandleArticleCategoryImg(list)
- 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,
- }
- resp.List = append(resp.List, &item)
- }
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|