report.go 86 KB

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