report.go 98 KB

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