report.go 84 KB

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