123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "html"
- "strconv"
- "strings"
- )
- type HomeController struct {
- BaseAuthController
- }
- type BaseHomeController struct {
- BaseCommonController
- }
- // @Title 首页列表接口
- // @Description 首页列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ChartPermissionId query int true "品类id,最新传0"
- // @Success 200 {object} models.HomeListResp
- // @router /list [get]
- func (this *HomeController) ListHome() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- 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{}
- var total int
- resp := new(models.HomeListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.HaveResearch = true
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- condition += ` AND is_summary = 1 `
- if chartPermissionId > 0 {
- categoryId, err := models.GetCategoryId(chartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
- return
- }
- categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 && categoryinfo.PermissionName == "研选" {
- resp.HaveResearch = false
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- //if categoryId != "" {
- // condition += ` AND category_id IN(` + categoryId + `)`
- // condition += ` OR ( category_name LIKE '%研选%' AND publish_status = 1 AND is_summary = 1 )`
- //} else {
- // condition += ` AND category_name LIKE '%研选%' `
- //}
- if categoryId != "" {
- condition += ` AND category_id IN(` + categoryId + `)`
- //condition += ` OR ( category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%' AND publish_status = 1 AND is_summary = 1 )`
- } else {
- condition += ` AND category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
- }
- }
- //永续客户无法查看研选分类的内容
- if userType == 1 {
- condition += ` AND category_name NOT LIKE '%研选` + `%'`
- }
- total, err = models.GetHomeCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetHomeList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- //研选的五张图片
- detailResearch, err := models.GetConfigByCode("category_research_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据研选分类图片失败,Err:" + err.Error()
- return
- }
- researchList := strings.Split(detailResearch.ConfigValue, "{|}")
- //对应分类的所图片
- detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
- mapCategoryUrl := make(map[string]string)
- var categoryId string
- var imgUrlChart string
- for _, v := range categoryUrlList {
- vslice := strings.Split(v, "_")
- categoryId = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapCategoryUrl[categoryId] = imgUrlChart
- }
- var articleIds []int
- for _, v := range list {
- articleIds = append(articleIds, v.ArticleId)
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
- fmt.Println(articleMapPv)
- for k, v := range list {
- list[k].Pv = articleMapPv[v.ArticleId]
- item := list[k]
- //如果文章一开始的内容是图片,优先展示第一张图片
- imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
- newBody, _ := services.GetReportContentTextSub(item.Body)
- list[k].Body = newBody
- if imgurl != "" {
- list[k].BodyHtml = imgurl
- }
- list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
- if strings.Contains(item.CategoryName, "研选") {
- list[k].IsResearch = true
- }
- if item.Pv > 999 {
- list[k].Pv = 999
- }
- //如果是研选系列的任意取五张图片的中的一张
- if v.CategoryId == "0" {
- knum := v.ArticleId % 5
- list[k].ImgUrlPc = researchList[knum]
- } else {
- list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- }
- if list[k].ArticleId < utils.SummaryArticleId {
- list[k].HttpUrl = utils.StrategyPlatform + strconv.Itoa(v.ArticleId)
- list[k].IsNeedJump = true
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 首页列表接口(无需token)
- // @Description 首页列表接口(无需token)
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ChartPermissionId query int true "品类id,最新传0"
- // @Param CompanyCode query string false "机构编号"
- // @Param CompanyName query string false "机构名称"
- // @Param Email query string false "邮箱"
- // @Param Sign query string false "加密签名"
- // @Success 200 {object} models.HomeListResp
- // @router /listPublic [get]
- func (this *BaseHomeController) ListHomePublic() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- companyCode := this.GetString("CompanyCode")
- companyName := this.GetString("CompanyName")
- email := this.GetString("Email")
- sign := this.GetString("Sign")
- var userType int
- var err error
- if companyCode != "" && companyName != "" && email != "" {
- errMsg, errHt, wxUser, _ := services.CheckHtgj(companyCode, companyName, email, sign)
- if errHt != nil {
- br.Msg = "获取"
- br.ErrMsg = "获取数据失败,Err:" + errHt.Error()
- return
- }
- if errMsg == "机构下账号个数已达上限" {
- goto Loop
- }
- if errMsg != "" {
- br.Msg = errMsg
- return
- }
- user := wxUser
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- userType, _, err = services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- }
- Loop:
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- 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{}
- var total int
- resp := new(models.HomeListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.HaveResearch = true
- condition += ` AND is_summary = 1 `
- if chartPermissionId > 0 {
- categoryId, err := models.GetCategoryId(chartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
- return
- }
- categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 && strings.Contains(categoryinfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.HaveResearch = false
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- if categoryId != "" {
- condition += ` AND category_id IN(` + categoryId + `)`
- //condition += ` OR ( category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%' AND publish_status = 1 AND is_summary = 1 )`
- } else {
- condition += ` AND category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
- }
- }
- //永续客户无法查看研选分类的内容
- if userType == 1 {
- condition += ` AND category_name NOT LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
- }
- total, err = models.GetHomeCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetHomeList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- list, err = services.HandleArticleCategoryImg(list)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "图片预处理失败,HandleArticleCategoryImg,Err:" + err.Error()
- return
- }
- for _, v := range list {
- v.Annotation, _ = services.GetReportContentTextSub(v.Annotation)
- v.Body = v.Annotation
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 首页/搜索头部导航接口
- // @Description 首页/搜索头部导航接口
- // @Param SearchPage query int false "是否为搜索页面"
- // @Success 200 {object} models.HomeListResp
- // @router /header_tab [get]
- func (this *HomeController) HeaderTab() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- searchPage, _ := this.GetInt("SearchPage")
- key := models.HomeHeaderTabConfigKey
- 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.HomeHeaderTabList)
- if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
- return
- }
- resp := list.Home
- if searchPage == 1 {
- resp = list.SearchPage
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 首页列表接口v7.6版本
- // @Description 首页列表接口v7.6版本
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ChartPermissionId query int true "品类id,最新传0"
- // @Param CtagId query int true "图表子类ID"
- // @Param ListType query int true "列表类型,1最新,2 纪要 ,3图表 默认1"
- // @Success 200 {object} models.HomeArtAndChartListResp
- // @router /artAndChart/list [get]
- func (this *HomeController) ListHomeArtAndChart() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- ctagId, _ := this.GetInt("CtagId")
- listType, _ := this.GetInt("ListType")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- if listType <= 0 {
- listType = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- var total, chartTotal int
- resp := new(models.HomeArtAndChartListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.HaveResearch = true
- var chartList []*models.HomeChartListResp
- var err error
- // 最新
- if listType == 1 {
- if currentIndex <= 2 {
- listCtagId := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
- var chartIds string
- for _, v := range listCtagId {
- chartListTwo, err := models.GetChartList(`AND ctag_id = `+strconv.Itoa(v), pars, 0, 2)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- for _, vChart := range chartListTwo {
- chartIds += strconv.Itoa(vChart.ChartId) + ","
- }
- }
- chartIds = strings.TrimRight(chartIds, ",")
- condition += ` AND chart_id IN (` + chartIds + `) `
- chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- }
- }
- // 图表
- if listType == 3 {
- if chartPermissionId > 0 {
- condition += ` AND a.ptag_id =? `
- pars = append(pars, chartPermissionId)
- }
- if ctagId > 0 {
- condition += ` AND a.ctag_id =? `
- pars = append(pars, ctagId)
- }
- chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- chartTotal, err = models.GetChartCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- }
- for k, v := range chartList {
- if v.PtagName != "" {
- chartList[k].CtagNamePc = v.PtagName
- }
- if v.CtagName != "" {
- chartList[k].CtagNamePc += "," + v.CtagName
- }
- if v.PtagNameTwo != "" {
- chartList[k].CtagNamePc += "," + v.PtagNameTwo
- }
- if v.CtagNameTwo != "" {
- chartList[k].CtagNamePc += "," + v.CtagNameTwo
- }
- chartList[k].IsNeedJump = true
- chartList[k].Source = 2
- }
- resp.ChartList = chartList
- // 最新/纪要
- if listType != 3 {
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- condition = ` AND is_summary = 1 `
- if chartPermissionId > 0 {
- categoryId, err := models.GetCategoryId(chartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
- return
- }
- categoryInfo, err := models.GetChartPermissionById(chartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 && strings.Contains(categoryInfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.HaveResearch = false
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- if categoryId != "" {
- condition += ` AND category_id IN(` + categoryId + `)`
- //condition += ` OR ( category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%' AND publish_status = 1 AND is_summary = 1 )`
- } else {
- condition += ` AND category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
- }
- }
- //永续客户无法查看研选分类的内容
- if userType == 1 {
- condition += ` AND category_name NOT LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
- }
- list := make([]*models.HomeArticle, 0)
- // 7.6-与音频作联合查询, 整体进行发布时间的排序(代码写的嘎嘎烂, 将就着用吧=_=!)
- if listType == 1 {
- var unionPars []interface{}
- unionList, unionTotal, e := services.GetHomeNewestList(user.UserId, user.CompanyId, startSize, pageSize, condition, unionPars)
- if e != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取纪要音频联合列表失败, Err: " + e.Error()
- return
- }
- total = unionTotal
- list = unionList
- } else {
- total, err = models.GetHomeCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- homeList, err := models.GetHomeList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- list = homeList
- }
- resp.List, err = services.HandleArticleCategoryImg(list)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "处理封面图片失败,HandleArticleCategoryImg,Err:" + err.Error()
- return
- }
- resp.List = list
- }
- if chartTotal > total {
- total = chartTotal
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 首页列表接口
- // @Description 首页列表接口
- // @Param TagIds query string true "标签选择"
- // @Param ChartPermissionId query int false "行业id"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.HomeArtAndChartListResp
- // @router /new [get]
- func (this *HomeController) NewList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- tagIds := this.GetString("TagIds")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var conditionInit string
- var pars []interface{}
- //var total int
- resp := new(models.HomeResourceDataListResp)
- //totalRai, err := models.GetCountCompanyProductCompanyId(user.CompanyId, utils.COMPANY_PRODUCT_RAI_ID)
- //if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取失败"
- // br.ErrMsg = "GetCountCompanyProductCompanyId,Err:" + err.Error()
- // return
- //}
- if tagIds != "" {
- conditionTagIdsInit, err := services.GetConditionInitByTagIds(tagIds, chartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
- return
- }
- conditionInit += conditionTagIdsInit
- }
- //行业筛选
- if chartPermissionId > 0 {
- conditionInit += " AND chart_permission_id = " + strconv.Itoa(chartPermissionId)
- condition += " AND chart_permission_id = " + strconv.Itoa(chartPermissionId)
- }
- //if tagIds == "" && chartPermissionId == 0 {
- // //查询近一个月的数据
- // conditionInit += " AND publish_date > '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
- //}
- //conditionInit += ` AND source IN ('newchart')`
- //if user.CompanyId <= 1 || totalRai == 0 {
- // //condition += " AND source IN ('roadshow','article') "
- // condition += " AND source NOT IN ('activityspecial','industrialsourceHz','industrialsourceYx') "
- // listActivityYiDong, err := models.GetActivityListHomeNew(" AND art.yidong_activity_id != '' ", 0, 1000)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取可见活动数据失败,Err:" + err.Error()
- // return
- // }
- // //易董的活动不查看 v12.2.1
- // var yiDongactivityIds []int
- // for _, v := range listActivityYiDong {
- // yiDongactivityIds = append(yiDongactivityIds, v.ActivityId)
- // }
- // lenyiDongactivityIds := len(yiDongactivityIds)
- // condition += ` AND IF ( source = 'activity' , source_id NOT IN (` + utils.GetOrmInReplace(lenyiDongactivityIds) + `) ,1=1 ) `
- // pars = append(pars, yiDongactivityIds)
- //} else {
- condition += ` AND is_hide = 0 AND source NOT IN ('activity','activityspecial','newchart','industrialsourceHz','industrialsourceYx') AND IF ( source IN('activityvoice','activityvideo') , chart_permission_id != 31 ,1=1 ) ` + conditionInit
- //conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "1,2,3", "", 0, 0, "", 0, 1)
- conditionActivity, err := services.ActivityConditioninitSql(user, " AND art.active_state IN (1,2) ", 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- conditionActivity += ` AND art.publish_status = 1 `
- var conditionOrder string
- conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
- conditionActivity += conditionOrder
- actPageSize := 200
- if tagIds != "" {
- actPageSize = 2000
- }
- listActivity, err := models.GetActivityListHomeNew(conditionActivity, 0, actPageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取可见活动数据失败,Err:" + err.Error()
- return
- }
- var activityIds []int
- for _, v := range listActivity {
- activityIds = append(activityIds, v.ActivityId)
- }
- lenActivityIds := len(activityIds)
- listActivitySpecial, _, err := services.GetActivitySpecialList(user, 1, 200, "")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取专项调研可见权限失败失败,Err:" + err.Error()
- return
- }
- var activityspecialIds []int
- for _, v := range listActivitySpecial {
- activityspecialIds = append(activityspecialIds, v.ActivityId)
- }
- lenActivityspecialIds := len(activityspecialIds)
- if lenActivityIds > 0 {
- condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` ) `
- pars = append(pars, activityIds)
- }
- if lenActivityspecialIds > 0 {
- condition += ` OR ( source = 'activityspecial' AND source_id IN (` + utils.GetOrmInReplace(lenActivityspecialIds) + `) ` + conditionInit + ` ) `
- pars = append(pars, activityspecialIds)
- //}
- }
- total, err := models.GetResourceDataCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
- list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var permissionName string
- if chartPermissionId > 0 {
- chartPermissioninfo, err := models.GetChartPermissionById(chartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- }
- permissionName = chartPermissioninfo.PermissionName
- }
- if currentIndex == 1 && len(list) > 0 && permissionName == utils.ZHOU_QI_NAME && tagIds == "" { // 如果是第一页信息,选择了周期行业,同时没有选择别的筛选条件就 在第三个拼接 FICC研报的跳转信息
- for k, v := range list {
- resp.List = append(resp.List, v)
- if k == 1 {
- resp.List = append(resp.List, services.GetFiccReportXcxItem(user))
- }
- }
- } else {
- resp.List = list
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|