report.go 87 KB

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