report.go 49 KB

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