report.go 78 KB

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