report.go 91 KB

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