1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230 |
- 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 ReportController struct {
- BaseAuthController
- }
- type ReportCommonController struct {
- BaseCommonController
- }
- type MobileReportController struct {
- BaseAuthMobileController
- }
- // @Title 行业报告分类列表接口
- // @Description 获取行业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Success 200 {object} models.TradeReportMappingResp
- // @router /tradeList [get]
- func (this *MobileReportController) TradeList() {
- 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
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- if ChartPermissionId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- //var result []*models.SearchItem
- var list []*models.TradeReportMapping
- var err error
- mapCategory := make(map[int]int)
- if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
- listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
- err = errTrade
- if ChartPermissionId == utils.CE_LUE_ID {
- cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
- item := new(models.TradeReportMapping)
- item.CategoryId = utils.TIME_LINE_ID
- item.MatchTypeName = utils.TIME_LINE_NAME
- list = append(list, item)
- }
- }
- for _, v := range listTrade {
- list = append(list, v)
- }
- if user.Mobile != "" {
- //策略的处理
- categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- for _, v := range categoryList {
- mapCategory[v.IdCygx] = v.IdCygx
- }
- }
- } else {
- listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- categoryMap := make(map[int]int)
- for _, v := range listCategory {
- if categoryMap[v.CategoryId] > 0 {
- continue
- }
- categoryMap[v.CategoryId] = v.CategoryId
- list = append(list, v)
- }
- //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
- //if ChartPermissionId == utils.KE_JI_ID {
- // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
- //}
- }
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
- var pageSize int
- var listArticle []*models.HomeArticle
- pageSize = 3
- if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
- //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
- listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
- } else {
- listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
- }
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "GetHomeList,Err:" + err.Error()
- return
- }
- if len(listArticle) > 0 {
- list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
- }
- list[k].ListArticle = listArticle
- } else {
- if mapCategory[v.CategoryId] > 0 {
- list[k].IsFollow = true
- }
- list[k].ListArticle = make([]*models.HomeArticle, 0)
- }
- }
- resp := new(models.TradeReportMappingResp)
- if len(list) == 0 {
- list = make([]*models.TradeReportMapping, 0)
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业报告分类列表接口
- // @Description 获取产业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
- // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /industryList [get]
- func (this *MobileReportController) IndustryList() {
- 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
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- orderColumn := this.GetString("OrderColumn")
- orderColumnNew := this.GetString("OrderColumn")
- isNewLabel := this.GetString("IsNewLabel")
- isDeepLabel := this.GetString("IsDeepLabel")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- deepCover, _ := this.GetInt("DeepCover")
- recommendFocus, _ := this.GetInt("RecommendFocus")
- isBillboard, _ := this.GetBool("IsBillboard", false)
- var orderSrt string
- var condition string
- var startSize int
- resp := new(models.IndustrialManagementList)
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- if ChartPermissionId > 0 {
- condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
- }
- // 获取近一个月产业报告阅读次数最多的产业
- var topCond string
- var topPars []interface{}
- topReadIndustryId := 0
- if ChartPermissionId > 0 {
- topCond += ` AND chart_permission_id = ?`
- topPars = append(topPars, ChartPermissionId)
- }
- topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
- return
- }
- if topReadIndustry != nil {
- topReadIndustryId = topReadIndustry.IndustrialManagementId
- }
- // 深度覆盖
- if deepCover == 1 {
- // 查询深标签产业报告数
- var deepCondition string
- var deepPars []interface{}
- deepCondition += ` AND man.is_deep_label = 1`
- if ChartPermissionId > 0 {
- deepCondition += ` AND man.chart_permission_id = ?`
- deepPars = append(deepPars, ChartPermissionId)
- }
- industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
- return
- }
- deepIdArr := make([]string, 0)
- for i := range industryCountList {
- if industryCountList[i].ArtNum > 10 {
- deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
- }
- }
- deepIds := strings.Join(deepIdArr, ",")
- if deepIds != "" {
- condition = `AND man.industrial_management_id IN (` + deepIds + `)`
- }
- }
- // 推荐关注
- if recommendFocus == 1 {
- condition += ` AND man.recommended_index >= 80`
- }
- var list []*models.IndustrialManagement
- total, err := models.GetIndustrialManagementAllCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取数量失败,Err:" + err.Error()
- return
- }
- if orderColumn == "" {
- orderColumn = "NewTime"
- }
- if orderColumn == "NewTime" {
- orderSrt = "update_time DESC"
- } else {
- orderSrt = "man.recommended_index DESC,update_time DESC"
- }
- if isBillboard {
- // 查询有已归类行业报告的行业IDs
- activeIndustryIds, e := models.GetActiveArticleIndustryIds()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
- return
- }
- activeIndustryLen := len(activeIndustryIds)
- //topNum := pageSize
- condition = ""
- var parsBd []interface{}
- if ChartPermissionId > 0 {
- condition += ` AND man.chart_permission_id = ? `
- parsBd = append(parsBd, ChartPermissionId)
- }
- if activeIndustryLen > 0 {
- condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
- parsBd = append(parsBd, activeIndustryIds)
- }
- //nowTime := time.Now().Local()
- //startTime := nowTime.AddDate(0, -1, 0)
- //endTime := nowTime.AddDate(0, 0, -1)
- //condition += ` AND idf.create_time BETWEEN ? AND ?`
- //parsBd = append(parsBd, startTime, endTime)
- list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
- return
- }
- } else {
- list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- }
- var resource string
- if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- resource = utils.REOURCE_YX
- } else {
- resource = utils.REOURCE_HZ
- }
- list, err = services.HandleIndustryList(list, user, resource)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- industrialIdArr := make([]int, 0)
- for k, v := range list {
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
- list[k].IsHot = true
- }
- }
- if orderColumnNew != "" {
- item := new(models.CygxReportIndustrialSeaarchHistory)
- item.UserId = user.UserId
- item.Mobile = user.Mobile
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.CreateTime = time.Now()
- item.IsDeepLabel = isDeepLabel
- item.IsNewLabel = isNewLabel
- item.ChartPermissionId = ChartPermissionId
- if orderColumnNew == "NewTime" {
- item.OrderColumn = "0"
- } else {
- item.OrderColumn = "1"
- }
- go models.AddCygxReportIndustrialSeaarchHistory(item)
- }
- if len(list) == 0 {
- list = make([]*models.IndustrialManagement, 0)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- if isBillboard {
- total = len(list)
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业下所关联的文章分类列表
- // @Description 产业下所关联的文章分类列表接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.IndustrialToArticleCategoryListRep
- // @router /toArticleCategoryList [get]
- func (this *MobileReportController) ArticleCategoryList() {
- 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
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- if industrialManagementId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var list []*models.IndustrialToArticleCategoryRep
- categoryMap := make(map[int]int)
- for _, v := range listCategory {
- if categoryMap[v.CategoryId] > 0 {
- continue
- }
- categoryMap[v.CategoryId] = v.CategoryId
- list = append(list, v)
- }
- //标的列表
- industrialSubjectList, err := models.GetIndustrialArticleGroupSubjectListByHz(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- timeLineItem := models.IndustrialToArticleCategoryRep{
- CategoryId: utils.TIME_CATEGORYID,
- MatchTypeName: "时间线",
- }
- timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- timeLineItem.IsRed = timeLineIsRed
- list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
- resp := new(models.IndustrialToArticleCategoryListRep)
- resp.List = list
- resp.ListSubject = industrialSubjectList
- resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
- resp.IndustryName = detail.IndustryName
- resp.IndustrialManagementId = industrialManagementId
- if videoSimple != nil && videoSimple.Id > 0 {
- resp.IndustryVideo = videoSimple
- }
- resp.AuthInfo = au
- 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 CategoryId query int true "分类ID"
- // @Param IndustrialManagementId query int false "产业ID"
- // @Success 200 {object} models.TacticsListResp
- // @router /articleList/byCategoryId [get]
- func (this *MobileReportController) List() {
- 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
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- categoryId, _ := this.GetInt("CategoryId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- uid := user.UserId
- 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.TacticsListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- list := make([]*models.ArticleListResp, 0)
- if categoryId == utils.TIME_CATEGORYID {
- var err error
- list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
- return
- }
- } else {
- //获取该产业下所对应的行业图片
- //var reportType int
- //if industrialManagementId > 0 {
- // reportType = 2
- //} else {
- // reportType = 1
- //}
- //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
- //if errCategory != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
- // return
- //}
- //对应行业的图片
- detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
- mapChartPermission := make(map[string]string)
- var permissionName string
- var imgUrlChartPermission string
- for _, v := range chartPermissionUrlList {
- vslice := strings.Split(v, "_")
- permissionName = vslice[0]
- imgUrlChartPermission = vslice[len(vslice)-1]
- mapChartPermission[permissionName] = imgUrlChartPermission
- }
- //对应分类的所图片
- 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 categoryIdStr string
- var imgUrlChart string
- for _, v := range categoryUrlList {
- vslice := strings.Split(v, "_")
- categoryIdStr = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapCategoryUrl[categoryIdStr] = imgUrlChart
- }
- list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- articleIdMap, err := services.GetUserArticleHistoryRecord(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
- list[k].IsRed = true
- }
- }
- }
- listPublic, err := services.HandleArticleCategoryImg(list, user)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
- return
- }
- var articleIds []int
- for _, v := range listPublic {
- if v.Resource == 1 {
- articleIds = append(articleIds, v.ArticleId)
- }
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
- articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
- listResp := make([]*models.HomeArticle, 0)
- //listResp :=
- for _, v := range listPublic {
- listResp = append(listResp, &models.HomeArticle{
- ArticleId: v.ArticleId,
- Title: v.Title,
- Annotation: "核心观点:" + v.Annotation,
- Abstract: v.Abstract,
- ImgUrlPc: v.ImgUrlPc,
- PublishDate: v.PublishDate,
- Resource: v.Resource,
- Pv: articleMapPv[v.ArticleId],
- IsCollect: articleCollectMap[v.ArticleId],
- CollectNum: articleCollectNumMap[v.ArticleId],
- })
- }
- //lenList := len(list)
- //for i := 0; i < lenList; i++ {
- // item := list[i]
- // list[i].Body = ""
- // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
- // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
- // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
- // //行业比较研究、资金流向,显示报告的摘要
- // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
- // list[i].Annotation = list[i].Abstract
- // }
- //}
- if len(listResp) == 0 {
- listResp = make([]*models.HomeArticle, 0)
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.List = listResp
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业关注/取消关注
- // @Description 产业关注/取消关注 接口
- // @Param request body models.CygxIndustryFllowRep true "type json string"
- // @Success 200
- // @router /industrial/fllow [post]
- func (this *ReportController) IndustrialFllow() {
- 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.CygxIndustryFllowRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- industrialManagementId := req.IndustrialManagementId
- var condition string
- countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countIndustrial == 0 {
- br.Msg = "产业不存在!"
- br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
- return
- }
- count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxIndustryFllowResp)
- item := new(models.CygxIndustryFllow)
- item.IndustrialManagementId = industrialManagementId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.RealName = user.RealName
- item.Source = utils.REGISTER_PLATFORM
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- if count == 0 {
- item.Type = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = models.AddCygxIndustryFllow(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.Status = 1
- br.Msg = "关注成功"
- } else {
- item.Type = 2
- err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- resp.Status = 2
- br.Msg = "已取消关注"
- }
- //处理是否关注全部赛道字段
- go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
- go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
- go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 行业关注/取消关注
- // @Description 行业关注/取消关注 接口
- // @Param request body models.CygxCategoryFllowRep true "type json string"
- // @Success 200
- // @router /category/fllow [post]
- func (this *ReportController) CategoryFllow() {
- 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.CygxCategoryFllowRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- categoryId := req.CategoryId
- var condition string
- //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.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- 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(mapReport[categoryId], user.Mobile, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxIndustryFllowResp)
- if count == 0 {
- item := new(models.CygxXzsChooseCategory)
- item.CategoryId = mapReport[categoryId]
- item.IdCygx = 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
- br.Msg = "关注成功"
- } else {
- err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- resp.Status = 2
- br.Msg = "已取消关注"
- }
- go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 报告搜索
- // @Description 报告搜索接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param KeyWord query string true "搜索关键词"
- // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
- // @Param IsAll query bool true "是否为综合 "
- // @Success 200 {object} models.ReoprtSearchResp
- // @router /searchReport [get]
- func (this *MobileReportController) SearchReport() {
- 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")
- articleType, _ := this.GetInt("ArticleType", 1)
- keyWord := this.GetString("KeyWord")
- isAll, _ := this.GetBool("IsAll")
- var condition string
- var conditionYxSpecial string
- var pars []interface{}
- //var conditionSql string
- var total int
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if isAll {
- pageSize = utils.PageSize5
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- resp := new(models.ReoprtSearchResp)
- //匹配报告标题、
- articleTypeIds, err := services.GetYanXuanArticleTypeIds()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
- return
- }
- if articleTypeIds == "" {
- br.Msg = "获取信息失败"
- br.ErrMsg = "研选分类ID不能为空"
- return
- }
- //处理对应的文章类型标签按钮
- nameMap, styleMap, err := services.GetArticleTypeMap()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
- return
- }
- if isAll {
- total = utils.PageSize5
- conditionHz := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
- conditionYx := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
- listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId, true)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- listHz, err = services.HandleArticleCategoryImg(listHz, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
- return
- }
- listYx, err = services.HandleArticleCategoryImg(listYx, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
- return
- }
- for _, v := range listHz {
- 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.ListHz = append(resp.ListHz, &item)
- }
- for _, v := range listYx {
- 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.ListYx = append(resp.ListYx, &item)
- }
- } else {
- if keyWord != "" {
- if articleType == 1 {
- condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
- total, err = models.GetReoprtSearchCountHz(condition)
- } else {
- condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
- total, err = models.GetReoprtSearchCountYx(condition)
- }
- conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
- }
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取总数失败,Err:" + err.Error()
- return
- }
- var list []*models.ArticleListResp
- //list := new([]models.ArticleResearchResp)
- if articleType == 1 {
- list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
- } else {
- total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
- }
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- //return
- list, err = services.HandleArticleCategoryImg(list, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
- return
- }
- 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 v.IsSpecial == 1 {
- //去除图片标签
- item.Annotation = utils.ArticleRemoveImgUrl(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 articleType == 1 {
- resp.ListHz = append(resp.ListHz, &item)
- } else {
- resp.ListYx = append(resp.ListYx, &item)
- }
- }
- }
- if keyWord != "" {
- //go services.AddUserSearchLog(user, keyWord, 5)
- }
- if len(resp.ListHz) == 0 {
- resp.ListHz = make([]*models.ArticleResearchResp, 0)
- }
- if len(resp.ListYx) == 0 {
- resp.ListYx = make([]*models.ArticleResearchResp, 0)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 资源包搜索
- // @Description 资源包搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.SearchResourceResp
- // @router /searchResource [get]
- func (this *MobileReportController) SearchResource() {
- 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
- fllowList, err := models.GetUserFllowIndustrialList(uid)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- keyWord := this.GetString("KeyWord")
- var condition 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.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
- listHz, err := models.GetSearchResourceList(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
- listYx, err := models.GetSearchResourceList(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if len(listYx) > 0 {
- listYx, err = services.HandleIndustryList(listYx, user, "Yx")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- }
- if len(listHz) > 0 {
- listHz, err = services.HandleIndustryList(listHz, user, "Hz")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- }
- if keyWord != "" {
- //go services.AddUserSearchLog(user, keyWord, 4)
- }
- resp := new(models.SearchResourceResp)
- if len(listHz) == 0 {
- listHz = make([]*models.IndustrialManagement, 0)
- }
- if len(listYx) == 0 {
- listYx = make([]*models.IndustrialManagement, 0)
- }
- resp.ListHz = listHz
- resp.ListYx = listYx
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告搜索、资源包搜索接口
- // @Description 报告搜索、资源包搜索接口接口
- // @Param KeyWord query string true "搜索关键词"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param SearchType query int true "1:综合,2:全部"
- // @Success 200 {object} models.SearchReportAndResourceResp
- // @router /searchReportAndResource [get]
- func (this *MobileReportController) SearchReportAndResource() {
- 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
- keyWord := this.GetString("KeyWord")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- searchType, _ := this.GetInt("SearchType")
- var total int
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- page := paging.GetPaging(currentIndex, pageSize, total)
- var condition string
- var conditionSql string
- //匹配报告标题、
- condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
- conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
- total, err := models.GetReoprtSearchCount(conditionSql)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取总数失败,Err:" + err.Error()
- return
- }
- if searchType == 1 {
- pageSize = utils.PageSize5
- }
- ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
- return
- }
- if len(ListHzReport) == 0 {
- ListHzReport = make([]*models.ArticleCollectionResp, 0)
- }
- var conditionOr string
- conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
- listHzResource, err := services.GetSearchResourceListHz(condition, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.SearchReportAndResourceResp)
- if len(listHzResource) == 0 {
- listHzResource = make([]*models.IndustrialManagement, 0)
- }
- if keyWord != "" {
- //go services.AddUserSearchLog(user, keyWord, 5)
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.Paging = page
- resp.ListHzResource = listHzResource
- resp.ListHzReport = ListHzReport
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 公司速览
- // @Description 公司速览接口
- // @Param ChartPermissionId query int false "分类ID"
- // @Success 200 {object} models.ArticleDataLogoListResp
- // @router /companyList [get]
- func (this *ReportCommonController) CompanyList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var condition string
- var pars []interface{}
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- if chartPermissionId > 1 {
- categoryId, err := models.GetCategoryId(chartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
- return
- }
- if categoryId != "" {
- condition += ` AND a.category_id IN (` + categoryId + `)`
- }
- }
- condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
- list, err := models.CygxArticleDataList(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
- return
- }
- listLogo := make([]*models.ArticleDataLogoResp, 0)
- for i := range list {
- v := list[i]
- comapnyList := services.HandleArticleStock(v.Stock)
- if len(comapnyList) > 1 {
- for kC, vC := range comapnyList {
- sliceCovers := strings.Split(v.Cover, "{|}")
- cover := v.Cover
- if len(sliceCovers) == len(comapnyList) {
- cover = sliceCovers[kC]
- }
- listLogo = append(listLogo, &models.ArticleDataLogoResp{
- ArticleId: v.ArticleId,
- Cover: cover,
- ComapnyList: services.HandleArticleStock(vC.ComapnyName),
- })
- }
- } else {
- listLogo = append(listLogo, &models.ArticleDataLogoResp{
- ArticleId: v.ArticleId,
- Cover: v.Cover,
- ComapnyList: services.HandleArticleStock(v.Stock),
- })
- }
- }
- resp := new(models.ArticleDataLogoListResp)
- resp.List = listLogo
- 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 IndustrialManagementId query int false "产业ID"
- // @Success 200 {object} models.TacticsListResp
- // @router /timeline [get]
- func (this *MobileReportController) Timeline() {
- 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")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var total int
- resp := new(models.TacticsListTimeResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- list := make([]*models.TimeLineReportItem, 0)
- var err error
- list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
- return
- }
- //处理晨会精华关联的标的,以及要跳转的文章ID
- var meetingreviewchaptIds []int
- var articleIds []int
- mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
- mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
- mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
- for _, v := range list {
- if v.Resource == 3 {
- meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
- }
- if v.Resource == 1 {
- articleIds = append(articleIds, v.ArticleId)
- }
- }
- if len(meetingreviewchaptIds) > 0 {
- listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
- }
- for _, v := range listMeet {
- mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
- mapchaptIdListSubject[v.Id] = v.ListSubject
- }
- }
- if len(articleIds) > 0 {
- mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
- }
- //查询用户今天是否看过时间线
- //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
- //if err != nil {
- // br.Msg = "查询浏览记录数量失败"
- // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
- // return
- //}
- //var recordItem *models.CygxPageHistoryRecord
- //if count > 1 {
- // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
- // if err != nil {
- // br.Msg = "查询浏览记录失败"
- // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
- // return
- // }
- //}
- for k, v := range list {
- if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
- list[k].IsRed = true
- }
- //timeLineRed := false
- //if count < 2 && v.SubCategoryName == "时间线" {
- // timeLineRed = true
- //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
- // timeLineRed = true
- //}
- //if v.SubCategoryName == "时间线" && timeLineRed {
- list[k].IsRed = true
- //}
- if v.VideoUrl != "" {
- list[k].IsHaveVideo = true
- }
- v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- if v.Resource == 3 {
- v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
- v.ListSubject = mapchaptIdListSubject[v.Id]
- }
- if v.Resource == 1 {
- v.ListSubject = mapArticleIdListSubject[v.Id]
- }
- }
- //添加我的日程访问记录
- item := new(models.CygxPageHistoryRecord)
- item.UserId = user.UserId
- item.CreateTime = time.Now()
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
- go models.AddCygxPageHistoryRecord(item)
- if len(list) == 0 {
- list = make([]*models.TimeLineReportItem, 0)
- }
- go services.AddCygxTimelineLog(user, industrialManagementId)
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 文章留言接口
- // @Description 文章留言接口
- // @Param request body models.AddCygxActivityHelpAsk true "type json string"
- // @Success 200 {object} models.TacticsListResp
- // @router /commentAdd [post]
- func (this *ReportController) CommentAdd() {
- 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 req models.AddCygxArticleCommentReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ArticleId <= 0 {
- br.Msg = "文章不存在"
- br.ErrMsg = "文章不存在,文章ID错误"
- return
- }
- if req.Content == "" {
- br.Msg = "建议内容不可为空"
- return
- }
- content := req.Content
- if content == "" {
- br.Msg = "留言内容不能为空!"
- return
- }
- //itemToken, err := services.WxGetToken()
- //if err != nil {
- // br.Msg = "GetWxAccessToken Err:" + err.Error()
- // return
- //}
- //if itemToken.AccessToken == "" {
- // br.Msg = "accessToken is empty"
- // return
- //}
- //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
- //if err != nil {
- // br.Msg = "内容校验失败!"
- // br.ErrMsg = "内容校验失败,Err:" + err.Error()
- // return
- //}
- //if commerr.ErrCode != 0 {
- // br.Msg = "内容违规,请重新提交!"
- // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
- // return
- //}
- articleId := req.ArticleId
- articleInfo, errInfo := models.GetArticleDetailById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
- if err != nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail == nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
- return
- }
- item := models.CygxArticleComment{
- UserId: user.UserId,
- ArticleId: req.ArticleId,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: companyDetail.CompanyName,
- Content: content,
- Title: articleInfo.Title,
- }
- msgId, err := models.AddArticleComment(&item)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交留言失败,Err:" + err.Error()
- return
- }
- go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
- go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
- br.Ret = 200
- br.Success = true
- br.Msg = "提交成功"
- }
- // @Title 报告精选、本周研究汇总、上周纪要汇总列表
- // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
- // @Success 200 {object} models.CygxReportSelectionListPublicRep
- // @router /reportList/byType [get]
- func (this *ReportController) ReportListByType() {
- 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
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- reportType := this.GetString("ReportType")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.CygxReportSelectionListPublicRep)
- page := paging.GetPaging(currentIndex, pageSize, total)
- var tbdb string
- var readSql string
- var reportTypeStr string
- if reportType == "1" {
- tbdb = "cygx_report_selection"
- reportTypeStr = "bgjx"
- } else if reportType == "2" {
- tbdb = "cygx_research_summary"
- reportTypeStr = "bzyjhz"
- } else if reportType == "3" {
- tbdb = "cygx_minutes_summary"
- reportTypeStr = "szjyhz"
- } else {
- br.Msg = "请选择报告类型"
- return
- }
- condition = ` AND publish_status = 1 `
- if user.CompanyId != utils.HZ_COMPANY_ID {
- condition += ` AND visible_range = 1 `
- }
- total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- //研究汇总--报告精选 只显示最新一期,往期都隐藏
- if reportType == "1" {
- startSize = 0
- pageSize = 1
- total = 1
- }
- readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if reportType == "1" {
- list[k].Abstract = v.UpdateDescription
- }
- list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
- if v.ReadNum == 0 {
- list[k].IsRed = true
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取本周研究汇总详情
- // @Description 获取本周研究汇总详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ResearchSummaryLetailResp
- // @router /researchSummary/detail [get]
- func (this *ReportController) ResearchDetail() {
- 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
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ResearchSummaryLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- detail, err := models.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- PermissionNameMap, err := services.GetPermissionNameMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- PermissionIcoMap, err := services.GetPermissionNameIcoMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- //未设置全部可见的只能给弘则内部查看
- if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
- resp.IsShow = true
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 || !resp.IsShow {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetResearchSummarylogListFirst(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- listArticleType, err := models.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
- v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
- listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for _, vType := range listArticleType {
- if v2.ChartPermissionId == vType.YanxPermissionId {
- listSecond[k2].IcoLink = vType.IcoLinkM
- listSecond[k2].PermissionName = vType.YanxPermissionName
- }
- }
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "SDBG" {
- listFirst[k].ListName = "深度报告"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
- } else if v.Type == "BZCHJH" {
- listFirst[k].ListName = "本周晨会精华"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
- } else if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "SJDP" {
- listFirst[k].ListName = "市场QA汇总"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "买方研选"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
- go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总内容详情
- // @Description 获取上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.MinutesSummaryLetailResp
- // @router /minutesSummary/detail [get]
- func (this *ReportController) MinutesDetail() {
- 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
- }
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.MinutesSummaryLetailRespV4)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- PermissionNameMap, err := services.GetPermissionNameMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- PermissionIcoMap, err := services.GetPermissionNameIcoMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- //未设置全部可见的只能给弘则内部查看
- if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
- resp.IsShow = true
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 || !resp.IsShow {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
- v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
- listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "买方研选纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
- go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 记录用户浏览音频回放接口
- // @Description 记录用户浏览音频回放接口
- // @Param request body models.ArticleIdReq true "type json string"
- // @Success Ret=200 操作成功
- // @router /voiceHistory/add [post]
- func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
- 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
- }
- uid := user.UserId
- var req models.ArticleIdReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- playSeconds := req.PlaySeconds
- reportType := req.ReportType
- //本周研究汇总
- if reportType == 2 {
- articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxResearchSummaryVoiceHistory{
- ArticleId: articleId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- RegisterPlatform: utils.REGISTER_PLATFORM,
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxResearchSummaryVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateResearchSummaryVoiceCounts(articleId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- }
- } else if reportType == 3 {
- articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxMinutesSummaryVoiceHistory{
- ArticleId: articleId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- RegisterPlatform: utils.REGISTER_PLATFORM,
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxMinutesSummaryVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateMinutesSummaryVoiceCounts(articleId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 根据行业分类获取行业文章列表
- // @Description 根据行业分类获取行业文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param CategoryId query int true "分类ID"
- // @Param IndustrialManagementId query int false "产业ID"
- // @Success 200 {object} models.TacticsListResp
- // @router /tactics/list [get]
- func (this *MobileReportController) TacticsList() {
- 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
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- categoryId, _ := this.GetInt("CategoryId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- 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
- var err error
- resp := new(models.TacticsListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- list := make([]*models.ArticleListResp, 0)
- if categoryId == utils.TIME_CATEGORYID {
- list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
- return
- }
- } else {
- if categoryId == utils.ACTEGORY_ID_AI_QY {
- listArticle := make([]*models.HomeArticle, 0)
- listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
- return
- }
- for _, v := range listArticle {
- list = append(list, &models.ArticleListResp{
- ArticleId: v.ArticleId,
- Title: v.Title,
- CategoryId: v.CategoryId,
- Annotation: v.Annotation,
- Abstract: v.Abstract,
- Body: v.Body,
- PublishDate: v.PublishDate,
- Resource: 1,
- })
- }
- } else {
- list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "GetHomeList,Err:" + err.Error()
- return
- }
- }
- articleIdMap, err := services.GetUserArticleHistoryRecord(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
- list[k].IsRed = true
- }
- }
- if categoryId > 0 {
- detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
- if errCategory != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
- return
- }
- resp.MatchTypeName = detail.MatchTypeName
- }
- //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
- }
- listPublic, err := services.HandleArticleCategoryImg(list, user)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
- return
- }
- var articleIds []int
- var productInteriorIs []int
- for _, v := range listPublic {
- if v.Resource == 1 {
- articleIds = append(articleIds, v.ArticleId)
- }
- if v.Resource == 2 {
- productInteriorIs = append(productInteriorIs, v.ArticleId)
- }
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
- articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
- productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
- listResp := make([]*models.HomeArticle, 0)
- for _, v := range listPublic {
- item := new(models.HomeArticle)
- item.ArticleId = v.ArticleId
- item.ReportId = v.ReportId
- item.Title = v.Title
- item.Annotation = v.Annotation
- item.Abstract = v.Abstract
- item.ImgUrlPc = v.ImgUrlPc
- item.PublishDate = v.PublishDate
- item.Resource = v.Resource
- if v.Resource == 1 {
- item.Pv = articleMapPv[v.ArticleId]
- item.IsCollect = articleCollectMap[v.ArticleId]
- item.CollectNum = articleCollectNumMap[v.ArticleId]
- }
- if v.Resource == 2 {
- item.Pv = productInteriorMapPv[v.ArticleId]
- }
- if v.ReportId > 0 {
- item.Resource = 3
- }
- listResp = append(listResp, item)
- }
- if len(listResp) == 0 {
- listResp = make([]*models.HomeArticle, 0)
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.List = listResp
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|