report.go 97 KB

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