report.go 86 KB

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