report.go 97 KB

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