report.go 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989
  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 PageSize query int true "每页数据条数"
  77. // @Param CurrentIndex query int true "当前页页码,从1开始"
  78. // @Success 200 {object} models.IndustrialManagementList
  79. // @router /home/industryList [get]
  80. func (this *ReportController) IndustryList() {
  81. br := new(models.BaseResponse).Init()
  82. defer func() {
  83. this.Data["json"] = br
  84. this.ServeJSON()
  85. }()
  86. user := this.User
  87. if user == nil {
  88. br.Msg = "请重新登录"
  89. br.Ret = 408
  90. return
  91. }
  92. uid := user.UserId
  93. fmt.Println(uid)
  94. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  95. orderColumn := this.GetString("OrderColumn")
  96. orderColumnNew := this.GetString("OrderColumn")
  97. isNewLabel := this.GetString("IsNewLabel")
  98. isDeepLabel := this.GetString("IsDeepLabel")
  99. keyWord := this.GetString("KeyWord")
  100. pageSize, _ := this.GetInt("PageSize")
  101. currentIndex, _ := this.GetInt("CurrentIndex")
  102. var orderSrt string
  103. var condition string
  104. var startSize int
  105. resp := new(models.IndustrialManagementList)
  106. if pageSize <= 0 {
  107. pageSize = utils.PageSize20
  108. }
  109. if currentIndex <= 0 {
  110. currentIndex = 1
  111. }
  112. startSize = paging.StartIndex(currentIndex, pageSize)
  113. if isNewLabel == "1" {
  114. condition += ` AND is_new_label = ` + isNewLabel
  115. }
  116. if isDeepLabel == "1" {
  117. condition += ` AND is_deep_label = ` + isDeepLabel
  118. }
  119. if keyWord != "" {
  120. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  121. //if err != nil {
  122. // br.Msg = "获取信息失败"
  123. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  124. // return
  125. //}
  126. //var conditionkeyWord string
  127. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  128. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  129. //keyWordLen := len(keyWordArr)
  130. //if keyWordLen <= 0 {
  131. // keyWordArr = append(keyWordArr, keyWord)
  132. // keyWordLen = len(keyWordArr)
  133. //}
  134. //for _, v := range keyWordArr {
  135. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  136. //}
  137. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  138. //if err != nil {
  139. // br.Msg = "获取信息失败"
  140. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  141. // return
  142. //}
  143. //if industrialManagementIds == "" {
  144. // br.Ret = 200
  145. // br.Success = true
  146. // br.Msg = "获取成功"
  147. // br.Data = resp
  148. // return
  149. //}
  150. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  151. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  152. }
  153. var sqlChartPermissionId string
  154. if ChartPermissionId > 0 {
  155. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  156. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  157. }
  158. var list []*models.IndustrialManagement
  159. total, err := models.GetIndustrialManagementAllCount(condition)
  160. if err != nil {
  161. br.Msg = "获取信息失败"
  162. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  163. return
  164. }
  165. page := paging.GetPaging(currentIndex, pageSize, total)
  166. if orderColumn == "" {
  167. orderColumn = "NewTime"
  168. }
  169. if orderColumn == "NewTime" {
  170. orderSrt = "update_time DESC"
  171. } else {
  172. orderSrt = "man.recommended_index DESC,update_time DESC"
  173. }
  174. if ChartPermissionId == 0 {
  175. ChartPermissionId = 20
  176. }
  177. detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  178. if err != nil {
  179. br.Msg = "获取信息失败"
  180. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  181. return
  182. }
  183. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  184. if err != nil {
  185. br.Msg = "获取信息失败"
  186. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  187. return
  188. }
  189. for k, v := range list {
  190. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  191. if err != nil {
  192. br.Msg = "获取信息失败"
  193. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  194. return
  195. }
  196. list[k].IndustrialSubjectList = industrialSubjectList
  197. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  198. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  199. if err != nil {
  200. br.Msg = "获取信息失败"
  201. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  202. return
  203. }
  204. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  205. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  206. if err != nil && err.Error() != utils.ErrNoRow() {
  207. br.Msg = "获取信息失败"
  208. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  209. return
  210. }
  211. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  212. list[k].IsRed = true
  213. }
  214. if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  215. list[k].IsHot = true
  216. }
  217. }
  218. //记录用户搜索的筛选条件
  219. if orderColumnNew != "" {
  220. item := new(models.CygxReportIndustrialSeaarchHistory)
  221. item.UserId = user.UserId
  222. item.Mobile = user.Mobile
  223. item.CompanyId = user.CompanyId
  224. item.CompanyName = user.CompanyName
  225. item.CreateTime = time.Now()
  226. item.IsDeepLabel = isDeepLabel
  227. item.IsNewLabel = isNewLabel
  228. item.ChartPermissionId = ChartPermissionId
  229. if orderColumnNew == "NewTime" {
  230. item.OrderColumn = "0"
  231. } else {
  232. item.OrderColumn = "1"
  233. }
  234. go models.AddCygxReportIndustrialSeaarchHistory(item)
  235. }
  236. resp.List = list
  237. resp.Paging = page
  238. br.Ret = 200
  239. br.Success = true
  240. br.Msg = "获取成功"
  241. br.Data = resp
  242. }
  243. // @Title 产业下所关联的文章分类列表
  244. // @Description 产业下所关联的文章分类列表接口
  245. // @Param IndustrialManagementId query int true "产业ID"
  246. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  247. // @router /toArticleCategoryList [get]
  248. func (this *ReportController) ArticleCategoryList() {
  249. br := new(models.BaseResponse).Init()
  250. defer func() {
  251. this.Data["json"] = br
  252. this.ServeJSON()
  253. }()
  254. user := this.User
  255. if user == nil {
  256. br.Msg = "请重新登录"
  257. br.Ret = 408
  258. return
  259. }
  260. uid := user.UserId
  261. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  262. if industrialManagementId < 1 {
  263. br.Msg = "请输入分类ID"
  264. return
  265. }
  266. list, err := models.IndustrialToArticleCategory(industrialManagementId)
  267. if err != nil {
  268. br.Msg = "获取信息失败"
  269. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  270. return
  271. }
  272. for k, v := range list {
  273. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  274. if err != nil && err.Error() != utils.ErrNoRow() {
  275. br.Msg = "获取信息失败"
  276. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  277. return
  278. }
  279. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  280. if err != nil {
  281. br.Msg = "获取信息失败"
  282. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  283. return
  284. }
  285. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  286. list[k].IsRed = true
  287. }
  288. }
  289. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  290. if err != nil {
  291. br.Msg = "获取信息失败"
  292. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  293. return
  294. }
  295. resp := new(models.IndustrialToArticleCategoryListRep)
  296. resp.List = list
  297. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  298. resp.IndustryName = detail.IndustryName
  299. resp.IndustrialManagementId = industrialManagementId
  300. br.Ret = 200
  301. br.Success = true
  302. br.Msg = "获取成功"
  303. br.Data = resp
  304. }
  305. // @Title 产业文章列表接口
  306. // @Description 获取产业文章列表接口
  307. // @Param PageSize query int true "每页数据条数"
  308. // @Param CurrentIndex query int true "当前页页码,从1开始"
  309. // @Param CategoryId query int true "分类ID"
  310. // @Param IndustrialManagementId query int true "产业ID"
  311. // @Success 200 {object} models.TacticsListResp
  312. // @router /industry/ArticleList [get]
  313. func (this *ReportController) List() {
  314. br := new(models.BaseResponse).Init()
  315. defer func() {
  316. this.Data["json"] = br
  317. this.ServeJSON()
  318. }()
  319. user := this.User
  320. if user == nil {
  321. br.Msg = "请重新登录"
  322. br.Ret = 408
  323. return
  324. }
  325. uid := user.UserId
  326. pageSize, _ := this.GetInt("PageSize")
  327. currentIndex, _ := this.GetInt("CurrentIndex")
  328. categoryId, _ := this.GetInt("CategoryId")
  329. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  330. var startSize int
  331. if pageSize <= 0 {
  332. pageSize = utils.PageSize20
  333. }
  334. if currentIndex <= 0 {
  335. currentIndex = 1
  336. }
  337. startSize = paging.StartIndex(currentIndex, pageSize)
  338. var pars []interface{}
  339. var total int
  340. resp := new(models.TacticsListResp)
  341. page := paging.GetPaging(currentIndex, pageSize, total)
  342. if categoryId < 1 {
  343. br.Msg = "请输入分类ID"
  344. return
  345. }
  346. if industrialManagementId < 1 {
  347. br.Msg = "请输入产业ID"
  348. return
  349. }
  350. total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
  351. if err != nil {
  352. br.Msg = "获取信息失败"
  353. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  354. return
  355. }
  356. page = paging.GetPaging(currentIndex, pageSize, total)
  357. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  358. if err != nil {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  361. return
  362. }
  363. lenList := len(list)
  364. for i := 0; i < lenList; i++ {
  365. item := list[i]
  366. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  367. //list[i].Abstract = html.UnescapeString(item.Abstract)
  368. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  369. }
  370. for k, v := range list {
  371. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  372. list[k].IsRed = true
  373. }
  374. if v.VideoUrl != "" {
  375. list[k].IsHaveVideo = true
  376. }
  377. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  378. }
  379. resp.List = list
  380. resp.Paging = page
  381. br.Ret = 200
  382. br.Success = true
  383. br.Msg = "获取成功"
  384. br.Data = resp
  385. }
  386. // @Title 置顶/取消置顶
  387. // @Description 置顶
  388. // @Param request body models.CygxIndustryTopRep true "type json string"
  389. // @Success 200
  390. // @router /top [post]
  391. func (this *ReportController) ArticleCollect() {
  392. br := new(models.BaseResponse).Init()
  393. defer func() {
  394. this.Data["json"] = br
  395. this.ServeJSON()
  396. }()
  397. user := this.User
  398. if user == nil {
  399. br.Msg = "请重新登录"
  400. br.Ret = 408
  401. return
  402. }
  403. uid := user.UserId
  404. var req models.CygxIndustryTopRep
  405. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  406. if err != nil {
  407. br.Msg = "参数解析异常!"
  408. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  409. return
  410. }
  411. industrialManagementId := req.IndustrialManagementId
  412. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  413. if err != nil {
  414. br.Msg = "获取数据失败!"
  415. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  416. return
  417. }
  418. if countIndustrial == 0 {
  419. br.Msg = "产业不存在!"
  420. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  421. return
  422. }
  423. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  424. if err != nil {
  425. br.Msg = "获取数据失败!"
  426. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  427. return
  428. }
  429. resp := new(models.ArticleCollectResp)
  430. if count <= 0 {
  431. item := new(models.CygxIndustryTop)
  432. item.IndustrialManagementId = req.IndustrialManagementId
  433. item.UserId = uid
  434. item.CreateTime = time.Now()
  435. _, err = models.AddCygxIndustryTop(item)
  436. if err != nil {
  437. br.Msg = "置顶失败"
  438. br.ErrMsg = "置顶失败,Err:" + err.Error()
  439. return
  440. }
  441. br.Msg = "置顶成功"
  442. resp.Status = 1
  443. } else {
  444. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  445. if err != nil {
  446. br.Msg = "取消置顶失败"
  447. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  448. return
  449. }
  450. br.Msg = "已取消置顶"
  451. resp.Status = 2
  452. }
  453. br.Ret = 200
  454. br.Success = true
  455. br.Data = resp
  456. }
  457. // @Title 关注/取消关注产业
  458. // @Description 关注/取消关注 接口
  459. // @Param request body models.CygxIndustryFllowRep true "type json string"
  460. // @Success 200
  461. // @router /fllow [post]
  462. func (this *ReportController) Fllow() {
  463. br := new(models.BaseResponse).Init()
  464. defer func() {
  465. this.Data["json"] = br
  466. this.ServeJSON()
  467. }()
  468. user := this.User
  469. if user == nil {
  470. br.Msg = "请重新登录"
  471. br.Ret = 408
  472. return
  473. }
  474. uid := user.UserId
  475. var req models.CygxIndustryFllowRep
  476. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  477. if err != nil {
  478. br.Msg = "参数解析异常!"
  479. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  480. return
  481. }
  482. industrialManagementId := req.IndustrialManagementId
  483. var condition string
  484. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  485. if err != nil {
  486. br.Msg = "获取数据失败!"
  487. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  488. return
  489. }
  490. if countIndustrial == 0 {
  491. br.Msg = "产业不存在!"
  492. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  493. return
  494. }
  495. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  496. if err != nil {
  497. br.Msg = "获取数据失败!"
  498. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  499. return
  500. }
  501. resp := new(models.CygxIndustryFllowResp)
  502. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  503. if countUser == 0 {
  504. resp.GoFollow = true
  505. }
  506. if count == 0 {
  507. item := new(models.CygxIndustryFllow)
  508. item.IndustrialManagementId = industrialManagementId
  509. item.UserId = uid
  510. item.Email = user.Email
  511. item.Mobile = user.Mobile
  512. item.CompanyId = user.CompanyId
  513. item.CompanyName = user.CompanyName
  514. item.Type = 1
  515. item.CreateTime = time.Now()
  516. item.ModifyTime = time.Now()
  517. _, err = models.AddCygxIndustryFllow(item)
  518. if err != nil {
  519. br.Msg = "操作失败"
  520. br.ErrMsg = "操作失败,Err:" + err.Error()
  521. return
  522. }
  523. resp.Status = 1
  524. } else {
  525. var doType int
  526. condition = ` AND type = 1`
  527. count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  528. if err != nil {
  529. br.Msg = "操作失败!"
  530. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  531. return
  532. }
  533. if count == 1 {
  534. resp.Status = 2
  535. doType = 2
  536. } else {
  537. resp.Status = 1
  538. doType = 1
  539. }
  540. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
  541. if err != nil {
  542. br.Msg = "操作失败"
  543. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  544. return
  545. }
  546. }
  547. br.Msg = "操作成功"
  548. br.Ret = 200
  549. br.Success = true
  550. br.Data = resp
  551. }
  552. // @Title 产业报告分类关联作者列表接口
  553. // @Description 获取产业报告分类关联作者列表接口
  554. // @Param ChartPermissionId query int true "分类ID"
  555. // @Param PageSize query int true "每页数据条数"
  556. // @Param CurrentIndex query int true "当前页页码,从1开始"
  557. // @Success 200 {object} models.CygxArticleDepartmentList
  558. // @router /industryListByDepartment [get]
  559. func (this *ReportController) IndustryListByDepartment() {
  560. br := new(models.BaseResponse).Init()
  561. defer func() {
  562. this.Data["json"] = br
  563. this.ServeJSON()
  564. }()
  565. user := this.User
  566. if user == nil {
  567. br.Msg = "请重新登录"
  568. br.Ret = 408
  569. return
  570. }
  571. uid := user.UserId
  572. pageSize, _ := this.GetInt("PageSize")
  573. currentIndex, _ := this.GetInt("CurrentIndex")
  574. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  575. var startSize int
  576. var condition string
  577. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  578. condition = ` AND a.publish_status=1 `
  579. if pageSize <= 0 {
  580. pageSize = utils.PageSize20
  581. }
  582. if currentIndex <= 0 {
  583. currentIndex = 1
  584. }
  585. startSize = paging.StartIndex(currentIndex, pageSize)
  586. total, err := models.GetArticleDepartmentCount(condition)
  587. page := paging.GetPaging(currentIndex, pageSize, total)
  588. resp := new(models.CygxArticleDepartmentList)
  589. userType, _, err := services.GetUserType(user.CompanyId)
  590. if err != nil {
  591. br.Msg = "获取信息失败"
  592. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  593. return
  594. }
  595. if userType == 1 {
  596. resp.Paging = page
  597. br.Ret = 200
  598. br.Success = true
  599. br.Msg = "获取成功"
  600. br.Data = resp
  601. return
  602. }
  603. resp.HaveResearch = true
  604. //获取作者信息,并排序
  605. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  606. if err != nil {
  607. br.Msg = "获取信息失败"
  608. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  609. return
  610. }
  611. for k, v := range list {
  612. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  613. if err != nil {
  614. br.Msg = "获取信息失败"
  615. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  616. return
  617. }
  618. for k2, v2 := range artList {
  619. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  620. if err != nil {
  621. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  622. br.ErrMsg = "获取失败,Err:" + err.Error()
  623. return
  624. }
  625. var subjectNamesNew string
  626. if len(subjectNames) > 0 {
  627. slice := strings.Split(subjectNames, "/")
  628. for k3, v3 := range slice {
  629. if k3 < 4 {
  630. subjectNamesNew += v3 + "/"
  631. }
  632. }
  633. }
  634. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  635. if err != nil && err.Error() != utils.ErrNoRow() {
  636. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  637. br.ErrMsg = "获取失败,Err:" + err.Error()
  638. return
  639. }
  640. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  641. artList[k2].SubjectName = subjectNamesNew
  642. artList[k2].DepartmentId = v.DepartmentId
  643. if subjectNamesNew == "" {
  644. artList[k2].IndustryName = industryName
  645. } else {
  646. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  647. }
  648. if artList[k2].IsReport == "1" {
  649. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  650. } else {
  651. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  652. }
  653. }
  654. list[k].List = artList
  655. if v.FollowNum > 0 {
  656. list[k].IsMyFollow = true
  657. }
  658. }
  659. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  660. if err != nil {
  661. br.Msg = "获取信息失败"
  662. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  663. return
  664. }
  665. if len(listnNew) > 0 {
  666. for _, v := range listnNew {
  667. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  668. Management := new(models.IndustrialManagementIdInt)
  669. if firstStr == 0 {
  670. Management.IndustryName = v.IndustryName
  671. } else {
  672. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  673. if err != nil {
  674. br.Msg = "获取信息失败"
  675. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  676. return
  677. }
  678. var subjectNamesNew string
  679. for _, v1 := range listSub {
  680. subjectNamesNew += v1.SubjectName + "/"
  681. }
  682. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  683. Management.IndustryName = subjectNamesNew
  684. }
  685. Management.IndustrialManagementId = v.IndustrialManagementId
  686. Management.ArticleId = v.ArticleId
  687. resp.ListnNew = append(resp.ListnNew, Management)
  688. }
  689. }
  690. resp.List = list
  691. resp.Paging = page
  692. br.Ret = 200
  693. br.Success = true
  694. br.Msg = "获取成功"
  695. br.Data = resp
  696. }
  697. // @Title 关注作者/取消关注作者
  698. // @Description 关注作者/取消关注作者 接口
  699. // @Param request body models.CygxArticleDepartmentId true "type json string"
  700. // @Success 200
  701. // @router /fllowDepartment [post]
  702. func (this *ReportController) FllowDepartment() {
  703. br := new(models.BaseResponse).Init()
  704. defer func() {
  705. this.Data["json"] = br
  706. this.ServeJSON()
  707. }()
  708. user := this.User
  709. if user == nil {
  710. br.Msg = "请重新登录"
  711. br.Ret = 408
  712. return
  713. }
  714. uid := user.UserId
  715. var req models.CygxArticleDepartmentId
  716. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  717. if err != nil {
  718. br.Msg = "参数解析异常!"
  719. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  720. return
  721. }
  722. departmentId := req.DepartmentId
  723. var condition string
  724. countDepartment, err := models.GetDepartmentCount(departmentId)
  725. if err != nil {
  726. br.Msg = "获取数据失败!"
  727. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  728. return
  729. }
  730. if countDepartment == 0 {
  731. br.Msg = "作者不存在!"
  732. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  733. return
  734. }
  735. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  736. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  737. if err != nil {
  738. br.Msg = "获取数据失败!"
  739. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  740. return
  741. }
  742. resp := new(models.CygxArticleDepartmentFollowResp)
  743. if countUser == 0 {
  744. resp.GoFollow = true
  745. }
  746. if count == 0 {
  747. item := new(models.CygxArticleDepartmentFollow)
  748. item.DepartmentId = departmentId
  749. item.UserId = uid
  750. item.Email = user.Email
  751. item.Mobile = user.Mobile
  752. item.CompanyId = user.CompanyId
  753. item.CompanyName = user.CompanyName
  754. item.Type = 1
  755. item.CreateTime = time.Now()
  756. item.ModifyTime = time.Now()
  757. _, err = models.AddArticleDepartmentFollow(item)
  758. if err != nil {
  759. br.Msg = "操作失败"
  760. br.ErrMsg = "操作失败,Err:" + err.Error()
  761. return
  762. }
  763. resp.Status = 1
  764. } else {
  765. var doType int
  766. condition = ` AND type = 1`
  767. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  768. if err != nil {
  769. br.Msg = "操作失败!"
  770. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  771. return
  772. }
  773. if count == 1 {
  774. resp.Status = 2
  775. doType = 2
  776. } else {
  777. resp.Status = 1
  778. doType = 1
  779. }
  780. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  781. if err != nil {
  782. br.Msg = "操作失败"
  783. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  784. return
  785. }
  786. }
  787. br.Msg = "操作成功"
  788. br.Ret = 200
  789. br.Success = true
  790. br.Data = resp
  791. }
  792. // @Title 研选文章列表接口
  793. // @Description 获取研选文章列表接口
  794. // @Param PageSize query int true "每页数据条数"
  795. // @Param CurrentIndex query int true "当前页页码,从1开始"
  796. // @Param ArticleId query int true "文章id"
  797. // @Param DepartmentId query int true "作者ID"
  798. // @Param IndustrialManagementId query int true "产业ID"
  799. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  800. // @router /industry/reportList [get]
  801. func (this *ReportController) ReportList() {
  802. br := new(models.BaseResponse).Init()
  803. defer func() {
  804. this.Data["json"] = br
  805. this.ServeJSON()
  806. }()
  807. user := this.User
  808. if user == nil {
  809. br.Msg = "请重新登录"
  810. br.Ret = 408
  811. return
  812. }
  813. uid := user.UserId
  814. pageSize, _ := this.GetInt("PageSize")
  815. currentIndex, _ := this.GetInt("CurrentIndex")
  816. departmentId, _ := this.GetInt("DepartmentId")
  817. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  818. articleId, _ := this.GetInt("ArticleId")
  819. var condition string
  820. var startSize int
  821. if pageSize <= 0 {
  822. pageSize = utils.PageSize20
  823. }
  824. if currentIndex <= 0 {
  825. currentIndex = 1
  826. }
  827. startSize = paging.StartIndex(currentIndex, pageSize)
  828. var pars []interface{}
  829. var total int
  830. resp := new(models.ReportArticleWhichIndustrialRepList)
  831. page := paging.GetPaging(currentIndex, pageSize, total)
  832. userType, _, err := services.GetUserType(user.CompanyId)
  833. if err != nil {
  834. br.Msg = "获取信息失败"
  835. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  836. return
  837. }
  838. if userType == 1 {
  839. resp.Paging = page
  840. br.Ret = 200
  841. br.Success = true
  842. br.Msg = "获取成功"
  843. br.Data = resp
  844. return
  845. }
  846. resp.HaveResearch = true
  847. if departmentId > 0 {
  848. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  849. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  850. if err != nil {
  851. br.Msg = "获取信息失败"
  852. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  853. return
  854. }
  855. resp.NickName = detail.NickName
  856. }
  857. if industrialManagementId > 0 {
  858. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  859. }
  860. if articleId > 0 {
  861. detail, err := models.GetArticleDetailById(articleId)
  862. if err != nil {
  863. br.Msg = "获取信息失败"
  864. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  865. return
  866. }
  867. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  868. }
  869. total, err = models.GetWhichDepartmentCount(condition)
  870. if err != nil {
  871. br.Msg = "获取信息失败"
  872. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  873. return
  874. }
  875. page = paging.GetPaging(currentIndex, pageSize, total)
  876. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  877. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  878. if err != nil {
  879. br.Msg = "获取失败"
  880. br.ErrMsg = "获取失败,Err:" + err.Error()
  881. return
  882. }
  883. for k, v := range list {
  884. if v.Readnum == 0 {
  885. list[k].IsRed = true
  886. }
  887. list[k].IsResearch = true
  888. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  889. if err != nil {
  890. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  891. br.ErrMsg = "获取失败,Err:" + err.Error()
  892. return
  893. }
  894. var subjectNamesNew string
  895. if len(subjectNames) > 0 {
  896. slice := strings.Split(subjectNames, "/")
  897. for k3, v3 := range slice {
  898. if k3 < 4 {
  899. subjectNamesNew += v3 + "/"
  900. }
  901. }
  902. }
  903. industryName, err := models.GetIndustrialNames(v.ArticleId)
  904. if err != nil && err.Error() != utils.ErrNoRow() {
  905. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  906. br.ErrMsg = "获取失败,Err:" + err.Error()
  907. return
  908. }
  909. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  910. list[k].SubjectName = subjectNamesNew
  911. if subjectNamesNew != "" {
  912. list[k].IndustryName = industryName + "-" + subjectNamesNew
  913. } else {
  914. list[k].IndustryName = industryName
  915. }
  916. resp.IndustryName = industryName
  917. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  918. }
  919. resp.List = list
  920. resp.Paging = page
  921. br.Ret = 200
  922. br.Success = true
  923. br.Msg = "获取成功"
  924. br.Data = resp
  925. }
  926. // @Title 研选最新主题关键词文章列表接口
  927. // @Description 获取研选最新主题关键词文章列表接口
  928. // @Param PageSize query int true "每页数据条数"
  929. // @Param CurrentIndex query int true "当前页页码,从1开始"
  930. // @Param ArticleId query int true "文章id"
  931. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  932. // @router /industry/reportListNew [get]
  933. func (this *ReportController) ReportListNew() {
  934. br := new(models.BaseResponse).Init()
  935. defer func() {
  936. this.Data["json"] = br
  937. this.ServeJSON()
  938. }()
  939. user := this.User
  940. if user == nil {
  941. br.Msg = "请重新登录"
  942. br.Ret = 408
  943. return
  944. }
  945. uid := user.UserId
  946. pageSize, _ := this.GetInt("PageSize")
  947. currentIndex, _ := this.GetInt("CurrentIndex")
  948. articleId, _ := this.GetInt("ArticleId")
  949. var condition string
  950. var startSize int
  951. if pageSize <= 0 {
  952. pageSize = utils.PageSize20
  953. }
  954. if currentIndex <= 0 {
  955. currentIndex = 1
  956. }
  957. startSize = paging.StartIndex(currentIndex, pageSize)
  958. var pars []interface{}
  959. var total int
  960. resp := new(models.ReportArticleWhichIndustrialRepList)
  961. page := paging.GetPaging(currentIndex, pageSize, total)
  962. userType, _, err := services.GetUserType(user.CompanyId)
  963. if err != nil {
  964. br.Msg = "获取信息失败"
  965. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  966. return
  967. }
  968. if userType == 1 {
  969. resp.Paging = page
  970. br.Ret = 200
  971. br.Success = true
  972. br.Msg = "获取成功"
  973. br.Data = resp
  974. return
  975. }
  976. resp.HaveResearch = true
  977. if articleId > 0 {
  978. detail, err := models.GetArticleDetailById(articleId)
  979. if err != nil {
  980. br.Msg = "获取信息失败"
  981. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  982. return
  983. }
  984. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  985. if firstStr == 0 {
  986. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  987. } else {
  988. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  989. }
  990. }
  991. total, err = models.GetWhichDepartmentCount(condition)
  992. if err != nil {
  993. br.Msg = "获取信息失败"
  994. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  995. return
  996. }
  997. page = paging.GetPaging(currentIndex, pageSize, total)
  998. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  999. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1000. if err != nil {
  1001. br.Msg = "获取失败"
  1002. br.ErrMsg = "获取失败,Err:" + err.Error()
  1003. return
  1004. }
  1005. for k, v := range list {
  1006. if v.Readnum == 0 {
  1007. list[k].IsRed = true
  1008. }
  1009. list[k].IsResearch = true
  1010. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1011. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1012. if err != nil {
  1013. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1014. br.ErrMsg = "获取失败,Err:" + err.Error()
  1015. return
  1016. }
  1017. var subjectNamesNew string
  1018. if len(subjectNames) > 0 {
  1019. slice := strings.Split(subjectNames, "/")
  1020. for k3, v3 := range slice {
  1021. if k3 < 4 {
  1022. subjectNamesNew += v3 + "/"
  1023. }
  1024. }
  1025. }
  1026. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1027. if err != nil && err.Error() != utils.ErrNoRow() {
  1028. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1029. br.ErrMsg = "获取失败,Err:" + err.Error()
  1030. return
  1031. }
  1032. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1033. list[k].SubjectName = subjectNamesNew
  1034. if subjectNamesNew != "" {
  1035. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1036. } else {
  1037. list[k].IndustryName = industryName
  1038. }
  1039. resp.IndustryName = industryName
  1040. }
  1041. resp.List = list
  1042. resp.Paging = page
  1043. br.Ret = 200
  1044. br.Success = true
  1045. br.Msg = "获取成功"
  1046. br.Data = resp
  1047. }
  1048. // @Title 是否展示绝密内参
  1049. // @Description 获取是否展示绝密内参接口
  1050. // @Param request body models.IsShow true "type json string"
  1051. // @Success 200
  1052. // @router /isShow [get]
  1053. func (this *ReportController) IsShow() {
  1054. br := new(models.BaseResponse).Init()
  1055. defer func() {
  1056. this.Data["json"] = br
  1057. this.ServeJSON()
  1058. }()
  1059. user := this.User
  1060. if user == nil {
  1061. br.Msg = "请重新登录"
  1062. br.Ret = 408
  1063. return
  1064. }
  1065. var resp models.IsShow
  1066. mobile := user.Mobile
  1067. if mobile == "" {
  1068. br.Ret = 200
  1069. br.Success = true
  1070. br.Data = resp
  1071. return
  1072. }
  1073. total, _ := models.GetUserIsAdminCount(mobile)
  1074. if total > 0 {
  1075. resp.IsShow = true
  1076. }
  1077. br.Ret = 200
  1078. br.Success = true
  1079. br.Data = resp
  1080. }
  1081. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1082. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1083. // @Param PageSize query int true "每页数据条数"
  1084. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1085. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1086. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1087. // @router /reportList/byType [get]
  1088. func (this *ReportController) ReportListByType() {
  1089. br := new(models.BaseResponse).Init()
  1090. defer func() {
  1091. this.Data["json"] = br
  1092. this.ServeJSON()
  1093. }()
  1094. user := this.User
  1095. if user == nil {
  1096. br.Msg = "请重新登录"
  1097. br.Ret = 408
  1098. return
  1099. }
  1100. uid := user.UserId
  1101. pageSize, _ := this.GetInt("PageSize")
  1102. currentIndex, _ := this.GetInt("CurrentIndex")
  1103. reportType := this.GetString("ReportType")
  1104. var condition string
  1105. var startSize int
  1106. if pageSize <= 0 {
  1107. pageSize = utils.PageSize20
  1108. }
  1109. if currentIndex <= 0 {
  1110. currentIndex = 1
  1111. }
  1112. startSize = paging.StartIndex(currentIndex, pageSize)
  1113. var pars []interface{}
  1114. var total int
  1115. resp := new(models.CygxReportSelectionListPublicRep)
  1116. page := paging.GetPaging(currentIndex, pageSize, total)
  1117. var tbdb string
  1118. var readSql string
  1119. var reportTypeStr string
  1120. if reportType == "1" {
  1121. tbdb = "cygx_report_selection"
  1122. reportTypeStr = "bgjx"
  1123. } else if reportType == "2" {
  1124. tbdb = "cygx_research_summary"
  1125. reportTypeStr = "bzyjhz"
  1126. } else if reportType == "3" {
  1127. tbdb = "cygx_minutes_summary"
  1128. reportTypeStr = "szjyhz"
  1129. } else {
  1130. br.Msg = "请选择报告类型"
  1131. return
  1132. }
  1133. fmt.Println(tbdb)
  1134. condition = ` AND publish_status = 1`
  1135. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1136. if err != nil {
  1137. br.Msg = "获取信息失败"
  1138. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1139. return
  1140. }
  1141. 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`
  1142. page = paging.GetPaging(currentIndex, pageSize, total)
  1143. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1144. if err != nil {
  1145. br.Msg = "获取失败"
  1146. br.ErrMsg = "获取失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. for k, v := range list {
  1150. if reportType == "1" {
  1151. list[k].Abstract = v.UpdateDescription
  1152. }
  1153. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1154. if v.ReadNum == 0 {
  1155. list[k].IsRed = true
  1156. }
  1157. }
  1158. resp.List = list
  1159. resp.Paging = page
  1160. br.Ret = 200
  1161. br.Success = true
  1162. br.Msg = "获取成功"
  1163. br.Data = resp
  1164. }
  1165. // @Title 获取报告精选详情
  1166. // @Description 获取报告精选详情接口
  1167. // @Param ArticleId query int true "报告ID"
  1168. // @Success 200 {object} models.ReportSelectionLetailResp
  1169. // @router /reportSelection/detail [get]
  1170. func (this *ReportController) Detail() {
  1171. br := new(models.BaseResponse).Init()
  1172. defer func() {
  1173. this.Data["json"] = br
  1174. this.ServeJSON()
  1175. }()
  1176. user := this.User
  1177. if user == nil {
  1178. br.Msg = "请重新登录"
  1179. br.Ret = 408
  1180. return
  1181. }
  1182. uid := user.UserId
  1183. articleId, _ := this.GetInt("ArticleId")
  1184. if articleId < 0 {
  1185. br.Msg = "参数错误"
  1186. br.ErrMsg = "参数错误"
  1187. return
  1188. }
  1189. resp := new(models.ReportSelectionLetailResp)
  1190. //判断用户权限
  1191. hasPermission, err := services.GetUserhasPermission(user)
  1192. if err != nil {
  1193. br.Msg = "获取信息失败"
  1194. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1195. }
  1196. resp.HasPermission = hasPermission
  1197. if hasPermission != 1 {
  1198. br.Ret = 200
  1199. br.Success = true
  1200. br.Msg = "获取成功"
  1201. br.Data = resp
  1202. return
  1203. }
  1204. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1205. if err != nil {
  1206. br.Msg = "获取信息失败"
  1207. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1208. return
  1209. }
  1210. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1211. existMap := make(map[int]int)
  1212. var items []*models.ReportSelectionChartPermission
  1213. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1214. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1215. if err != nil {
  1216. br.Msg = "获取失败"
  1217. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1218. return
  1219. }
  1220. //var itemLogs []*models.CygxReportSelectionLogDetail
  1221. for _, v := range listLog {
  1222. item := new(models.ReportSelectionChartPermission)
  1223. if existMap[v.ChartPermissionId] == 0 {
  1224. item.PermissionName = v.PermissionName + "领域深度调研和报告"
  1225. item.IcoLink = v.IcoLink
  1226. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1227. if err != nil && err.Error() != utils.ErrNoRow() {
  1228. br.Msg = "获取信息失败"
  1229. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1230. return
  1231. }
  1232. for k2, v2 := range listSonLog {
  1233. if v2.IndustrialManagementId != "" {
  1234. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1235. if err != nil && err.Error() != utils.ErrNoRow() {
  1236. br.Msg = "获取信息失败"
  1237. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1238. return
  1239. }
  1240. listSonLog[k2].List = listIndustrial
  1241. }
  1242. }
  1243. item.List = listSonLog
  1244. items = append(items, item)
  1245. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1246. }
  1247. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1248. }
  1249. historyRecord := new(models.CygxReportHistoryRecord)
  1250. historyRecord.UserId = uid
  1251. historyRecord.ArticleId = articleId
  1252. historyRecord.CreateTime = time.Now()
  1253. historyRecord.Mobile = user.Mobile
  1254. historyRecord.Email = user.Email
  1255. historyRecord.CompanyId = user.CompanyId
  1256. historyRecord.CompanyName = user.CompanyName
  1257. historyRecord.ReportType = "bgjx"
  1258. go models.AddCygxReportHistoryRecord(historyRecord)
  1259. resp.List = items
  1260. resp.Detail = detail
  1261. br.Ret = 200
  1262. br.Success = true
  1263. br.Msg = "获取成功"
  1264. br.Data = resp
  1265. }
  1266. // @Title 获取本周研究汇总详情
  1267. // @Description 获取本周研究汇总详情接口
  1268. // @Param ArticleId query int true "报告ID"
  1269. // @Success 200 {object} models.ResearchSummaryLetailResp
  1270. // @router /researchSummary/detail [get]
  1271. func (this *ReportController) ResearchDetail() {
  1272. br := new(models.BaseResponse).Init()
  1273. defer func() {
  1274. this.Data["json"] = br
  1275. this.ServeJSON()
  1276. }()
  1277. user := this.User
  1278. if user == nil {
  1279. br.Msg = "请重新登录"
  1280. br.Ret = 408
  1281. return
  1282. }
  1283. uid := user.UserId
  1284. articleId, _ := this.GetInt("ArticleId")
  1285. if articleId < 0 {
  1286. br.Msg = "参数错误"
  1287. br.ErrMsg = "参数错误"
  1288. return
  1289. }
  1290. resp := new(models.ResearchSummaryLetailResp)
  1291. //判断用户权限
  1292. hasPermission, err := services.GetUserhasPermission(user)
  1293. if err != nil {
  1294. br.Msg = "获取信息失败"
  1295. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1296. }
  1297. resp.HasPermission = hasPermission
  1298. if hasPermission != 1 {
  1299. br.Ret = 200
  1300. br.Success = true
  1301. br.Msg = "获取成功"
  1302. br.Data = resp
  1303. return
  1304. }
  1305. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1306. if err != nil {
  1307. br.Msg = "获取信息失败"
  1308. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1309. return
  1310. }
  1311. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1312. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1313. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1314. if err != nil {
  1315. br.Msg = "获取失败"
  1316. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1317. return
  1318. }
  1319. for k, v := range listFirst {
  1320. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1321. if err != nil && err.Error() != utils.ErrNoRow() {
  1322. br.Msg = "获取信息失败"
  1323. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1324. return
  1325. }
  1326. for k2, v2 := range listSecond {
  1327. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1328. if err != nil && err.Error() != utils.ErrNoRow() {
  1329. br.Msg = "获取信息失败"
  1330. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1331. return
  1332. }
  1333. if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1334. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1335. listSecond[k2].PermissionName = "研选纪要"
  1336. } else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1337. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1338. listSecond[k2].PermissionName = "研选观点"
  1339. }
  1340. if len(listThird) > 0 {
  1341. for k3, v3 := range listThird {
  1342. if v3.VideoUrl != "" {
  1343. listThird[k3].IsHaveVideo = true
  1344. }
  1345. if v3.ReportLink == "0" {
  1346. listThird[k3].ReportLink = ""
  1347. }
  1348. }
  1349. listSecond[k2].List = listThird
  1350. }
  1351. }
  1352. if len(listSecond) > 0 {
  1353. listFirst[k].List = listSecond
  1354. }
  1355. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1356. if v.Type == "SDBG" {
  1357. listFirst[k].ListName = "深度报告"
  1358. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1359. } else if v.Type == "BZCHJH" {
  1360. listFirst[k].ListName = "本周晨会精华"
  1361. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1362. } else if v.Type == "CYDYJY" {
  1363. listFirst[k].ListName = "产业调研纪要"
  1364. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1365. } else if v.Type == "SSGS" {
  1366. listFirst[k].ListName = "上市公司调研纪要篇"
  1367. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1368. } else if v.Type == "SJDP" {
  1369. listFirst[k].ListName = "事件点评"
  1370. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1371. } else if v.Type == "YANX" {
  1372. listFirst[k].ListName = "研选"
  1373. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1374. }
  1375. }
  1376. historyRecord := new(models.CygxReportHistoryRecord)
  1377. historyRecord.UserId = uid
  1378. historyRecord.ArticleId = articleId
  1379. historyRecord.CreateTime = time.Now()
  1380. historyRecord.Mobile = user.Mobile
  1381. historyRecord.Email = user.Email
  1382. historyRecord.CompanyId = user.CompanyId
  1383. historyRecord.CompanyName = user.CompanyName
  1384. historyRecord.ReportType = "bzyjhz"
  1385. go models.AddCygxReportHistoryRecord(historyRecord)
  1386. resp.List = listFirst
  1387. resp.Detail = detail
  1388. br.Ret = 200
  1389. br.Success = true
  1390. br.Msg = "获取成功"
  1391. br.Data = resp
  1392. }
  1393. // @Title 上周纪要汇总内容详情
  1394. // @Description 获取上周纪要汇总内容详情接口
  1395. // @Param ArticleId query int true "报告ID"
  1396. // @Success 200 {object} models.MinutesSummaryLetailResp
  1397. // @router /minutesSummary/detailv4 [get]
  1398. func (this *ReportController) MinutesDetailV4() {
  1399. br := new(models.BaseResponse).Init()
  1400. defer func() {
  1401. this.Data["json"] = br
  1402. this.ServeJSON()
  1403. }()
  1404. user := this.User
  1405. if user == nil {
  1406. br.Msg = "请重新登录"
  1407. br.Ret = 408
  1408. return
  1409. }
  1410. uid := user.UserId
  1411. articleId, _ := this.GetInt("ArticleId")
  1412. if articleId < 0 {
  1413. br.Msg = "参数错误"
  1414. br.ErrMsg = "参数错误"
  1415. return
  1416. }
  1417. resp := new(models.MinutesSummaryLetailRespV4)
  1418. //判断用户权限
  1419. hasPermission, err := services.GetUserhasPermission(user)
  1420. if err != nil {
  1421. br.Msg = "获取信息失败"
  1422. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1423. }
  1424. resp.HasPermission = hasPermission
  1425. if hasPermission != 1 {
  1426. br.Ret = 200
  1427. br.Success = true
  1428. br.Msg = "获取成功"
  1429. br.Data = resp
  1430. return
  1431. }
  1432. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1433. if err != nil {
  1434. br.Msg = "获取信息失败"
  1435. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1436. return
  1437. }
  1438. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1439. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1440. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1441. if err != nil {
  1442. br.Msg = "获取失败"
  1443. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1444. return
  1445. }
  1446. for k, v := range listFirst {
  1447. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1448. if err != nil && err.Error() != utils.ErrNoRow() {
  1449. br.Msg = "获取信息失败"
  1450. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1451. return
  1452. }
  1453. for k2, v2 := range listSecond {
  1454. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1455. if err != nil && err.Error() != utils.ErrNoRow() {
  1456. br.Msg = "获取信息失败"
  1457. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1458. return
  1459. }
  1460. if len(listThird) > 0 {
  1461. for k3, v3 := range listThird {
  1462. if v3.VideoUrl != "" {
  1463. listThird[k3].IsHaveVideo = true
  1464. }
  1465. if v3.ReportLink == "0" {
  1466. listThird[k3].ReportLink = ""
  1467. }
  1468. }
  1469. listSecond[k2].List = listThird
  1470. }
  1471. }
  1472. if len(listSecond) > 0 {
  1473. listFirst[k].List = listSecond
  1474. }
  1475. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1476. if v.Type == "CYDYJY" {
  1477. listFirst[k].ListName = "产业调研纪要"
  1478. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1479. } else if v.Type == "SSGS" {
  1480. listFirst[k].ListName = "上市公司调研纪要篇"
  1481. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1482. } else if v.Type == "YANX" {
  1483. listFirst[k].ListName = "研选纪要"
  1484. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1485. }
  1486. }
  1487. historyRecord := new(models.CygxReportHistoryRecord)
  1488. historyRecord.UserId = uid
  1489. historyRecord.ArticleId = articleId
  1490. historyRecord.CreateTime = time.Now()
  1491. historyRecord.Mobile = user.Mobile
  1492. historyRecord.Email = user.Email
  1493. historyRecord.CompanyId = user.CompanyId
  1494. historyRecord.CompanyName = user.CompanyName
  1495. historyRecord.ReportType = "szjyhz"
  1496. go models.AddCygxReportHistoryRecord(historyRecord)
  1497. resp.List = listFirst
  1498. resp.Detail = detail
  1499. br.Ret = 200
  1500. br.Success = true
  1501. br.Msg = "获取成功"
  1502. br.Data = resp
  1503. }
  1504. // @Title 上周纪要汇总内容详情
  1505. // @Description 获取上周纪要汇总内容详情接口
  1506. // @Param ArticleId query int true "报告ID"
  1507. // @Success 200 {object} models.MinutesSummaryLetailResp
  1508. // @router /minutesSummary/detail [get]
  1509. func (this *ReportController) MinutesDetail() {
  1510. br := new(models.BaseResponse).Init()
  1511. defer func() {
  1512. this.Data["json"] = br
  1513. this.ServeJSON()
  1514. }()
  1515. user := this.User
  1516. if user == nil {
  1517. br.Msg = "请重新登录"
  1518. br.Ret = 408
  1519. return
  1520. }
  1521. uid := user.UserId
  1522. articleId, _ := this.GetInt("ArticleId")
  1523. if articleId < 0 {
  1524. br.Msg = "参数错误"
  1525. br.ErrMsg = "参数错误"
  1526. return
  1527. }
  1528. resp := new(models.MinutesSummaryLetailResp)
  1529. //判断用户权限
  1530. hasPermission, err := services.GetUserhasPermission(user)
  1531. if err != nil {
  1532. br.Msg = "获取信息失败"
  1533. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1534. }
  1535. resp.HasPermission = hasPermission
  1536. if hasPermission != 1 {
  1537. br.Ret = 200
  1538. br.Success = true
  1539. br.Msg = "获取成功"
  1540. br.Data = resp
  1541. return
  1542. }
  1543. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1544. if err != nil {
  1545. br.Msg = "获取信息失败"
  1546. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1547. return
  1548. }
  1549. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1550. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1551. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1552. if err != nil {
  1553. br.Msg = "获取失败"
  1554. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1555. return
  1556. }
  1557. for k, v := range listLog {
  1558. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1559. if err != nil && err.Error() != utils.ErrNoRow() {
  1560. br.Msg = "获取信息失败"
  1561. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1562. return
  1563. }
  1564. if len(listSonLog) > 0 {
  1565. listLog[k].List = listSonLog
  1566. for k2, v2 := range listSonLog {
  1567. if v2.ReportLink == "0" {
  1568. listSonLog[k2].ReportLink = ""
  1569. }
  1570. }
  1571. }
  1572. }
  1573. historyRecord := new(models.CygxReportHistoryRecord)
  1574. historyRecord.UserId = uid
  1575. historyRecord.ArticleId = articleId
  1576. historyRecord.CreateTime = time.Now()
  1577. historyRecord.Mobile = user.Mobile
  1578. historyRecord.Email = user.Email
  1579. historyRecord.CompanyId = user.CompanyId
  1580. historyRecord.CompanyName = user.CompanyName
  1581. historyRecord.ReportType = "szjyhz"
  1582. go models.AddCygxReportHistoryRecord(historyRecord)
  1583. resp.List = listLog
  1584. resp.Detail = detail
  1585. br.Ret = 200
  1586. br.Success = true
  1587. br.Msg = "获取成功"
  1588. br.Data = resp
  1589. }
  1590. // @Title 获取路演精华详情
  1591. // @Description 获取路演精华详情接口
  1592. // @Param ArticleId query int true "报告ID"
  1593. // @Success 200 {object} models.RoadshowDetailResp
  1594. // @router /roadshowEssence/detail [get]
  1595. func (this *ReportController) RoadshowDetail() {
  1596. br := new(models.BaseResponse).Init()
  1597. defer func() {
  1598. this.Data["json"] = br
  1599. this.ServeJSON()
  1600. }()
  1601. user := this.User
  1602. if user == nil {
  1603. br.Msg = "请登录"
  1604. br.ErrMsg = "请登录,用户信息为空"
  1605. br.Ret = 408
  1606. return
  1607. }
  1608. uid := user.UserId
  1609. articleId, err := this.GetInt("ArticleId")
  1610. if articleId <= 0 {
  1611. br.Msg = "文章不存在"
  1612. br.ErrMsg = "文章不存在,文章ID错误"
  1613. return
  1614. }
  1615. detail := new(models.ReportDetailRoadshow)
  1616. hasPermission := 0
  1617. hasFree := 0
  1618. //判断是否已经申请过
  1619. applyCount, err := models.GetApplyRecordCount(uid)
  1620. if err != nil && err.Error() != utils.ErrNoRow() {
  1621. br.Msg = "获取信息失败"
  1622. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1623. return
  1624. }
  1625. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1626. if user.CompanyId > 1 {
  1627. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1628. if err != nil {
  1629. br.Msg = "获取信息失败"
  1630. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1631. return
  1632. }
  1633. detail, err = models.GetReportRoadshowDetailById(articleId)
  1634. if err != nil {
  1635. br.Msg = "获取信息失败"
  1636. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1637. return
  1638. }
  1639. detail.Body = html.UnescapeString(detail.Body)
  1640. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1641. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1642. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1643. if detail.ReportLink == "0" {
  1644. detail.ReportLink = ""
  1645. }
  1646. if companyPermission == "" {
  1647. if applyCount > 0 {
  1648. hasPermission = 5
  1649. } else {
  1650. hasPermission = 2
  1651. }
  1652. hasFree = 2
  1653. goto Loop
  1654. } else {
  1655. hasFree = 1
  1656. var articlePermissionPermissionName string
  1657. articlePermissionPermissionName = detail.CategoryName
  1658. var hasPersion bool
  1659. slice := strings.Split(articlePermissionPermissionName, ",")
  1660. for _, v := range slice {
  1661. if strings.Contains(companyPermission, v) {
  1662. hasPersion = true
  1663. }
  1664. }
  1665. if hasPersion {
  1666. hasPermission = 1
  1667. historyRecord := new(models.CygxArticleHistoryRecord)
  1668. historyRecord.UserId = uid
  1669. historyRecord.ArticleId = articleId
  1670. historyRecord.CreateTime = time.Now()
  1671. historyRecord.Mobile = user.Mobile
  1672. historyRecord.Email = user.Email
  1673. historyRecord.CompanyId = user.CompanyId
  1674. historyRecord.CompanyName = user.CompanyName
  1675. go models.AddCygxArticleHistoryRecord(historyRecord)
  1676. } else { //无该行业权限
  1677. hasPermission = 3
  1678. }
  1679. if hasPermission == 1 {
  1680. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1681. if !utils.Rc.IsExist(key) {
  1682. //新增浏览记录
  1683. record := new(models.CygxArticleViewRecord)
  1684. record.UserId = uid
  1685. record.ArticleId = articleId
  1686. record.CreateTime = time.Now()
  1687. record.Mobile = user.Mobile
  1688. record.Email = user.Email
  1689. record.CompanyId = user.CompanyId
  1690. record.CompanyName = user.CompanyName
  1691. go models.AddCygxArticleViewRecord(record)
  1692. utils.Rc.Put(key, 1, 5*time.Second)
  1693. models.ModifyReportLastViewTime(uid)
  1694. }
  1695. }
  1696. }
  1697. } else { //潜在客户
  1698. if applyCount > 0 {
  1699. hasPermission = 5
  1700. } else {
  1701. hasPermission = 4
  1702. }
  1703. }
  1704. Loop:
  1705. if hasPermission != 1 {
  1706. detail.Body = ""
  1707. detail.Abstract = ""
  1708. }
  1709. resp := new(models.RoadshowDetailResp)
  1710. resp.HasPermission = hasPermission
  1711. resp.HasFree = hasFree
  1712. resp.Detail = detail
  1713. br.Ret = 200
  1714. br.Success = true
  1715. br.Msg = "获取成功"
  1716. br.Data = resp
  1717. }
  1718. // @Title 产业文章列表接口
  1719. // @Description 获取产业文章列表接口
  1720. // @Param KeyWord query string true "搜索关键词"
  1721. // @Success 200 {object} models.CygxIndustrySearchList
  1722. // @router /industryAndArticle/list [get]
  1723. func (this *ReportController) IndustryAndArticleList() {
  1724. br := new(models.BaseResponse).Init()
  1725. defer func() {
  1726. this.Data["json"] = br
  1727. this.ServeJSON()
  1728. }()
  1729. user := this.User
  1730. if user == nil {
  1731. br.Msg = "请重新登录"
  1732. br.Ret = 408
  1733. return
  1734. }
  1735. uid := user.UserId
  1736. keyWord := this.GetString("KeyWord")
  1737. orderSrt := "update_time DESC"
  1738. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1739. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1740. if err != nil {
  1741. br.Msg = "获取信息失败"
  1742. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1743. return
  1744. }
  1745. for k, v := range list {
  1746. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1747. if err != nil {
  1748. br.Msg = "获取信息失败"
  1749. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1750. return
  1751. }
  1752. list[k].IndustrialSubjectList = industrialSubjectList
  1753. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1754. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1755. if err != nil {
  1756. br.Msg = "获取信息失败"
  1757. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1758. return
  1759. }
  1760. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1761. }
  1762. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1763. if err != nil {
  1764. br.Msg = "获取失败"
  1765. br.ErrMsg = "获取失败,Err:" + err.Error()
  1766. return
  1767. }
  1768. for k2, v2 := range artList {
  1769. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1770. if err != nil {
  1771. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1772. br.ErrMsg = "获取失败,Err:" + err.Error()
  1773. return
  1774. }
  1775. var subjectNamesNew string
  1776. if len(subjectNames) > 0 {
  1777. slice := strings.Split(subjectNames, "/")
  1778. for k3, v3 := range slice {
  1779. if k3 < 4 {
  1780. subjectNamesNew += v3 + "/"
  1781. }
  1782. }
  1783. }
  1784. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1785. if err != nil && err.Error() != utils.ErrNoRow() {
  1786. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1787. br.ErrMsg = "获取失败,Err:" + err.Error()
  1788. return
  1789. }
  1790. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1791. artList[k2].SubjectName = subjectNamesNew
  1792. if subjectNamesNew == "" {
  1793. artList[k2].IndustryName = industryName
  1794. } else {
  1795. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1796. }
  1797. }
  1798. if keyWord != "" {
  1799. keyWordItem := new(models.CygxUserSearchKeyWord)
  1800. keyWordItem.UserId = user.UserId
  1801. keyWordItem.KeyWord = keyWord
  1802. keyWordItem.PageType = "ReortSearch"
  1803. keyWordItem.CreateTime = time.Now()
  1804. go models.AddUserSearchKeyWord(keyWordItem)
  1805. }
  1806. resp := new(models.CygxIndustrySearchList)
  1807. resp.ArtList = artList
  1808. resp.IndList = list
  1809. br.Ret = 200
  1810. br.Success = true
  1811. br.Msg = "获取成功"
  1812. br.Data = resp
  1813. }
  1814. // @Title 产业报告分类关联作者列表接口Pc端
  1815. // @Description 获取产业报告分类关联作者列表接口Pc端
  1816. // @Param ChartPermissionId query int true "分类ID"
  1817. // @Param KeyWord query string true "搜索关键词"
  1818. // @Param PageSize query int true "每页数据条数"
  1819. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1820. // @Success 200 {object} models.CygxArticleDepartmentListPc
  1821. // @router /industryListByDepartmentPc [get]
  1822. func (this *ReportController) IndustryListByDepartmentPc() {
  1823. br := new(models.BaseResponse).Init()
  1824. defer func() {
  1825. this.Data["json"] = br
  1826. this.ServeJSON()
  1827. }()
  1828. user := this.User
  1829. if user == nil {
  1830. br.Msg = "请重新登录"
  1831. br.Ret = 408
  1832. return
  1833. }
  1834. uid := user.UserId
  1835. pageSize, _ := this.GetInt("PageSize")
  1836. currentIndex, _ := this.GetInt("CurrentIndex")
  1837. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1838. keyWord := this.GetString("KeyWord")
  1839. var startSize int
  1840. var condition string
  1841. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  1842. if pageSize <= 0 {
  1843. pageSize = utils.PageSize20
  1844. }
  1845. if currentIndex <= 0 {
  1846. currentIndex = 1
  1847. }
  1848. var articleIdGroup string
  1849. if keyWord != "" {
  1850. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  1851. if err != nil {
  1852. br.Msg = "获取信息失败"
  1853. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  1854. return
  1855. }
  1856. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  1857. if err != nil {
  1858. br.Msg = "获取信息失败"
  1859. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  1860. return
  1861. }
  1862. if articleIdSub != "" && articleIdInd != "" {
  1863. articleIdGroup = articleIdSub + "," + articleIdInd
  1864. } else if articleIdSub != "" && articleIdInd == "" {
  1865. articleIdGroup = articleIdSub
  1866. } else if articleIdSub == "" && articleIdInd == "" {
  1867. articleIdGroup = articleIdInd
  1868. }
  1869. }
  1870. if articleIdGroup != "" {
  1871. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  1872. }
  1873. startSize = paging.StartIndex(currentIndex, pageSize)
  1874. total, err := models.GetArticleDepartmentCount(condition)
  1875. page := paging.GetPaging(currentIndex, pageSize, total)
  1876. resp := new(models.CygxArticleDepartmentListPc)
  1877. userType, _, err := services.GetUserType(user.CompanyId)
  1878. if err != nil {
  1879. br.Msg = "获取信息失败"
  1880. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1881. return
  1882. }
  1883. if userType == 1 {
  1884. resp.Paging = page
  1885. br.Ret = 200
  1886. br.Success = true
  1887. br.Msg = "获取成功"
  1888. br.Data = resp
  1889. return
  1890. }
  1891. resp.HaveResearch = true
  1892. //获取作者信息,并排序
  1893. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  1894. if err != nil {
  1895. br.Msg = "获取信息失败"
  1896. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1897. return
  1898. }
  1899. for k, v := range list {
  1900. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  1901. if err != nil {
  1902. br.Msg = "获取信息失败"
  1903. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  1904. return
  1905. }
  1906. for k2, v2 := range artList {
  1907. if artList[k2].IsReport == "1" {
  1908. artList[k2].Title = "【研选观点】" + v2.Title
  1909. } else {
  1910. artList[k2].Title = "【研选纪要】" + v2.Title
  1911. }
  1912. }
  1913. list[k].List = artList
  1914. if v.FollowNum > 0 {
  1915. list[k].IsMyFollow = true
  1916. }
  1917. }
  1918. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  1919. if err != nil {
  1920. br.Msg = "获取信息失败"
  1921. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1922. return
  1923. }
  1924. if len(listnNew) > 0 {
  1925. for _, v := range listnNew {
  1926. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  1927. Management := new(models.IndustrialManagementIdInt)
  1928. if firstStr == 0 {
  1929. Management.IndustryName = v.IndustryName
  1930. } else {
  1931. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  1932. if err != nil {
  1933. br.Msg = "获取信息失败"
  1934. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  1935. return
  1936. }
  1937. var subjectNamesNew string
  1938. for _, v1 := range listSub {
  1939. subjectNamesNew += v1.SubjectName + "/"
  1940. }
  1941. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1942. Management.IndustryName = subjectNamesNew
  1943. }
  1944. Management.IndustrialManagementId = v.IndustrialManagementId
  1945. Management.ArticleId = v.ArticleId
  1946. resp.ListnNew = append(resp.ListnNew, Management)
  1947. }
  1948. }
  1949. resp.List = list
  1950. resp.Paging = page
  1951. br.Ret = 200
  1952. br.Success = true
  1953. br.Msg = "获取成功"
  1954. br.Data = resp
  1955. }