report.go 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/services"
  8. "hongze/hongze_cygx/utils"
  9. "html"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. //报告
  15. type ReportController struct {
  16. BaseAuthController
  17. }
  18. type ReportCommonController struct {
  19. BaseCommonController
  20. }
  21. // @Title 行业报告分类列表接口
  22. // @Description 获取行业报告分类列表接口
  23. // @Param ChartPermissionId query int true "分类ID"
  24. // @Success 200 {object} models.IndustrialManagementList
  25. // @router /home/tradeList [get]
  26. func (this *ReportController) TradeList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请重新登录"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  40. if ChartPermissionId < 1 {
  41. br.Msg = "请输入分类ID"
  42. return
  43. }
  44. list, err := models.GetTradeAll(ChartPermissionId)
  45. if err != nil {
  46. br.Msg = "获取信息失败"
  47. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  48. return
  49. }
  50. for k, v := range list {
  51. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  52. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  53. if err != nil {
  54. br.Msg = "获取信息失败"
  55. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  56. return
  57. }
  58. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  59. list[k].IsRed = true
  60. }
  61. }
  62. resp := new(models.TradeReportMappingResp)
  63. resp.List = list
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 产业报告分类列表接口
  70. // @Description 获取产业报告分类列表接口
  71. // @Param ChartPermissionId query int true "分类ID"
  72. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  73. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  74. // @Param KeyWord query string true "搜索关键词"
  75. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  76. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  77. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  78. // @Param PageSize query int true "每页数据条数"
  79. // @Param CurrentIndex query int true "当前页页码,从1开始"
  80. // @Success 200 {object} models.IndustrialManagementList
  81. // @router /home/industryList [get]
  82. func (this *ReportController) IndustryList() {
  83. br := new(models.BaseResponse).Init()
  84. defer func() {
  85. this.Data["json"] = br
  86. this.ServeJSON()
  87. }()
  88. user := this.User
  89. if user == nil {
  90. br.Msg = "请重新登录"
  91. br.Ret = 408
  92. return
  93. }
  94. uid := user.UserId
  95. fmt.Println(uid)
  96. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  97. orderColumn := this.GetString("OrderColumn")
  98. orderColumnNew := this.GetString("OrderColumn")
  99. isNewLabel := this.GetString("IsNewLabel")
  100. isDeepLabel := this.GetString("IsDeepLabel")
  101. keyWord := this.GetString("KeyWord")
  102. pageSize, _ := this.GetInt("PageSize")
  103. currentIndex, _ := this.GetInt("CurrentIndex")
  104. deepCover, _ := this.GetInt("DeepCover")
  105. recommendFocus, _ := this.GetInt("RecommendFocus")
  106. var orderSrt string
  107. var condition string
  108. var startSize int
  109. resp := new(models.IndustrialManagementList)
  110. if pageSize <= 0 {
  111. pageSize = utils.PageSize20
  112. }
  113. if currentIndex <= 0 {
  114. currentIndex = 1
  115. }
  116. startSize = paging.StartIndex(currentIndex, pageSize)
  117. if isNewLabel == "1" {
  118. condition += ` AND is_new_label = ` + isNewLabel
  119. }
  120. if isDeepLabel == "1" {
  121. condition += ` AND is_deep_label = ` + isDeepLabel
  122. }
  123. if keyWord != "" {
  124. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  125. //if err != nil {
  126. // br.Msg = "获取信息失败"
  127. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  128. // return
  129. //}
  130. //var conditionkeyWord string
  131. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  132. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  133. //keyWordLen := len(keyWordArr)
  134. //if keyWordLen <= 0 {
  135. // keyWordArr = append(keyWordArr, keyWord)
  136. // keyWordLen = len(keyWordArr)
  137. //}
  138. //for _, v := range keyWordArr {
  139. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  140. //}
  141. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  142. //if err != nil {
  143. // br.Msg = "获取信息失败"
  144. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  145. // return
  146. //}
  147. //if industrialManagementIds == "" {
  148. // br.Ret = 200
  149. // br.Success = true
  150. // br.Msg = "获取成功"
  151. // br.Data = resp
  152. // return
  153. //}
  154. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  155. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  156. }
  157. var sqlChartPermissionId string
  158. if ChartPermissionId > 0 {
  159. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  160. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  161. }
  162. // 深度覆盖
  163. if deepCover == 1 {
  164. // 查询深标签产业报告数
  165. var deepCondition string
  166. var deepPars []interface{}
  167. deepCondition += ` AND man.is_deep_label = 1`
  168. if ChartPermissionId > 0 {
  169. deepCondition += ` AND man.chart_permission_id = ?`
  170. deepPars = append(deepPars, ChartPermissionId)
  171. }
  172. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  173. if e != nil {
  174. br.Msg = "获取信息失败"
  175. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  176. return
  177. }
  178. deepIdArr := make([]string, 0)
  179. for i := range industryCountList {
  180. if industryCountList[i].ArtNum > 10 {
  181. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  182. }
  183. }
  184. deepIds := strings.Join(deepIdArr, ",")
  185. if deepIds != "" {
  186. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  187. }
  188. }
  189. // 推荐关注
  190. if recommendFocus == 1 {
  191. condition += ` AND man.recommended_index >= 80`
  192. }
  193. // 列表总数据量
  194. var list []*models.IndustrialManagement
  195. total, err := models.GetIndustrialManagementAllCount(condition)
  196. if err != nil {
  197. br.Msg = "获取信息失败"
  198. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  199. return
  200. }
  201. page := paging.GetPaging(currentIndex, pageSize, total)
  202. if orderColumn == "" {
  203. orderColumn = "NewTime"
  204. }
  205. if orderColumn == "NewTime" {
  206. orderSrt = "update_time DESC"
  207. } else {
  208. orderSrt = "man.recommended_index DESC,update_time DESC"
  209. }
  210. if ChartPermissionId == 0 {
  211. ChartPermissionId = 20
  212. }
  213. // 阅读第三的产业详情
  214. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  215. //if err != nil {
  216. // br.Msg = "获取信息失败"
  217. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  218. // return
  219. //}
  220. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  221. if err != nil {
  222. br.Msg = "获取信息失败"
  223. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  224. return
  225. }
  226. // 获取近一个月产业报告阅读次数最多的产业
  227. var topCond string
  228. var topPars []interface{}
  229. topReadIndustryId := 0
  230. if ChartPermissionId > 0 {
  231. topCond += ` AND chart_permission_id = ?`
  232. topPars = append(topPars, ChartPermissionId)
  233. }
  234. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  235. if e != nil && e.Error() != utils.ErrNoRow() {
  236. br.Msg = "获取信息失败"
  237. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  238. return
  239. }
  240. if topReadIndustry != nil {
  241. topReadIndustryId = topReadIndustry.IndustrialManagementId
  242. }
  243. //查询产业视频
  244. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  245. var industrialManagementIds []int
  246. for _, v := range list {
  247. if v.IndustrialManagementId > 0 {
  248. industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
  249. }
  250. }
  251. if len(industrialManagementIds) >0 {
  252. // 获取默认图配置
  253. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  254. if e != nil {
  255. br.Msg = "获取视频默认配置图失败"
  256. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  257. return
  258. }
  259. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialManagementIds)
  260. if err != nil {
  261. br.Msg = "产业视频列表失败"
  262. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  263. return
  264. }
  265. for _, v := range videoList {
  266. tmp := &models.MicroVideoSimpleInfo{
  267. Id: v.VideoId,
  268. Title: "5min逻辑【"+v.IndustryName+"】解析",
  269. ResourceUrl: v.VideoUrl,
  270. BackgroundImg: v.ImgUrl,
  271. PlaySeconds: v.VideoDuration,
  272. DetailImgUrl: v.DetailImgUrl,
  273. }
  274. if tmp.BackgroundImg == "" {
  275. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  276. }
  277. industrialVideoMap[v.IndustryId] = tmp
  278. }
  279. }
  280. nowTime := time.Now().Local()
  281. threeMonBefore := nowTime.AddDate(0, -3, 0)
  282. for k, v := range list {
  283. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  284. if err != nil {
  285. br.Msg = "获取信息失败"
  286. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  287. return
  288. }
  289. list[k].IndustrialSubjectList = industrialSubjectList
  290. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  291. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  292. if err != nil {
  293. br.Msg = "获取信息失败"
  294. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  295. return
  296. }
  297. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  298. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  299. if err != nil && err.Error() != utils.ErrNoRow() {
  300. br.Msg = "获取信息失败"
  301. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  302. return
  303. }
  304. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  305. list[k].IsRed = true
  306. }
  307. // 原:关联的报告阅读量大于等于阅读第三的产业,则标记热门
  308. //if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  309. // list[k].IsHot = true
  310. //}
  311. // 近一个月报告阅读次数最多的产业标记Hot
  312. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  313. list[k].IsHot = true
  314. }
  315. // 关联报告发布时间均在3个月内则标记New
  316. if v.MinReportTime != "" {
  317. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  318. if e != nil {
  319. br.Msg = "获取信息失败"
  320. br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
  321. return
  322. }
  323. if t.After(threeMonBefore) {
  324. list[k].IsNew = true
  325. }
  326. }
  327. //展示产业视频
  328. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  329. list[k].IndustryVideo = video
  330. }
  331. }
  332. //记录用户搜索的筛选条件
  333. if orderColumnNew != "" {
  334. item := new(models.CygxReportIndustrialSeaarchHistory)
  335. item.UserId = user.UserId
  336. item.Mobile = user.Mobile
  337. item.CompanyId = user.CompanyId
  338. item.CompanyName = user.CompanyName
  339. item.CreateTime = time.Now()
  340. item.IsDeepLabel = isDeepLabel
  341. item.IsNewLabel = isNewLabel
  342. item.ChartPermissionId = ChartPermissionId
  343. if orderColumnNew == "NewTime" {
  344. item.OrderColumn = "0"
  345. } else {
  346. item.OrderColumn = "1"
  347. }
  348. go models.AddCygxReportIndustrialSeaarchHistory(item)
  349. }
  350. resp.List = list
  351. resp.Paging = page
  352. br.Ret = 200
  353. br.Success = true
  354. br.Msg = "获取成功"
  355. br.Data = resp
  356. }
  357. // @Title 产业下所关联的文章分类列表
  358. // @Description 产业下所关联的文章分类列表接口
  359. // @Param IndustrialManagementId query int true "产业ID"
  360. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  361. // @router /toArticleCategoryList [get]
  362. func (this *ReportController) ArticleCategoryList() {
  363. br := new(models.BaseResponse).Init()
  364. defer func() {
  365. this.Data["json"] = br
  366. this.ServeJSON()
  367. }()
  368. user := this.User
  369. if user == nil {
  370. br.Msg = "请重新登录"
  371. br.Ret = 408
  372. return
  373. }
  374. uid := user.UserId
  375. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  376. if industrialManagementId < 1 {
  377. br.Msg = "请输入分类ID"
  378. return
  379. }
  380. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  381. if err != nil {
  382. br.Msg = "获取信息失败"
  383. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  384. return
  385. }
  386. list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  387. if err != nil {
  388. br.Msg = "获取信息失败"
  389. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  390. return
  391. }
  392. for k, v := range list {
  393. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  394. if err != nil && err.Error() != utils.ErrNoRow() {
  395. br.Msg = "获取信息失败"
  396. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  397. return
  398. }
  399. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  400. if err != nil {
  401. br.Msg = "获取信息失败"
  402. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  403. return
  404. }
  405. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  406. list[k].IsRed = true
  407. }
  408. }
  409. videoSimple := new(models.MicroVideoSimpleInfo)
  410. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  411. if err != nil {
  412. if err.Error() != utils.ErrNoRow() {
  413. br.Msg = "获取产业视频失败"
  414. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  415. return
  416. }
  417. }else{
  418. videoSimple.Id = video.VideoId
  419. videoSimple.Title = "5min逻辑【"+video.IndustryName+"】解析"
  420. videoSimple.BackgroundImg = video.ImgUrl
  421. videoSimple.DetailImgUrl = video.DetailImgUrl
  422. if videoSimple.BackgroundImg == "" {
  423. // 获取默认图配置
  424. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  425. if e != nil {
  426. br.Msg = "获取视频默认配置图失败"
  427. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  428. return
  429. }
  430. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  431. }
  432. videoSimple.PlaySeconds = video.VideoDuration
  433. videoSimple.ResourceUrl = video.VideoUrl
  434. }
  435. //时间线
  436. timeLineItem := models.IndustrialToArticleCategoryRep{
  437. CategoryId: 99999,
  438. MatchTypeName: "时间线",
  439. }
  440. list = append(list, &timeLineItem)
  441. resp := new(models.IndustrialToArticleCategoryListRep)
  442. resp.List = list
  443. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  444. resp.IndustryName = detail.IndustryName
  445. resp.IndustrialManagementId = industrialManagementId
  446. if videoSimple.Id > 0 {
  447. resp.IndustryVideo = videoSimple
  448. }
  449. br.Ret = 200
  450. br.Success = true
  451. br.Msg = "获取成功"
  452. br.Data = resp
  453. }
  454. // @Title 产业文章列表接口
  455. // @Description 获取产业文章列表接口
  456. // @Param PageSize query int true "每页数据条数"
  457. // @Param CurrentIndex query int true "当前页页码,从1开始"
  458. // @Param CategoryId query int true "分类ID"
  459. // @Param IndustrialManagementId query int true "产业ID"
  460. // @Success 200 {object} models.TacticsListResp
  461. // @router /industry/ArticleList [get]
  462. func (this *ReportController) List() {
  463. br := new(models.BaseResponse).Init()
  464. defer func() {
  465. this.Data["json"] = br
  466. this.ServeJSON()
  467. }()
  468. user := this.User
  469. if user == nil {
  470. br.Msg = "请重新登录"
  471. br.Ret = 408
  472. return
  473. }
  474. uid := user.UserId
  475. pageSize, _ := this.GetInt("PageSize")
  476. currentIndex, _ := this.GetInt("CurrentIndex")
  477. categoryId, _ := this.GetInt("CategoryId")
  478. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  479. var startSize int
  480. if pageSize <= 0 {
  481. pageSize = utils.PageSize20
  482. }
  483. if currentIndex <= 0 {
  484. currentIndex = 1
  485. }
  486. startSize = paging.StartIndex(currentIndex, pageSize)
  487. var pars []interface{}
  488. var total int
  489. page := paging.GetPaging(currentIndex, pageSize, total)
  490. if categoryId < 1 {
  491. br.Msg = "请输入分类ID"
  492. return
  493. }
  494. if industrialManagementId < 1 {
  495. br.Msg = "请输入产业ID"
  496. return
  497. }
  498. if categoryId != 99999 {
  499. resp := new(models.TacticsListResp)
  500. //获取该产业下所对应的行业图片
  501. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  502. if errCategory != nil {
  503. br.Msg = "获取信息失败"
  504. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  505. return
  506. }
  507. //对应行业的图片
  508. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  509. if err != nil {
  510. br.Msg = "获取数据失败"
  511. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  512. return
  513. }
  514. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  515. mapChartPermission := make(map[string]string)
  516. var permissionName string
  517. var imgUrlChartPermission string
  518. for _, v := range chartPermissionUrlList {
  519. vslice := strings.Split(v, "_")
  520. permissionName = vslice[0]
  521. imgUrlChartPermission = vslice[len(vslice)-1]
  522. mapChartPermission[permissionName] = imgUrlChartPermission
  523. }
  524. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  525. if err != nil {
  526. br.Msg = "获取信息失败"
  527. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  528. return
  529. }
  530. page = paging.GetPaging(currentIndex, pageSize, total)
  531. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  532. if err != nil {
  533. br.Msg = "获取信息失败"
  534. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  535. return
  536. }
  537. //对应分类的所图片
  538. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  539. if err != nil {
  540. br.Msg = "获取数据失败"
  541. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  542. return
  543. }
  544. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  545. mapCategoryUrl := make(map[string]string)
  546. var categoryIdStr string
  547. var imgUrlChart string
  548. for _, v := range categoryUrlList {
  549. vslice := strings.Split(v, "_")
  550. categoryIdStr = vslice[0]
  551. imgUrlChart = vslice[len(vslice)-1]
  552. mapCategoryUrl[categoryIdStr] = imgUrlChart
  553. }
  554. lenList := len(list)
  555. for i := 0; i < lenList; i++ {
  556. item := list[i]
  557. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  558. //list[i].Abstract = html.UnescapeString(item.Abstract)
  559. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  560. //list[i].Annotation = services.GetAnnotationTextSub(item.Annotation)
  561. }
  562. for k, v := range list {
  563. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  564. list[k].IsRed = true
  565. }
  566. if v.VideoUrl != "" {
  567. list[k].IsHaveVideo = true
  568. }
  569. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  570. if mapCategoryUrl[v.CategoryId] == "" {
  571. if detail.ChartPermissionId == utils.YI_YAO_ID {
  572. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  573. }
  574. }
  575. }
  576. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  577. resp.ChartPermissionId = detail.ChartPermissionId
  578. resp.List = list
  579. resp.Paging = page
  580. br.Ret = 200
  581. br.Success = true
  582. br.Msg = "获取成功"
  583. br.Data = resp
  584. } else {
  585. ////获取该产业下所对应的行业图片
  586. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  587. //if errCategory != nil {
  588. // br.Msg = "获取信息失败"
  589. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  590. // return
  591. //}
  592. ////对应行业的图片
  593. //detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  594. //if err != nil {
  595. // br.Msg = "获取数据失败"
  596. // br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  597. // return
  598. //}
  599. //chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  600. //mapChartPermission := make(map[string]string)
  601. //var permissionName string
  602. //var imgUrlChartPermission string
  603. //for _, v := range chartPermissionUrlList {
  604. // vslice := strings.Split(v, "_")
  605. // permissionName = vslice[0]
  606. // imgUrlChartPermission = vslice[len(vslice)-1]
  607. // mapChartPermission[permissionName] = imgUrlChartPermission
  608. //}
  609. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  610. if err != nil {
  611. br.Msg = "获取信息失败"
  612. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  613. return
  614. }
  615. page = paging.GetPaging(currentIndex, pageSize, total)
  616. list, err := models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  617. if err != nil {
  618. br.Msg = "获取信息失败"
  619. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  620. return
  621. }
  622. ////对应分类的所图片
  623. //detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  624. //if err != nil {
  625. // br.Msg = "获取数据失败"
  626. // br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  627. // return
  628. //}
  629. //categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  630. //mapCategoryUrl := make(map[string]string)
  631. //var categoryIdStr string
  632. //var imgUrlChart string
  633. //for _, v := range categoryUrlList {
  634. // vslice := strings.Split(v, "_")
  635. // categoryIdStr = vslice[0]
  636. // imgUrlChart = vslice[len(vslice)-1]
  637. // mapCategoryUrl[categoryIdStr] = imgUrlChart
  638. //}
  639. //lenList := len(list)
  640. //for i := 0; i < lenList; i++ {
  641. // item := list[i]
  642. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  643. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  644. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  645. //}
  646. //for k, v := range list {
  647. // if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  648. // list[k].IsRed = true
  649. // }
  650. // if v.VideoUrl != "" {
  651. // list[k].IsHaveVideo = true
  652. // }
  653. // list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  654. //
  655. // if mapCategoryUrl[v.CategoryId] == "" {
  656. // if detail.ChartPermissionId == utils.YI_YAO_ID {
  657. // list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  658. // }
  659. // }
  660. //}
  661. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  662. resp := new(models.TimeLineReportListResp)
  663. resp.List = list
  664. resp.Paging = page
  665. br.Ret = 200
  666. br.Success = true
  667. br.Msg = "获取成功"
  668. br.Data = resp
  669. }
  670. }
  671. // @Title 置顶/取消置顶
  672. // @Description 置顶
  673. // @Param request body models.CygxIndustryTopRep true "type json string"
  674. // @Success 200
  675. // @router /top [post]
  676. func (this *ReportController) ArticleCollect() {
  677. br := new(models.BaseResponse).Init()
  678. defer func() {
  679. this.Data["json"] = br
  680. this.ServeJSON()
  681. }()
  682. user := this.User
  683. if user == nil {
  684. br.Msg = "请重新登录"
  685. br.Ret = 408
  686. return
  687. }
  688. uid := user.UserId
  689. var req models.CygxIndustryTopRep
  690. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  691. if err != nil {
  692. br.Msg = "参数解析异常!"
  693. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  694. return
  695. }
  696. industrialManagementId := req.IndustrialManagementId
  697. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  698. if err != nil {
  699. br.Msg = "获取数据失败!"
  700. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  701. return
  702. }
  703. if countIndustrial == 0 {
  704. br.Msg = "产业不存在!"
  705. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  706. return
  707. }
  708. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  709. if err != nil {
  710. br.Msg = "获取数据失败!"
  711. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  712. return
  713. }
  714. resp := new(models.ArticleCollectResp)
  715. if count <= 0 {
  716. item := new(models.CygxIndustryTop)
  717. item.IndustrialManagementId = req.IndustrialManagementId
  718. item.UserId = uid
  719. item.CreateTime = time.Now()
  720. _, err = models.AddCygxIndustryTop(item)
  721. if err != nil {
  722. br.Msg = "置顶失败"
  723. br.ErrMsg = "置顶失败,Err:" + err.Error()
  724. return
  725. }
  726. br.Msg = "置顶成功"
  727. resp.Status = 1
  728. } else {
  729. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  730. if err != nil {
  731. br.Msg = "取消置顶失败"
  732. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  733. return
  734. }
  735. br.Msg = "已取消置顶"
  736. resp.Status = 2
  737. }
  738. br.Ret = 200
  739. br.Success = true
  740. br.Data = resp
  741. }
  742. // @Title 关注/取消关注产业
  743. // @Description 关注/取消关注 接口
  744. // @Param request body models.CygxIndustryFllowRep true "type json string"
  745. // @Success 200
  746. // @router /fllow [post]
  747. func (this *ReportController) Fllow() {
  748. br := new(models.BaseResponse).Init()
  749. defer func() {
  750. this.Data["json"] = br
  751. this.ServeJSON()
  752. }()
  753. user := this.User
  754. if user == nil {
  755. br.Msg = "请重新登录"
  756. br.Ret = 408
  757. return
  758. }
  759. uid := user.UserId
  760. var req models.CygxIndustryFllowRep
  761. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  762. if err != nil {
  763. br.Msg = "参数解析异常!"
  764. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  765. return
  766. }
  767. industrialManagementId := req.IndustrialManagementId
  768. var condition string
  769. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  770. if err != nil {
  771. br.Msg = "获取数据失败!"
  772. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  773. return
  774. }
  775. if countIndustrial == 0 {
  776. br.Msg = "产业不存在!"
  777. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  778. return
  779. }
  780. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  781. if err != nil {
  782. br.Msg = "获取数据失败!"
  783. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  784. return
  785. }
  786. resp := new(models.CygxIndustryFllowResp)
  787. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  788. if countUser == 0 {
  789. resp.GoFollow = true
  790. }
  791. if count == 0 {
  792. item := new(models.CygxIndustryFllow)
  793. item.IndustrialManagementId = industrialManagementId
  794. item.UserId = uid
  795. item.Email = user.Email
  796. item.Mobile = user.Mobile
  797. item.RealName = user.RealName
  798. item.CompanyId = user.CompanyId
  799. item.CompanyName = user.CompanyName
  800. item.Type = 1
  801. item.CreateTime = time.Now()
  802. item.ModifyTime = time.Now()
  803. _, err = models.AddCygxIndustryFllow(item)
  804. if err != nil {
  805. br.Msg = "操作失败"
  806. br.ErrMsg = "操作失败,Err:" + err.Error()
  807. return
  808. }
  809. resp.Status = 1
  810. } else {
  811. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  812. if err != nil {
  813. br.Msg = "操作失败"
  814. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  815. return
  816. }
  817. }
  818. //处理是否关注全部赛道字段
  819. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  820. br.Msg = "操作成功"
  821. br.Ret = 200
  822. br.Success = true
  823. br.Data = resp
  824. }
  825. // @Title 产业报告分类关联作者列表接口
  826. // @Description 获取产业报告分类关联作者列表接口
  827. // @Param ChartPermissionId query int true "分类ID"
  828. // @Param PageSize query int true "每页数据条数"
  829. // @Param CurrentIndex query int true "当前页页码,从1开始"
  830. // @Success 200 {object} models.CygxArticleDepartmentList
  831. // @router /industryListByDepartment [get]
  832. func (this *ReportController) IndustryListByDepartment() {
  833. br := new(models.BaseResponse).Init()
  834. defer func() {
  835. this.Data["json"] = br
  836. this.ServeJSON()
  837. }()
  838. user := this.User
  839. if user == nil {
  840. br.Msg = "请重新登录"
  841. br.Ret = 408
  842. return
  843. }
  844. uid := user.UserId
  845. pageSize, _ := this.GetInt("PageSize")
  846. currentIndex, _ := this.GetInt("CurrentIndex")
  847. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  848. var startSize int
  849. var condition string
  850. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  851. condition = ` AND a.publish_status=1 `
  852. if pageSize <= 0 {
  853. pageSize = utils.PageSize20
  854. }
  855. if currentIndex <= 0 {
  856. currentIndex = 1
  857. }
  858. startSize = paging.StartIndex(currentIndex, pageSize)
  859. total, err := models.GetArticleDepartmentCount(condition)
  860. page := paging.GetPaging(currentIndex, pageSize, total)
  861. resp := new(models.CygxArticleDepartmentList)
  862. userType, _, err := services.GetUserType(user.CompanyId)
  863. if err != nil {
  864. br.Msg = "获取信息失败"
  865. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  866. return
  867. }
  868. if userType == 1 {
  869. resp.Paging = page
  870. br.Ret = 200
  871. br.Success = true
  872. br.Msg = "获取成功"
  873. br.Data = resp
  874. return
  875. }
  876. resp.HaveResearch = true
  877. //获取作者信息,并排序
  878. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  879. if err != nil {
  880. br.Msg = "获取信息失败"
  881. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  882. return
  883. }
  884. for k, v := range list {
  885. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  886. if err != nil {
  887. br.Msg = "获取信息失败"
  888. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  889. return
  890. }
  891. for k2, v2 := range artList {
  892. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  893. if err != nil {
  894. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  895. br.ErrMsg = "获取失败,Err:" + err.Error()
  896. return
  897. }
  898. var subjectNamesNew string
  899. if len(subjectNames) > 0 {
  900. slice := strings.Split(subjectNames, "/")
  901. for k3, v3 := range slice {
  902. if k3 < 4 {
  903. subjectNamesNew += v3 + "/"
  904. }
  905. }
  906. }
  907. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  908. if err != nil && err.Error() != utils.ErrNoRow() {
  909. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  910. br.ErrMsg = "获取失败,Err:" + err.Error()
  911. return
  912. }
  913. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  914. artList[k2].SubjectName = subjectNamesNew
  915. artList[k2].DepartmentId = v.DepartmentId
  916. if subjectNamesNew == "" {
  917. artList[k2].IndustryName = industryName
  918. } else {
  919. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  920. }
  921. if artList[k2].IsReport == "1" {
  922. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  923. } else {
  924. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  925. }
  926. }
  927. list[k].List = artList
  928. if v.FollowNum > 0 {
  929. list[k].IsMyFollow = true
  930. }
  931. }
  932. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  933. if err != nil {
  934. br.Msg = "获取信息失败"
  935. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  936. return
  937. }
  938. if len(listnNew) > 0 {
  939. for _, v := range listnNew {
  940. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  941. Management := new(models.IndustrialManagementIdInt)
  942. if firstStr == 0 {
  943. Management.IndustryName = v.IndustryName
  944. } else {
  945. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  946. if err != nil {
  947. br.Msg = "获取信息失败"
  948. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  949. return
  950. }
  951. var subjectNamesNew string
  952. for _, v1 := range listSub {
  953. subjectNamesNew += v1.SubjectName + "/"
  954. }
  955. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  956. Management.IndustryName = subjectNamesNew
  957. }
  958. Management.IndustrialManagementId = v.IndustrialManagementId
  959. Management.ArticleId = v.ArticleId
  960. resp.ListnNew = append(resp.ListnNew, Management)
  961. }
  962. }
  963. resp.List = list
  964. resp.Paging = page
  965. br.Ret = 200
  966. br.Success = true
  967. br.Msg = "获取成功"
  968. br.Data = resp
  969. }
  970. // @Title 关注作者/取消关注作者
  971. // @Description 关注作者/取消关注作者 接口
  972. // @Param request body models.CygxArticleDepartmentId true "type json string"
  973. // @Success 200
  974. // @router /fllowDepartment [post]
  975. func (this *ReportController) FllowDepartment() {
  976. br := new(models.BaseResponse).Init()
  977. defer func() {
  978. this.Data["json"] = br
  979. this.ServeJSON()
  980. }()
  981. user := this.User
  982. if user == nil {
  983. br.Msg = "请重新登录"
  984. br.Ret = 408
  985. return
  986. }
  987. uid := user.UserId
  988. var req models.CygxArticleDepartmentId
  989. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  990. if err != nil {
  991. br.Msg = "参数解析异常!"
  992. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  993. return
  994. }
  995. departmentId := req.DepartmentId
  996. var condition string
  997. countDepartment, err := models.GetDepartmentCount(departmentId)
  998. if err != nil {
  999. br.Msg = "获取数据失败!"
  1000. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1001. return
  1002. }
  1003. if countDepartment == 0 {
  1004. br.Msg = "作者不存在!"
  1005. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1006. return
  1007. }
  1008. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1009. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1010. if err != nil {
  1011. br.Msg = "获取数据失败!"
  1012. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1013. return
  1014. }
  1015. resp := new(models.CygxArticleDepartmentFollowResp)
  1016. if countUser == 0 {
  1017. resp.GoFollow = true
  1018. }
  1019. if count == 0 {
  1020. item := new(models.CygxArticleDepartmentFollow)
  1021. item.DepartmentId = departmentId
  1022. item.UserId = uid
  1023. item.Email = user.Email
  1024. item.Mobile = user.Mobile
  1025. item.RealName = user.RealName
  1026. item.CompanyId = user.CompanyId
  1027. item.CompanyName = user.CompanyName
  1028. item.Type = 1
  1029. item.CreateTime = time.Now()
  1030. item.ModifyTime = time.Now()
  1031. _, err = models.AddArticleDepartmentFollow(item)
  1032. if err != nil {
  1033. br.Msg = "操作失败"
  1034. br.ErrMsg = "操作失败,Err:" + err.Error()
  1035. return
  1036. }
  1037. resp.Status = 1
  1038. } else {
  1039. var doType int
  1040. condition = ` AND type = 1`
  1041. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1042. if err != nil {
  1043. br.Msg = "操作失败!"
  1044. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1045. return
  1046. }
  1047. if count == 1 {
  1048. resp.Status = 2
  1049. doType = 2
  1050. } else {
  1051. resp.Status = 1
  1052. doType = 1
  1053. }
  1054. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1055. if err != nil {
  1056. br.Msg = "操作失败"
  1057. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1058. return
  1059. }
  1060. }
  1061. br.Msg = "操作成功"
  1062. br.Ret = 200
  1063. br.Success = true
  1064. br.Data = resp
  1065. }
  1066. // @Title 研选文章列表接口
  1067. // @Description 获取研选文章列表接口
  1068. // @Param PageSize query int true "每页数据条数"
  1069. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1070. // @Param ArticleId query int true "文章id"
  1071. // @Param DepartmentId query int true "作者ID"
  1072. // @Param IndustrialManagementId query int true "产业ID"
  1073. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1074. // @router /industry/reportList [get]
  1075. func (this *ReportController) ReportList() {
  1076. br := new(models.BaseResponse).Init()
  1077. defer func() {
  1078. this.Data["json"] = br
  1079. this.ServeJSON()
  1080. }()
  1081. user := this.User
  1082. if user == nil {
  1083. br.Msg = "请重新登录"
  1084. br.Ret = 408
  1085. return
  1086. }
  1087. uid := user.UserId
  1088. pageSize, _ := this.GetInt("PageSize")
  1089. currentIndex, _ := this.GetInt("CurrentIndex")
  1090. departmentId, _ := this.GetInt("DepartmentId")
  1091. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1092. articleId, _ := this.GetInt("ArticleId")
  1093. var condition string
  1094. var startSize int
  1095. if pageSize <= 0 {
  1096. pageSize = utils.PageSize20
  1097. }
  1098. if currentIndex <= 0 {
  1099. currentIndex = 1
  1100. }
  1101. startSize = paging.StartIndex(currentIndex, pageSize)
  1102. var pars []interface{}
  1103. var total int
  1104. resp := new(models.ReportArticleWhichIndustrialRepList)
  1105. page := paging.GetPaging(currentIndex, pageSize, total)
  1106. userType, _, err := services.GetUserType(user.CompanyId)
  1107. if err != nil {
  1108. br.Msg = "获取信息失败"
  1109. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1110. return
  1111. }
  1112. if userType == 1 {
  1113. resp.Paging = page
  1114. br.Ret = 200
  1115. br.Success = true
  1116. br.Msg = "获取成功"
  1117. br.Data = resp
  1118. return
  1119. }
  1120. resp.HaveResearch = true
  1121. if departmentId > 0 {
  1122. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1123. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1124. if err != nil {
  1125. br.Msg = "获取信息失败"
  1126. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1127. return
  1128. }
  1129. resp.NickName = detail.NickName
  1130. }
  1131. if industrialManagementId > 0 {
  1132. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1133. }
  1134. if articleId > 0 {
  1135. detail, err := models.GetArticleDetailById(articleId)
  1136. if err != nil {
  1137. br.Msg = "获取信息失败"
  1138. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1139. return
  1140. }
  1141. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1142. }
  1143. total, err = models.GetWhichDepartmentCount(condition)
  1144. if err != nil {
  1145. br.Msg = "获取信息失败"
  1146. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. page = paging.GetPaging(currentIndex, pageSize, total)
  1150. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1151. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1152. if err != nil {
  1153. br.Msg = "获取失败"
  1154. br.ErrMsg = "获取失败,Err:" + err.Error()
  1155. return
  1156. }
  1157. for k, v := range list {
  1158. if v.Readnum == 0 {
  1159. list[k].IsRed = true
  1160. }
  1161. list[k].IsResearch = true
  1162. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1163. if err != nil {
  1164. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1165. br.ErrMsg = "获取失败,Err:" + err.Error()
  1166. return
  1167. }
  1168. var subjectNamesNew string
  1169. if len(subjectNames) > 0 {
  1170. slice := strings.Split(subjectNames, "/")
  1171. for k3, v3 := range slice {
  1172. if k3 < 4 {
  1173. subjectNamesNew += v3 + "/"
  1174. }
  1175. }
  1176. }
  1177. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1178. if err != nil && err.Error() != utils.ErrNoRow() {
  1179. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1180. br.ErrMsg = "获取失败,Err:" + err.Error()
  1181. return
  1182. }
  1183. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1184. list[k].SubjectName = subjectNamesNew
  1185. if subjectNamesNew != "" {
  1186. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1187. } else {
  1188. list[k].IndustryName = industryName
  1189. }
  1190. resp.IndustryName = industryName
  1191. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1192. }
  1193. resp.List = list
  1194. resp.Paging = page
  1195. br.Ret = 200
  1196. br.Success = true
  1197. br.Msg = "获取成功"
  1198. br.Data = resp
  1199. }
  1200. // @Title 研选最新主题关键词文章列表接口
  1201. // @Description 获取研选最新主题关键词文章列表接口
  1202. // @Param PageSize query int true "每页数据条数"
  1203. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1204. // @Param ArticleId query int true "文章id"
  1205. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1206. // @router /industry/reportListNew [get]
  1207. func (this *ReportController) ReportListNew() {
  1208. br := new(models.BaseResponse).Init()
  1209. defer func() {
  1210. this.Data["json"] = br
  1211. this.ServeJSON()
  1212. }()
  1213. user := this.User
  1214. if user == nil {
  1215. br.Msg = "请重新登录"
  1216. br.Ret = 408
  1217. return
  1218. }
  1219. uid := user.UserId
  1220. pageSize, _ := this.GetInt("PageSize")
  1221. currentIndex, _ := this.GetInt("CurrentIndex")
  1222. articleId, _ := this.GetInt("ArticleId")
  1223. var condition string
  1224. var startSize int
  1225. if pageSize <= 0 {
  1226. pageSize = utils.PageSize20
  1227. }
  1228. if currentIndex <= 0 {
  1229. currentIndex = 1
  1230. }
  1231. startSize = paging.StartIndex(currentIndex, pageSize)
  1232. var pars []interface{}
  1233. var total int
  1234. resp := new(models.ReportArticleWhichIndustrialRepList)
  1235. page := paging.GetPaging(currentIndex, pageSize, total)
  1236. userType, _, err := services.GetUserType(user.CompanyId)
  1237. if err != nil {
  1238. br.Msg = "获取信息失败"
  1239. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1240. return
  1241. }
  1242. if userType == 1 {
  1243. resp.Paging = page
  1244. br.Ret = 200
  1245. br.Success = true
  1246. br.Msg = "获取成功"
  1247. br.Data = resp
  1248. return
  1249. }
  1250. resp.HaveResearch = true
  1251. if articleId > 0 {
  1252. detail, err := models.GetArticleDetailById(articleId)
  1253. if err != nil {
  1254. br.Msg = "获取信息失败"
  1255. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1256. return
  1257. }
  1258. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1259. if firstStr == 0 {
  1260. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1261. } else {
  1262. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1263. }
  1264. }
  1265. total, err = models.GetWhichDepartmentCount(condition)
  1266. if err != nil {
  1267. br.Msg = "获取信息失败"
  1268. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1269. return
  1270. }
  1271. page = paging.GetPaging(currentIndex, pageSize, total)
  1272. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1273. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1274. if err != nil {
  1275. br.Msg = "获取失败"
  1276. br.ErrMsg = "获取失败,Err:" + err.Error()
  1277. return
  1278. }
  1279. for k, v := range list {
  1280. if v.Readnum == 0 {
  1281. list[k].IsRed = true
  1282. }
  1283. list[k].IsResearch = true
  1284. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1285. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1286. if err != nil {
  1287. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1288. br.ErrMsg = "获取失败,Err:" + err.Error()
  1289. return
  1290. }
  1291. var subjectNamesNew string
  1292. if len(subjectNames) > 0 {
  1293. slice := strings.Split(subjectNames, "/")
  1294. for k3, v3 := range slice {
  1295. if k3 < 4 {
  1296. subjectNamesNew += v3 + "/"
  1297. }
  1298. }
  1299. }
  1300. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1301. if err != nil && err.Error() != utils.ErrNoRow() {
  1302. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1303. br.ErrMsg = "获取失败,Err:" + err.Error()
  1304. return
  1305. }
  1306. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1307. list[k].SubjectName = subjectNamesNew
  1308. if subjectNamesNew != "" {
  1309. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1310. } else {
  1311. list[k].IndustryName = industryName
  1312. }
  1313. resp.IndustryName = industryName
  1314. }
  1315. resp.List = list
  1316. resp.Paging = page
  1317. br.Ret = 200
  1318. br.Success = true
  1319. br.Msg = "获取成功"
  1320. br.Data = resp
  1321. }
  1322. // @Title 是否展示绝密内参
  1323. // @Description 获取是否展示绝密内参接口
  1324. // @Param request body models.IsShow true "type json string"
  1325. // @Success 200
  1326. // @router /isShow [get]
  1327. func (this *ReportController) IsShow() {
  1328. br := new(models.BaseResponse).Init()
  1329. defer func() {
  1330. this.Data["json"] = br
  1331. this.ServeJSON()
  1332. }()
  1333. user := this.User
  1334. if user == nil {
  1335. br.Msg = "请重新登录"
  1336. br.Ret = 408
  1337. return
  1338. }
  1339. var resp models.IsShow
  1340. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1341. if err != nil {
  1342. br.Msg = "获取失败"
  1343. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1344. return
  1345. }
  1346. resp.IsShowChart = true
  1347. //resp.IsShowResearch = true
  1348. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1349. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1350. //resp.YanXuan_Explain = true
  1351. resp.IsShowFreeButton = IsShowFreeButton
  1352. mobile := user.Mobile
  1353. if mobile == "" {
  1354. br.Ret = 200
  1355. br.Success = true
  1356. br.Data = resp
  1357. return
  1358. }
  1359. total, _ := models.GetUserIsAdminCount(mobile)
  1360. if total > 0 {
  1361. resp.IsShowList = true
  1362. }
  1363. resp.SearchTxtList.SummarySearch = "全局搜索"
  1364. resp.SearchTxtList.ReportSearch = "全局搜索"
  1365. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1366. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1367. resp.SearchTxtList.TabSearch = "请输入关键词"
  1368. resp.IsShow = true
  1369. br.Ret = 200
  1370. br.Success = true
  1371. br.Data = resp
  1372. }
  1373. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1374. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1375. // @Param PageSize query int true "每页数据条数"
  1376. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1377. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1378. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1379. // @router /reportList/byType [get]
  1380. func (this *ReportController) ReportListByType() {
  1381. br := new(models.BaseResponse).Init()
  1382. defer func() {
  1383. this.Data["json"] = br
  1384. this.ServeJSON()
  1385. }()
  1386. user := this.User
  1387. if user == nil {
  1388. br.Msg = "请重新登录"
  1389. br.Ret = 408
  1390. return
  1391. }
  1392. uid := user.UserId
  1393. pageSize, _ := this.GetInt("PageSize")
  1394. currentIndex, _ := this.GetInt("CurrentIndex")
  1395. reportType := this.GetString("ReportType")
  1396. var condition string
  1397. var startSize int
  1398. if pageSize <= 0 {
  1399. pageSize = utils.PageSize20
  1400. }
  1401. if currentIndex <= 0 {
  1402. currentIndex = 1
  1403. }
  1404. startSize = paging.StartIndex(currentIndex, pageSize)
  1405. var pars []interface{}
  1406. var total int
  1407. resp := new(models.CygxReportSelectionListPublicRep)
  1408. page := paging.GetPaging(currentIndex, pageSize, total)
  1409. var tbdb string
  1410. var readSql string
  1411. var reportTypeStr string
  1412. if reportType == "1" {
  1413. tbdb = "cygx_report_selection"
  1414. reportTypeStr = "bgjx"
  1415. } else if reportType == "2" {
  1416. tbdb = "cygx_research_summary"
  1417. reportTypeStr = "bzyjhz"
  1418. } else if reportType == "3" {
  1419. tbdb = "cygx_minutes_summary"
  1420. reportTypeStr = "szjyhz"
  1421. } else {
  1422. br.Msg = "请选择报告类型"
  1423. return
  1424. }
  1425. fmt.Println(tbdb)
  1426. condition = ` AND publish_status = 1 `
  1427. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1428. if err != nil {
  1429. br.Msg = "获取信息失败"
  1430. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1431. return
  1432. }
  1433. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1434. if reportType == "1" {
  1435. startSize = 0
  1436. pageSize = 1
  1437. total = 1
  1438. }
  1439. 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`
  1440. page = paging.GetPaging(currentIndex, pageSize, total)
  1441. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1442. if err != nil {
  1443. br.Msg = "获取失败"
  1444. br.ErrMsg = "获取失败,Err:" + err.Error()
  1445. return
  1446. }
  1447. for k, v := range list {
  1448. if reportType == "1" {
  1449. list[k].Abstract = v.UpdateDescription
  1450. }
  1451. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1452. if v.ReadNum == 0 {
  1453. list[k].IsRed = true
  1454. }
  1455. }
  1456. resp.List = list
  1457. resp.Paging = page
  1458. br.Ret = 200
  1459. br.Success = true
  1460. br.Msg = "获取成功"
  1461. br.Data = resp
  1462. }
  1463. // @Title 获取报告精选详情
  1464. // @Description 获取报告精选详情接口
  1465. // @Param ArticleId query int true "报告ID"
  1466. // @Success 200 {object} models.ReportSelectionLetailResp
  1467. // @router /reportSelection/detail [get]
  1468. func (this *ReportController) Detail() {
  1469. br := new(models.BaseResponse).Init()
  1470. defer func() {
  1471. this.Data["json"] = br
  1472. this.ServeJSON()
  1473. }()
  1474. user := this.User
  1475. if user == nil {
  1476. br.Msg = "请重新登录"
  1477. br.Ret = 408
  1478. return
  1479. }
  1480. uid := user.UserId
  1481. articleId, _ := this.GetInt("ArticleId")
  1482. if articleId < 0 {
  1483. br.Msg = "参数错误"
  1484. br.ErrMsg = "参数错误"
  1485. return
  1486. }
  1487. resp := new(models.ReportSelectionLetailResp)
  1488. //判断用户权限
  1489. hasPermission, err := services.GetUserhasPermission(user)
  1490. if err != nil {
  1491. br.Msg = "获取信息失败"
  1492. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1493. }
  1494. resp.HasPermission = hasPermission
  1495. if hasPermission != 1 {
  1496. br.Ret = 200
  1497. br.Success = true
  1498. br.Msg = "获取成功"
  1499. br.Data = resp
  1500. return
  1501. }
  1502. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1503. if err != nil {
  1504. br.Msg = "获取信息失败"
  1505. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1506. return
  1507. }
  1508. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1509. existMap := make(map[int]int)
  1510. var items []*models.ReportSelectionChartPermission
  1511. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1512. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1513. if err != nil {
  1514. br.Msg = "获取失败"
  1515. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1516. return
  1517. }
  1518. //var itemLogs []*models.CygxReportSelectionLogDetail
  1519. for _, v := range listLog {
  1520. item := new(models.ReportSelectionChartPermission)
  1521. if existMap[v.ChartPermissionId] == 0 {
  1522. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1523. item.IcoLink = v.IcoLink
  1524. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1525. if err != nil && err.Error() != utils.ErrNoRow() {
  1526. br.Msg = "获取信息失败"
  1527. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1528. return
  1529. }
  1530. for k2, v2 := range listSonLog {
  1531. if v2.IndustrialManagementId != "" {
  1532. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1533. if err != nil && err.Error() != utils.ErrNoRow() {
  1534. br.Msg = "获取信息失败"
  1535. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1536. return
  1537. }
  1538. listSonLog[k2].List = listIndustrial
  1539. }
  1540. }
  1541. item.List = listSonLog
  1542. items = append(items, item)
  1543. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1544. }
  1545. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1546. }
  1547. historyRecord := new(models.CygxReportHistoryRecord)
  1548. historyRecord.UserId = uid
  1549. historyRecord.ArticleId = articleId
  1550. historyRecord.CreateTime = time.Now()
  1551. historyRecord.Mobile = user.Mobile
  1552. historyRecord.Email = user.Email
  1553. historyRecord.CompanyId = user.CompanyId
  1554. historyRecord.CompanyName = user.CompanyName
  1555. historyRecord.ReportType = "bgjx"
  1556. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1557. if err != nil && err.Error() != utils.ErrNoRow() {
  1558. br.Msg = "获取信息失败"
  1559. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1560. return
  1561. }
  1562. historyRecord.RealName = user.RealName
  1563. if sellerItem != nil {
  1564. historyRecord.SellerName = sellerItem.RealName
  1565. }
  1566. go models.AddCygxReportHistoryRecord(historyRecord)
  1567. resp.List = items
  1568. resp.Detail = detail
  1569. br.Ret = 200
  1570. br.Success = true
  1571. br.Msg = "获取成功"
  1572. br.Data = resp
  1573. }
  1574. // @Title 获取本周研究汇总详情
  1575. // @Description 获取本周研究汇总详情接口
  1576. // @Param ArticleId query int true "报告ID"
  1577. // @Success 200 {object} models.ResearchSummaryLetailResp
  1578. // @router /researchSummary/detail [get]
  1579. func (this *ReportController) ResearchDetail() {
  1580. br := new(models.BaseResponse).Init()
  1581. defer func() {
  1582. this.Data["json"] = br
  1583. this.ServeJSON()
  1584. }()
  1585. user := this.User
  1586. if user == nil {
  1587. br.Msg = "请重新登录"
  1588. br.Ret = 408
  1589. return
  1590. }
  1591. uid := user.UserId
  1592. articleId, _ := this.GetInt("ArticleId")
  1593. if articleId < 0 {
  1594. br.Msg = "参数错误"
  1595. br.ErrMsg = "参数错误"
  1596. return
  1597. }
  1598. resp := new(models.ResearchSummaryLetailResp)
  1599. //判断用户权限
  1600. hasPermission, err := services.GetUserhasPermission(user)
  1601. if err != nil {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1604. }
  1605. resp.HasPermission = hasPermission
  1606. if hasPermission != 1 {
  1607. br.Ret = 200
  1608. br.Success = true
  1609. br.Msg = "获取成功"
  1610. br.Data = resp
  1611. return
  1612. }
  1613. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1614. if err != nil {
  1615. br.Msg = "获取信息失败"
  1616. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1617. return
  1618. }
  1619. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1620. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1621. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1622. if err != nil {
  1623. br.Msg = "获取失败"
  1624. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1625. return
  1626. }
  1627. listArticleType, err := models.GetCygxArticleTypeList()
  1628. if err != nil {
  1629. br.Msg = "获取失败"
  1630. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1631. return
  1632. }
  1633. for k, v := range listFirst {
  1634. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1635. if err != nil && err.Error() != utils.ErrNoRow() {
  1636. br.Msg = "获取信息失败"
  1637. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1638. return
  1639. }
  1640. for k2, v2 := range listSecond {
  1641. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1642. if err != nil && err.Error() != utils.ErrNoRow() {
  1643. br.Msg = "获取信息失败"
  1644. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1645. return
  1646. }
  1647. for _, vType := range listArticleType {
  1648. if v2.ChartPermissionId == vType.YanxPermissionId {
  1649. listSecond[k2].IcoLink = vType.IcoLinkM
  1650. listSecond[k2].PermissionName = vType.YanxPermissionName
  1651. }
  1652. }
  1653. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1654. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1655. // listSecond[k2].PermissionName = "买方研选纪要"
  1656. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1657. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1658. // listSecond[k2].PermissionName = "买方研选观点"
  1659. //}
  1660. if len(listThird) > 0 {
  1661. for k3, v3 := range listThird {
  1662. if v3.VideoUrl != "" {
  1663. listThird[k3].IsHaveVideo = true
  1664. }
  1665. if v3.ReportLink == "0" {
  1666. listThird[k3].ReportLink = ""
  1667. }
  1668. }
  1669. listSecond[k2].List = listThird
  1670. }
  1671. }
  1672. if len(listSecond) > 0 {
  1673. listFirst[k].List = listSecond
  1674. }
  1675. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1676. if v.Type == "SDBG" {
  1677. listFirst[k].ListName = "深度报告"
  1678. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1679. } else if v.Type == "BZCHJH" {
  1680. listFirst[k].ListName = "本周晨会精华"
  1681. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1682. } else if v.Type == "CYDYJY" {
  1683. listFirst[k].ListName = "产业调研纪要"
  1684. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1685. } else if v.Type == "SSGS" {
  1686. listFirst[k].ListName = "上市公司调研纪要篇"
  1687. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1688. } else if v.Type == "SJDP" {
  1689. listFirst[k].ListName = "事件点评"
  1690. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1691. } else if v.Type == "YANX" {
  1692. listFirst[k].ListName = "买方研选"
  1693. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1694. }
  1695. }
  1696. historyRecord := new(models.CygxReportHistoryRecord)
  1697. historyRecord.UserId = uid
  1698. historyRecord.ArticleId = articleId
  1699. historyRecord.CreateTime = time.Now()
  1700. historyRecord.Mobile = user.Mobile
  1701. historyRecord.Email = user.Email
  1702. historyRecord.CompanyId = user.CompanyId
  1703. historyRecord.CompanyName = user.CompanyName
  1704. historyRecord.ReportType = "bzyjhz"
  1705. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1706. if err != nil && err.Error() != utils.ErrNoRow() {
  1707. br.Msg = "获取信息失败"
  1708. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1709. return
  1710. }
  1711. historyRecord.RealName = user.RealName
  1712. if sellerItem != nil {
  1713. historyRecord.SellerName = sellerItem.RealName
  1714. }
  1715. go models.AddCygxReportHistoryRecord(historyRecord)
  1716. resp.List = listFirst
  1717. resp.Detail = detail
  1718. br.Ret = 200
  1719. br.Success = true
  1720. br.Msg = "获取成功"
  1721. br.Data = resp
  1722. }
  1723. // @Title 上周纪要汇总内容详情
  1724. // @Description 获取上周纪要汇总内容详情接口
  1725. // @Param ArticleId query int true "报告ID"
  1726. // @Success 200 {object} models.MinutesSummaryLetailResp
  1727. // @router /minutesSummary/detailv4 [get]
  1728. func (this *ReportController) MinutesDetailV4() {
  1729. br := new(models.BaseResponse).Init()
  1730. defer func() {
  1731. this.Data["json"] = br
  1732. this.ServeJSON()
  1733. }()
  1734. user := this.User
  1735. if user == nil {
  1736. br.Msg = "请重新登录"
  1737. br.Ret = 408
  1738. return
  1739. }
  1740. uid := user.UserId
  1741. articleId, _ := this.GetInt("ArticleId")
  1742. if articleId < 0 {
  1743. br.Msg = "参数错误"
  1744. br.ErrMsg = "参数错误"
  1745. return
  1746. }
  1747. resp := new(models.MinutesSummaryLetailRespV4)
  1748. //判断用户权限
  1749. hasPermission, err := services.GetUserhasPermission(user)
  1750. if err != nil {
  1751. br.Msg = "获取信息失败"
  1752. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1753. }
  1754. resp.HasPermission = hasPermission
  1755. if hasPermission != 1 {
  1756. br.Ret = 200
  1757. br.Success = true
  1758. br.Msg = "获取成功"
  1759. br.Data = resp
  1760. return
  1761. }
  1762. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1763. if err != nil {
  1764. br.Msg = "获取信息失败"
  1765. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1766. return
  1767. }
  1768. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1769. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1770. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1771. if err != nil {
  1772. br.Msg = "获取失败"
  1773. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1774. return
  1775. }
  1776. for k, v := range listFirst {
  1777. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1778. if err != nil && err.Error() != utils.ErrNoRow() {
  1779. br.Msg = "获取信息失败"
  1780. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1781. return
  1782. }
  1783. for k2, v2 := range listSecond {
  1784. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1785. if err != nil && err.Error() != utils.ErrNoRow() {
  1786. br.Msg = "获取信息失败"
  1787. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1788. return
  1789. }
  1790. if len(listThird) > 0 {
  1791. for k3, v3 := range listThird {
  1792. if v3.VideoUrl != "" {
  1793. listThird[k3].IsHaveVideo = true
  1794. }
  1795. if v3.ReportLink == "0" {
  1796. listThird[k3].ReportLink = ""
  1797. }
  1798. }
  1799. listSecond[k2].List = listThird
  1800. }
  1801. }
  1802. if len(listSecond) > 0 {
  1803. listFirst[k].List = listSecond
  1804. }
  1805. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1806. if v.Type == "CYDYJY" {
  1807. listFirst[k].ListName = "产业调研纪要"
  1808. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1809. } else if v.Type == "SSGS" {
  1810. listFirst[k].ListName = "上市公司调研纪要篇"
  1811. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1812. } else if v.Type == "YANX" {
  1813. listFirst[k].ListName = "买方研选纪要"
  1814. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1815. }
  1816. }
  1817. historyRecord := new(models.CygxReportHistoryRecord)
  1818. historyRecord.UserId = uid
  1819. historyRecord.ArticleId = articleId
  1820. historyRecord.CreateTime = time.Now()
  1821. historyRecord.Mobile = user.Mobile
  1822. historyRecord.Email = user.Email
  1823. historyRecord.CompanyId = user.CompanyId
  1824. historyRecord.CompanyName = user.CompanyName
  1825. historyRecord.ReportType = "szjyhz"
  1826. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1827. if err != nil && err.Error() != utils.ErrNoRow() {
  1828. br.Msg = "获取信息失败"
  1829. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1830. return
  1831. }
  1832. historyRecord.RealName = user.RealName
  1833. if sellerItem != nil {
  1834. historyRecord.SellerName = sellerItem.RealName
  1835. }
  1836. go models.AddCygxReportHistoryRecord(historyRecord)
  1837. resp.List = listFirst
  1838. resp.Detail = detail
  1839. br.Ret = 200
  1840. br.Success = true
  1841. br.Msg = "获取成功"
  1842. br.Data = resp
  1843. }
  1844. // @Title 上周纪要汇总内容详情
  1845. // @Description 获取上周纪要汇总内容详情接口
  1846. // @Param ArticleId query int true "报告ID"
  1847. // @Success 200 {object} models.MinutesSummaryLetailResp
  1848. // @router /minutesSummary/detail [get]
  1849. func (this *ReportController) MinutesDetail() {
  1850. br := new(models.BaseResponse).Init()
  1851. defer func() {
  1852. this.Data["json"] = br
  1853. this.ServeJSON()
  1854. }()
  1855. user := this.User
  1856. if user == nil {
  1857. br.Msg = "请重新登录"
  1858. br.Ret = 408
  1859. return
  1860. }
  1861. uid := user.UserId
  1862. articleId, _ := this.GetInt("ArticleId")
  1863. if articleId < 0 {
  1864. br.Msg = "参数错误"
  1865. br.ErrMsg = "参数错误"
  1866. return
  1867. }
  1868. resp := new(models.MinutesSummaryLetailResp)
  1869. //判断用户权限
  1870. hasPermission, err := services.GetUserhasPermission(user)
  1871. if err != nil {
  1872. br.Msg = "获取信息失败"
  1873. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1874. }
  1875. resp.HasPermission = hasPermission
  1876. if hasPermission != 1 {
  1877. br.Ret = 200
  1878. br.Success = true
  1879. br.Msg = "获取成功"
  1880. br.Data = resp
  1881. return
  1882. }
  1883. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1884. if err != nil {
  1885. br.Msg = "获取信息失败"
  1886. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1887. return
  1888. }
  1889. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1890. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1891. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1892. if err != nil {
  1893. br.Msg = "获取失败"
  1894. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1895. return
  1896. }
  1897. for k, v := range listLog {
  1898. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1899. if err != nil && err.Error() != utils.ErrNoRow() {
  1900. br.Msg = "获取信息失败"
  1901. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1902. return
  1903. }
  1904. if len(listSonLog) > 0 {
  1905. listLog[k].List = listSonLog
  1906. for k2, v2 := range listSonLog {
  1907. if v2.ReportLink == "0" {
  1908. listSonLog[k2].ReportLink = ""
  1909. }
  1910. }
  1911. }
  1912. }
  1913. historyRecord := new(models.CygxReportHistoryRecord)
  1914. historyRecord.UserId = uid
  1915. historyRecord.ArticleId = articleId
  1916. historyRecord.CreateTime = time.Now()
  1917. historyRecord.Mobile = user.Mobile
  1918. historyRecord.Email = user.Email
  1919. historyRecord.CompanyId = user.CompanyId
  1920. historyRecord.CompanyName = user.CompanyName
  1921. historyRecord.ReportType = "szjyhz"
  1922. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1923. if err != nil && err.Error() != utils.ErrNoRow() {
  1924. br.Msg = "获取信息失败"
  1925. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1926. return
  1927. }
  1928. historyRecord.RealName = user.RealName
  1929. if sellerItem != nil {
  1930. historyRecord.SellerName = sellerItem.RealName
  1931. }
  1932. go models.AddCygxReportHistoryRecord(historyRecord)
  1933. resp.List = listLog
  1934. resp.Detail = detail
  1935. br.Ret = 200
  1936. br.Success = true
  1937. br.Msg = "获取成功"
  1938. br.Data = resp
  1939. }
  1940. // @Title 获取路演精华详情
  1941. // @Description 获取路演精华详情接口
  1942. // @Param ArticleId query int true "报告ID"
  1943. // @Success 200 {object} models.RoadshowDetailResp
  1944. // @router /roadshowEssence/detail [get]
  1945. func (this *ReportController) RoadshowDetail() {
  1946. br := new(models.BaseResponse).Init()
  1947. defer func() {
  1948. this.Data["json"] = br
  1949. this.ServeJSON()
  1950. }()
  1951. user := this.User
  1952. if user == nil {
  1953. br.Msg = "请登录"
  1954. br.ErrMsg = "请登录,用户信息为空"
  1955. br.Ret = 408
  1956. return
  1957. }
  1958. uid := user.UserId
  1959. articleId, err := this.GetInt("ArticleId")
  1960. if articleId <= 0 {
  1961. br.Msg = "文章不存在"
  1962. br.ErrMsg = "文章不存在,文章ID错误"
  1963. return
  1964. }
  1965. detail := new(models.ReportDetailRoadshow)
  1966. hasPermission := 0
  1967. hasFree := 0
  1968. //判断是否已经申请过
  1969. applyCount, err := models.GetApplyRecordCount(uid)
  1970. if err != nil && err.Error() != utils.ErrNoRow() {
  1971. br.Msg = "获取信息失败"
  1972. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1973. return
  1974. }
  1975. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1976. if user.CompanyId > 1 {
  1977. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1978. if err != nil {
  1979. br.Msg = "获取信息失败"
  1980. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1981. return
  1982. }
  1983. detail, err = models.GetReportRoadshowDetailById(articleId)
  1984. if err != nil {
  1985. br.Msg = "获取信息失败"
  1986. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1987. return
  1988. }
  1989. detail.Body = html.UnescapeString(detail.Body)
  1990. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  1991. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1992. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1993. if detail.ReportLink == "0" {
  1994. detail.ReportLink = ""
  1995. }
  1996. if companyPermission == "" {
  1997. if applyCount > 0 {
  1998. hasPermission = 5
  1999. } else {
  2000. hasPermission = 2
  2001. }
  2002. hasFree = 2
  2003. goto Loop
  2004. } else {
  2005. hasFree = 1
  2006. var articlePermissionPermissionName string
  2007. articlePermissionPermissionName = detail.CategoryName
  2008. var hasPersion bool
  2009. slice := strings.Split(articlePermissionPermissionName, ",")
  2010. for _, v := range slice {
  2011. if strings.Contains(companyPermission, v) {
  2012. hasPersion = true
  2013. }
  2014. }
  2015. if hasPersion {
  2016. hasPermission = 1
  2017. historyRecord := new(models.CygxArticleHistoryRecord)
  2018. historyRecord.UserId = uid
  2019. historyRecord.ArticleId = articleId
  2020. historyRecord.CreateTime = time.Now()
  2021. historyRecord.Mobile = user.Mobile
  2022. historyRecord.Email = user.Email
  2023. historyRecord.CompanyId = user.CompanyId
  2024. historyRecord.CompanyName = user.CompanyName
  2025. go models.AddCygxArticleHistoryRecord(historyRecord)
  2026. } else { //无该行业权限
  2027. hasPermission = 3
  2028. }
  2029. if hasPermission == 1 {
  2030. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2031. if !utils.Rc.IsExist(key) {
  2032. //新增浏览记录
  2033. record := new(models.CygxArticleViewRecord)
  2034. record.UserId = uid
  2035. record.ArticleId = articleId
  2036. record.CreateTime = time.Now()
  2037. record.Mobile = user.Mobile
  2038. record.Email = user.Email
  2039. record.CompanyId = user.CompanyId
  2040. record.CompanyName = user.CompanyName
  2041. go models.AddCygxArticleViewRecord(record)
  2042. utils.Rc.Put(key, 1, 5*time.Second)
  2043. models.ModifyReportLastViewTime(uid)
  2044. }
  2045. }
  2046. }
  2047. } else { //潜在客户
  2048. if applyCount > 0 {
  2049. hasPermission = 5
  2050. } else {
  2051. hasPermission = 4
  2052. }
  2053. }
  2054. Loop:
  2055. if hasPermission != 1 {
  2056. detail.Body = ""
  2057. detail.Abstract = ""
  2058. }
  2059. resp := new(models.RoadshowDetailResp)
  2060. resp.HasPermission = hasPermission
  2061. resp.HasFree = hasFree
  2062. resp.Detail = detail
  2063. br.Ret = 200
  2064. br.Success = true
  2065. br.Msg = "获取成功"
  2066. br.Data = resp
  2067. }
  2068. // @Title 产业文章列表接口
  2069. // @Description 获取产业文章列表接口
  2070. // @Param KeyWord query string true "搜索关键词"
  2071. // @Success 200 {object} models.CygxIndustrySearchList
  2072. // @router /industryAndArticle/list [get]
  2073. func (this *ReportController) IndustryAndArticleList() {
  2074. br := new(models.BaseResponse).Init()
  2075. defer func() {
  2076. this.Data["json"] = br
  2077. this.ServeJSON()
  2078. }()
  2079. user := this.User
  2080. if user == nil {
  2081. br.Msg = "请重新登录"
  2082. br.Ret = 408
  2083. return
  2084. }
  2085. uid := user.UserId
  2086. keyWord := this.GetString("KeyWord")
  2087. orderSrt := "update_time DESC"
  2088. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2089. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2090. if err != nil {
  2091. br.Msg = "获取信息失败"
  2092. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2093. return
  2094. }
  2095. for k, v := range list {
  2096. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2097. if err != nil {
  2098. br.Msg = "获取信息失败"
  2099. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2100. return
  2101. }
  2102. list[k].IndustrialSubjectList = industrialSubjectList
  2103. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2104. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2105. if err != nil {
  2106. br.Msg = "获取信息失败"
  2107. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2108. return
  2109. }
  2110. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2111. }
  2112. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2113. if err != nil {
  2114. br.Msg = "获取失败"
  2115. br.ErrMsg = "获取失败,Err:" + err.Error()
  2116. return
  2117. }
  2118. for k2, v2 := range artList {
  2119. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2120. if err != nil {
  2121. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2122. br.ErrMsg = "获取失败,Err:" + err.Error()
  2123. return
  2124. }
  2125. var subjectNamesNew string
  2126. if len(subjectNames) > 0 {
  2127. slice := strings.Split(subjectNames, "/")
  2128. for k3, v3 := range slice {
  2129. if k3 < 4 {
  2130. subjectNamesNew += v3 + "/"
  2131. }
  2132. }
  2133. }
  2134. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2135. if err != nil && err.Error() != utils.ErrNoRow() {
  2136. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2137. br.ErrMsg = "获取失败,Err:" + err.Error()
  2138. return
  2139. }
  2140. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2141. artList[k2].SubjectName = subjectNamesNew
  2142. if subjectNamesNew == "" {
  2143. artList[k2].IndustryName = industryName
  2144. } else {
  2145. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2146. }
  2147. }
  2148. if keyWord != "" {
  2149. keyWordItem := new(models.CygxUserSearchKeyWord)
  2150. keyWordItem.UserId = user.UserId
  2151. keyWordItem.KeyWord = keyWord
  2152. keyWordItem.PageType = "ReortSearch"
  2153. keyWordItem.CreateTime = time.Now()
  2154. go models.AddUserSearchKeyWord(keyWordItem)
  2155. }
  2156. resp := new(models.CygxIndustrySearchList)
  2157. resp.ArtList = artList
  2158. resp.IndList = list
  2159. br.Ret = 200
  2160. br.Success = true
  2161. br.Msg = "获取成功"
  2162. br.Data = resp
  2163. }
  2164. // @Title 产业报告分类关联作者列表接口Pc端
  2165. // @Description 获取产业报告分类关联作者列表接口Pc端
  2166. // @Param ChartPermissionId query int true "分类ID"
  2167. // @Param KeyWord query string true "搜索关键词"
  2168. // @Param PageSize query int true "每页数据条数"
  2169. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2170. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2171. // @router /industryListByDepartmentPc [get]
  2172. func (this *ReportController) IndustryListByDepartmentPc() {
  2173. br := new(models.BaseResponse).Init()
  2174. defer func() {
  2175. this.Data["json"] = br
  2176. this.ServeJSON()
  2177. }()
  2178. user := this.User
  2179. if user == nil {
  2180. br.Msg = "请重新登录"
  2181. br.Ret = 408
  2182. return
  2183. }
  2184. uid := user.UserId
  2185. pageSize, _ := this.GetInt("PageSize")
  2186. currentIndex, _ := this.GetInt("CurrentIndex")
  2187. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2188. keyWord := this.GetString("KeyWord")
  2189. var startSize int
  2190. var condition string
  2191. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2192. if pageSize <= 0 {
  2193. pageSize = utils.PageSize20
  2194. }
  2195. if currentIndex <= 0 {
  2196. currentIndex = 1
  2197. }
  2198. var articleIdGroup string
  2199. if keyWord != "" {
  2200. //获取标的关联的文章ID
  2201. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2202. if err != nil {
  2203. br.Msg = "获取信息失败"
  2204. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2205. return
  2206. }
  2207. //获取产业关联的标的
  2208. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2209. if err != nil {
  2210. br.Msg = "获取信息失败"
  2211. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2212. return
  2213. }
  2214. if articleIdSub != "" && articleIdInd != "" {
  2215. articleIdGroup = articleIdSub + "," + articleIdInd
  2216. } else if articleIdSub != "" && articleIdInd == "" {
  2217. articleIdGroup = articleIdSub
  2218. } else if articleIdSub == "" && articleIdInd != "" {
  2219. articleIdGroup = articleIdInd
  2220. }
  2221. slice := strings.Split(keyWord, "/")
  2222. if len(slice) > 1 {
  2223. var subjectIds string
  2224. for _, v := range slice {
  2225. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2226. if err != nil && err.Error() != utils.ErrNoRow() {
  2227. br.Msg = "获取信息失败"
  2228. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2229. return
  2230. }
  2231. if subjectId != "" {
  2232. subjectIds += subjectId + ","
  2233. }
  2234. }
  2235. subjectIds = strings.TrimRight(subjectIds, ",")
  2236. if len(subjectIds) > 0 {
  2237. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2238. if err != nil {
  2239. br.Msg = "获取信息失败"
  2240. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2241. return
  2242. }
  2243. if articleIdGroup != "" {
  2244. if articleBySub != "" {
  2245. articleIdGroup += "," + articleBySub
  2246. }
  2247. } else {
  2248. articleIdGroup = articleBySub
  2249. }
  2250. }
  2251. }
  2252. }
  2253. if articleIdGroup != "" {
  2254. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2255. }
  2256. startSize = paging.StartIndex(currentIndex, pageSize)
  2257. total, err := models.GetArticleDepartmentCount(condition)
  2258. page := paging.GetPaging(currentIndex, pageSize, total)
  2259. resp := new(models.CygxArticleDepartmentListPc)
  2260. userType, _, err := services.GetUserType(user.CompanyId)
  2261. if err != nil {
  2262. br.Msg = "获取信息失败"
  2263. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2264. return
  2265. }
  2266. if userType == 1 {
  2267. resp.Paging = page
  2268. br.Ret = 200
  2269. br.Success = true
  2270. br.Msg = "获取成功"
  2271. br.Data = resp
  2272. return
  2273. }
  2274. resp.HaveResearch = true
  2275. //获取作者信息,并排序
  2276. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2277. if err != nil {
  2278. br.Msg = "获取信息失败"
  2279. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2280. return
  2281. }
  2282. for k, v := range list {
  2283. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2284. if err != nil {
  2285. br.Msg = "获取信息失败"
  2286. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2287. return
  2288. }
  2289. for k2, v2 := range artList {
  2290. if artList[k2].IsReport == "1" {
  2291. artList[k2].Title = v2.Title
  2292. } else {
  2293. artList[k2].Title = v2.Title
  2294. }
  2295. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2296. }
  2297. list[k].List = artList
  2298. if v.FollowNum > 0 {
  2299. list[k].IsMyFollow = true
  2300. }
  2301. }
  2302. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2303. if err != nil {
  2304. br.Msg = "获取信息失败"
  2305. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2306. return
  2307. }
  2308. if len(listnNew) > 0 {
  2309. for _, v := range listnNew {
  2310. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2311. Management := new(models.IndustrialManagementIdInt)
  2312. if firstStr == 0 {
  2313. Management.IndustryName = v.IndustryName
  2314. } else {
  2315. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2316. if err != nil {
  2317. br.Msg = "获取信息失败"
  2318. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2319. return
  2320. }
  2321. var subjectNamesNew string
  2322. for _, v1 := range listSub {
  2323. subjectNamesNew += v1.SubjectName + "/"
  2324. }
  2325. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2326. Management.IndustryName = subjectNamesNew
  2327. }
  2328. Management.IndustrialManagementId = v.IndustrialManagementId
  2329. Management.ArticleId = v.ArticleId
  2330. resp.ListnNew = append(resp.ListnNew, Management)
  2331. }
  2332. }
  2333. resp.List = list
  2334. resp.Paging = page
  2335. br.Ret = 200
  2336. br.Success = true
  2337. br.Msg = "获取成功"
  2338. br.Data = resp
  2339. }
  2340. // @Title 产业文章列表接口Pc端
  2341. // @Description 获取产业文章列表接口Pc端
  2342. // @Param KeyWord query string true "搜索关键词"
  2343. // @Success 200 {object} models.CygxIndustrySearchListPc
  2344. // @router /industryAndArticle/listPc [get]
  2345. func (this *ReportController) IndustryAndArticleListPc() {
  2346. br := new(models.BaseResponse).Init()
  2347. defer func() {
  2348. this.Data["json"] = br
  2349. this.ServeJSON()
  2350. }()
  2351. user := this.User
  2352. if user == nil {
  2353. br.Msg = "请重新登录"
  2354. br.Ret = 408
  2355. return
  2356. }
  2357. uid := user.UserId
  2358. keyWord := this.GetString("KeyWord")
  2359. resp := new(models.CygxIndustrySearchListPc)
  2360. orderSrt := "update_time DESC"
  2361. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2362. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2363. if err != nil {
  2364. br.Msg = "获取信息失败"
  2365. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2366. return
  2367. }
  2368. for k, v := range list {
  2369. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2370. if err != nil {
  2371. br.Msg = "获取信息失败"
  2372. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2373. return
  2374. }
  2375. list[k].IndustrialSubjectList = industrialSubjectList
  2376. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2377. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2378. if err != nil {
  2379. br.Msg = "获取信息失败"
  2380. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2381. return
  2382. }
  2383. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2384. }
  2385. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2386. if err != nil {
  2387. br.Msg = "获取失败"
  2388. br.ErrMsg = "获取失败,Err:" + err.Error()
  2389. return
  2390. }
  2391. if len(artList) > 0 {
  2392. var articleIds string
  2393. for _, v := range artList {
  2394. articleIds += strconv.Itoa(v.ArticleId) + ","
  2395. }
  2396. articleIds = strings.TrimRight(articleIds, ",")
  2397. if articleIds != "" {
  2398. condition = ` AND a.article_id IN (` + articleIds + `)`
  2399. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2400. if err != nil {
  2401. br.Msg = "获取信息失败"
  2402. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2403. return
  2404. }
  2405. for k, v := range DepartmentList {
  2406. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2407. if err != nil {
  2408. br.Msg = "获取信息失败"
  2409. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2410. return
  2411. }
  2412. for k2, v2 := range artList {
  2413. if artList[k2].IsReport == "1" {
  2414. artList[k2].Title = v2.Title
  2415. } else {
  2416. artList[k2].Title = v2.Title
  2417. }
  2418. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2419. }
  2420. DepartmentList[k].List = artList
  2421. if v.FollowNum > 0 {
  2422. DepartmentList[k].IsMyFollow = true
  2423. }
  2424. }
  2425. resp.DepartmentList = DepartmentList
  2426. }
  2427. }
  2428. if keyWord != "" {
  2429. keyWordItem := new(models.CygxUserSearchKeyWord)
  2430. keyWordItem.UserId = user.UserId
  2431. keyWordItem.KeyWord = keyWord
  2432. keyWordItem.PageType = "ReortSearch"
  2433. keyWordItem.CreateTime = time.Now()
  2434. go models.AddUserSearchKeyWord(keyWordItem)
  2435. }
  2436. resp.IndList = list
  2437. br.Ret = 200
  2438. br.Success = true
  2439. br.Msg = "获取成功"
  2440. br.Data = resp
  2441. }
  2442. // @Title 报告搜索
  2443. // @Description 报告搜索接口
  2444. // @Param KeyWord query string true "搜索关键词"
  2445. // @Success 200 {object} models.ReoprtSearchResp
  2446. // @router /searchReport [get]
  2447. func (this *ReportController) SearchReport() {
  2448. br := new(models.BaseResponse).Init()
  2449. defer func() {
  2450. this.Data["json"] = br
  2451. this.ServeJSON()
  2452. }()
  2453. user := this.User
  2454. if user == nil {
  2455. br.Msg = "请重新登录"
  2456. br.Ret = 408
  2457. return
  2458. }
  2459. keyWord := this.GetString("KeyWord")
  2460. var condition string
  2461. var sqlGroup string
  2462. //匹配报告标题、
  2463. 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 `
  2464. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2465. //对应产业名称、标的名称。
  2466. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2467. if err != nil {
  2468. br.Msg = "获取信息失败"
  2469. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2470. return
  2471. }
  2472. for k, v := range listYx {
  2473. listYx[k].Source = 2
  2474. if v.MyCollectNum > 0 {
  2475. listYx[k].IsCollect = true
  2476. }
  2477. }
  2478. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2479. if err != nil {
  2480. br.Msg = "获取信息失败"
  2481. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2482. return
  2483. }
  2484. for k, v := range listHz {
  2485. listHz[k].Source = 1
  2486. if v.MyCollectNum > 0 {
  2487. listHz[k].IsCollect = true
  2488. }
  2489. }
  2490. if keyWord != "" {
  2491. keyWordItem := new(models.CygxUserSearchKeyWord)
  2492. keyWordItem.UserId = user.UserId
  2493. keyWordItem.KeyWord = keyWord
  2494. keyWordItem.PageType = "ReortSearch"
  2495. keyWordItem.CreateTime = time.Now()
  2496. go models.AddUserSearchKeyWord(keyWordItem)
  2497. go services.AddUserSearchLog(user, keyWord, 5)
  2498. }
  2499. if len(listYx) == 0 {
  2500. listYx = make([]*models.ArticleCollectionResp, 0)
  2501. }
  2502. if len(listHz) == 0 {
  2503. listHz = make([]*models.ArticleCollectionResp, 0)
  2504. }
  2505. resp := new(models.ReoprtSearchResp)
  2506. resp.ListYx = listYx
  2507. resp.ListHz = listHz
  2508. br.Ret = 200
  2509. br.Success = true
  2510. br.Msg = "获取成功"
  2511. br.Data = resp
  2512. }
  2513. // @Title 资源包搜索
  2514. // @Description 资源包搜索接口
  2515. // @Param KeyWord query string true "搜索关键词"
  2516. // @Success 200 {object} models.SearchResourceResp
  2517. // @router /searchResource [get]
  2518. func (this *ReportController) SearchResource() {
  2519. br := new(models.BaseResponse).Init()
  2520. defer func() {
  2521. this.Data["json"] = br
  2522. this.ServeJSON()
  2523. }()
  2524. user := this.User
  2525. if user == nil {
  2526. br.Msg = "请重新登录"
  2527. br.Ret = 408
  2528. return
  2529. }
  2530. uid := user.UserId
  2531. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2532. if err != nil {
  2533. br.Msg = "获取失败"
  2534. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2535. return
  2536. }
  2537. fllowMap := make(map[int]int)
  2538. if len(fllowList) > 0 {
  2539. for _, v := range fllowList {
  2540. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2541. }
  2542. }
  2543. keyWord := this.GetString("KeyWord")
  2544. var condition string
  2545. var conditionOr string
  2546. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2547. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2548. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2549. listHz, err := models.GetSearchResourceList(condition, 0, 0)
  2550. if err != nil {
  2551. br.Msg = "获取信息失败"
  2552. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2553. return
  2554. }
  2555. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2556. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2557. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2558. listYx, err := models.GetSearchResourceList(condition, 0, 0)
  2559. if err != nil {
  2560. br.Msg = "获取信息失败"
  2561. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2562. return
  2563. }
  2564. //合并产业关联的标的
  2565. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2566. if err != nil {
  2567. br.Msg = "获取信息失败"
  2568. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2569. return
  2570. }
  2571. industrialIdArr := make([]int, 0)
  2572. for k, v := range listHz {
  2573. listHz[k].Source = 1
  2574. if fllowMap[v.IndustrialManagementId] > 0 {
  2575. listHz[k].IsFollw = true
  2576. }
  2577. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2578. }
  2579. for k, v := range listYx {
  2580. listYx[k].Source = 2
  2581. if fllowMap[v.IndustrialManagementId] > 0 {
  2582. listYx[k].IsFollw = true
  2583. }
  2584. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2585. }
  2586. if len(industrialIdArr) > 0 {
  2587. //合并产业关联的标的
  2588. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2589. if err != nil {
  2590. br.Msg = "获取信息失败"
  2591. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2592. return
  2593. }
  2594. mapIndustrial := make(map[string]int)
  2595. for _, v := range listSubjcet {
  2596. for k2, v2 := range listYx {
  2597. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2598. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2599. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2600. }
  2601. }
  2602. for k2, v2 := range listHz {
  2603. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2604. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2605. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2606. }
  2607. }
  2608. }
  2609. }
  2610. if keyWord != "" {
  2611. keyWordItem := new(models.CygxUserSearchKeyWord)
  2612. keyWordItem.UserId = user.UserId
  2613. keyWordItem.KeyWord = keyWord
  2614. keyWordItem.PageType = "ReortSearch"
  2615. keyWordItem.CreateTime = time.Now()
  2616. go models.AddUserSearchKeyWord(keyWordItem)
  2617. go services.AddUserSearchLog(user, keyWord, 4)
  2618. }
  2619. resp := new(models.SearchResourceResp)
  2620. if len(listYx) == 0 {
  2621. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2622. }
  2623. if len(listHz) == 0 {
  2624. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2625. }
  2626. resp.ListYx = listYx
  2627. resp.ListHz = listHz
  2628. br.Ret = 200
  2629. br.Success = true
  2630. br.Msg = "获取成功"
  2631. br.Data = resp
  2632. }
  2633. // @Title 报告搜索、资源包搜索接口
  2634. // @Description 报告搜索、资源包搜索接口接口
  2635. // @Param KeyWord query string true "搜索关键词"
  2636. // @Param PageSize query int true "每页数据条数"
  2637. // @Success 200 {object} models.SearchReportAndResourceResp
  2638. // @router /searchReportAndResource [get]
  2639. func (this *ReportController) SearchReportAndResource() {
  2640. br := new(models.BaseResponse).Init()
  2641. defer func() {
  2642. this.Data["json"] = br
  2643. this.ServeJSON()
  2644. }()
  2645. user := this.User
  2646. if user == nil {
  2647. br.Msg = "请重新登录"
  2648. br.Ret = 408
  2649. return
  2650. }
  2651. uid := user.UserId
  2652. keyWord := this.GetString("KeyWord")
  2653. pageSize, _ := this.GetInt("PageSize")
  2654. var condition string
  2655. var sqlGroup string
  2656. //匹配报告标题、
  2657. 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 `
  2658. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2659. if pageSize > 0 {
  2660. sqlGroup += ` LIMIT 5 `
  2661. }
  2662. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2663. if err != nil {
  2664. br.Msg = "获取信息失败"
  2665. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2666. return
  2667. }
  2668. for k, v := range ListYxReport {
  2669. ListYxReport[k].Source = 2
  2670. if v.MyCollectNum > 0 {
  2671. ListYxReport[k].IsCollect = true
  2672. }
  2673. }
  2674. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2675. if err != nil {
  2676. br.Msg = "获取信息失败"
  2677. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2678. return
  2679. }
  2680. for k, v := range ListHzReport {
  2681. ListHzReport[k].Source = 1
  2682. if v.MyCollectNum > 0 {
  2683. ListHzReport[k].IsCollect = true
  2684. }
  2685. }
  2686. if len(ListYxReport) == 0 {
  2687. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2688. }
  2689. if len(ListHzReport) == 0 {
  2690. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2691. }
  2692. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2693. if err != nil {
  2694. br.Msg = "获取失败"
  2695. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2696. return
  2697. }
  2698. fllowMap := make(map[int]int)
  2699. if len(fllowList) > 0 {
  2700. for _, v := range fllowList {
  2701. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2702. }
  2703. }
  2704. var conditionOr string
  2705. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2706. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2707. listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2708. if err != nil {
  2709. br.Msg = "获取信息失败"
  2710. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2711. return
  2712. }
  2713. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2714. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2715. listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2716. if err != nil {
  2717. br.Msg = "获取信息失败"
  2718. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2719. return
  2720. }
  2721. //合并产业关联的标的
  2722. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2723. if err != nil {
  2724. br.Msg = "获取信息失败"
  2725. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2726. return
  2727. }
  2728. industrialIdArr := make([]int, 0)
  2729. for k, v := range listHzResource {
  2730. listHzResource[k].Source = 1
  2731. if fllowMap[v.IndustrialManagementId] > 0 {
  2732. listHzResource[k].IsFollw = true
  2733. }
  2734. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2735. }
  2736. for k, v := range listYxResource {
  2737. listYxResource[k].Source = 2
  2738. if fllowMap[v.IndustrialManagementId] > 0 {
  2739. listYxResource[k].IsFollw = true
  2740. }
  2741. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2742. }
  2743. if len(industrialIdArr) > 0 {
  2744. //查询产业视频
  2745. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  2746. // 获取默认图配置
  2747. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  2748. if e != nil {
  2749. br.Msg = "获取视频默认配置图失败"
  2750. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  2751. return
  2752. }
  2753. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  2754. if err != nil {
  2755. br.Msg = "产业视频列表失败"
  2756. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  2757. return
  2758. }
  2759. for _, v := range videoList {
  2760. tmp := &models.MicroVideoSimpleInfo{
  2761. Id: v.VideoId,
  2762. Title: "5min逻辑【"+v.IndustryName+"】解析",
  2763. ResourceUrl: v.VideoUrl,
  2764. BackgroundImg: v.ImgUrl,
  2765. PlaySeconds: v.VideoDuration,
  2766. DetailImgUrl: v.DetailImgUrl,
  2767. }
  2768. if tmp.BackgroundImg == "" {
  2769. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  2770. }
  2771. industrialVideoMap[v.IndustryId] = tmp
  2772. }
  2773. for k, v := range listYxResource {
  2774. //展示产业视频
  2775. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  2776. listYxResource[k].IndustryVideo = video
  2777. }
  2778. }
  2779. for k, v := range listHzResource {
  2780. //展示产业视频
  2781. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  2782. listHzResource[k].IndustryVideo = video
  2783. }
  2784. }
  2785. //合并产业关联的标的
  2786. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2787. if err != nil {
  2788. br.Msg = "获取信息失败"
  2789. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2790. return
  2791. }
  2792. mapIndustrial := make(map[string]int)
  2793. for _, v := range listSubjcet {
  2794. for k2, v2 := range listYxResource {
  2795. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2796. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  2797. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2798. }
  2799. }
  2800. for k2, v2 := range listHzResource {
  2801. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2802. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  2803. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2804. }
  2805. }
  2806. }
  2807. }
  2808. resp := new(models.SearchReportAndResourceResp)
  2809. if len(listYxResource) == 0 {
  2810. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  2811. }
  2812. if len(listHzResource) == 0 {
  2813. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  2814. }
  2815. if keyWord != "" {
  2816. keyWordItem := new(models.CygxUserSearchKeyWord)
  2817. keyWordItem.UserId = user.UserId
  2818. keyWordItem.KeyWord = keyWord
  2819. keyWordItem.PageType = "ReortSearch"
  2820. keyWordItem.CreateTime = time.Now()
  2821. go models.AddUserSearchKeyWord(keyWordItem)
  2822. go services.AddUserSearchLog(user, keyWord, 5)
  2823. }
  2824. resp.ListHzResource = listHzResource
  2825. resp.ListYxResource = listYxResource
  2826. resp.ListYxReport = ListYxReport
  2827. resp.ListHzReport = ListHzReport
  2828. br.Ret = 200
  2829. br.Success = true
  2830. br.Msg = "获取成功"
  2831. br.Data = resp
  2832. }