report.go 95 KB

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