report.go 88 KB

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