report.go 92 KB

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