report.go 91 KB

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