report.go 97 KB

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