report.go 94 KB

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