report.go 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 报告
  13. type ReportController struct {
  14. BaseAuthController
  15. }
  16. type ReportCommonController struct {
  17. BaseCommonController
  18. }
  19. type MobileReportController struct {
  20. BaseAuthMobileController
  21. }
  22. // @Title 行业报告分类列表接口
  23. // @Description 获取行业报告分类列表接口
  24. // @Param ChartPermissionId query int true "分类ID"
  25. // @Success 200 {object} models.TradeReportMappingResp
  26. // @router /tradeList [get]
  27. func (this *MobileReportController) TradeList() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. user := this.User
  34. if user == nil {
  35. br.Msg = "请重新登录"
  36. br.Ret = 408
  37. return
  38. }
  39. //uid := user.UserId
  40. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  41. if ChartPermissionId < 1 {
  42. br.Msg = "请输入分类ID"
  43. return
  44. }
  45. //var result []*models.SearchItem
  46. var list []*models.TradeReportMapping
  47. var err error
  48. mapCategory := make(map[int]int)
  49. if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
  50. listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
  51. err = errTrade
  52. if ChartPermissionId == utils.CE_LUE_ID {
  53. cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
  54. if err != nil {
  55. br.Msg = "获取失败"
  56. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  57. return
  58. }
  59. if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  60. item := new(models.TradeReportMapping)
  61. item.CategoryId = utils.TIME_LINE_ID
  62. item.MatchTypeName = utils.TIME_LINE_NAME
  63. list = append(list, item)
  64. }
  65. }
  66. for _, v := range listTrade {
  67. list = append(list, v)
  68. }
  69. if user.Mobile != "" {
  70. //策略的处理
  71. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  72. if err != nil && err.Error() != utils.ErrNoRow() {
  73. br.Msg = "获取信息失败"
  74. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  75. return
  76. }
  77. for _, v := range categoryList {
  78. mapCategory[v.IdCygx] = v.IdCygx
  79. }
  80. }
  81. } else {
  82. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  83. if err != nil {
  84. br.Msg = "获取信息失败"
  85. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  86. return
  87. }
  88. categoryMap := make(map[int]int)
  89. for _, v := range listCategory {
  90. if categoryMap[v.CategoryId] > 0 {
  91. continue
  92. }
  93. categoryMap[v.CategoryId] = v.CategoryId
  94. list = append(list, v)
  95. }
  96. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  97. if ChartPermissionId == utils.KE_JI_ID {
  98. list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: 62})
  99. }
  100. }
  101. if err != nil {
  102. br.Msg = "获取信息失败"
  103. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  104. return
  105. }
  106. for k, v := range list {
  107. if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
  108. var pageSize int
  109. var listArticle []*models.HomeArticle
  110. pageSize = 3
  111. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  112. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  113. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  114. } else {
  115. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  116. }
  117. if err != nil {
  118. br.Msg = "获取信息失败"
  119. br.Msg = "GetHomeList,Err:" + err.Error()
  120. return
  121. }
  122. if len(listArticle) > 0 {
  123. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  124. }
  125. list[k].ListArticle = listArticle
  126. } else {
  127. if mapCategory[v.CategoryId] > 0 {
  128. list[k].IsFollow = true
  129. }
  130. list[k].ListArticle = make([]*models.HomeArticle, 0)
  131. }
  132. }
  133. resp := new(models.TradeReportMappingResp)
  134. if len(list) == 0 {
  135. list = make([]*models.TradeReportMapping, 0)
  136. }
  137. resp.List = list
  138. br.Ret = 200
  139. br.Success = true
  140. br.Msg = "获取成功"
  141. br.Data = resp
  142. }
  143. // @Title 产业报告分类列表接口
  144. // @Description 获取产业报告分类列表接口
  145. // @Param ChartPermissionId query int true "分类ID"
  146. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  147. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  148. // @Param PageSize query int true "每页数据条数"
  149. // @Param CurrentIndex query int true "当前页页码,从1开始"
  150. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  151. // @Success 200 {object} models.IndustrialManagementList
  152. // @router /industryList [get]
  153. func (this *MobileReportController) IndustryList() {
  154. br := new(models.BaseResponse).Init()
  155. defer func() {
  156. this.Data["json"] = br
  157. this.ServeJSON()
  158. }()
  159. user := this.User
  160. if user == nil {
  161. br.Msg = "请重新登录"
  162. br.Ret = 408
  163. return
  164. }
  165. uid := user.UserId
  166. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  167. orderColumn := this.GetString("OrderColumn")
  168. orderColumnNew := this.GetString("OrderColumn")
  169. isNewLabel := this.GetString("IsNewLabel")
  170. isDeepLabel := this.GetString("IsDeepLabel")
  171. pageSize, _ := this.GetInt("PageSize")
  172. currentIndex, _ := this.GetInt("CurrentIndex")
  173. deepCover, _ := this.GetInt("DeepCover")
  174. recommendFocus, _ := this.GetInt("RecommendFocus")
  175. isBillboard, _ := this.GetBool("IsBillboard", false)
  176. var orderSrt string
  177. var condition string
  178. var startSize int
  179. resp := new(models.IndustrialManagementList)
  180. if pageSize <= 0 {
  181. pageSize = utils.PageSize20
  182. }
  183. if currentIndex <= 0 {
  184. currentIndex = 1
  185. }
  186. startSize = paging.StartIndex(currentIndex, pageSize)
  187. if ChartPermissionId > 0 {
  188. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  189. }
  190. // 获取近一个月产业报告阅读次数最多的产业
  191. var topCond string
  192. var topPars []interface{}
  193. topReadIndustryId := 0
  194. if ChartPermissionId > 0 {
  195. topCond += ` AND chart_permission_id = ?`
  196. topPars = append(topPars, ChartPermissionId)
  197. }
  198. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  199. if e != nil && e.Error() != utils.ErrNoRow() {
  200. br.Msg = "获取信息失败"
  201. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  202. return
  203. }
  204. if topReadIndustry != nil {
  205. topReadIndustryId = topReadIndustry.IndustrialManagementId
  206. }
  207. // 深度覆盖
  208. if deepCover == 1 {
  209. // 查询深标签产业报告数
  210. var deepCondition string
  211. var deepPars []interface{}
  212. deepCondition += ` AND man.is_deep_label = 1`
  213. if ChartPermissionId > 0 {
  214. deepCondition += ` AND man.chart_permission_id = ?`
  215. deepPars = append(deepPars, ChartPermissionId)
  216. }
  217. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  218. if e != nil {
  219. br.Msg = "获取信息失败"
  220. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  221. return
  222. }
  223. deepIdArr := make([]string, 0)
  224. for i := range industryCountList {
  225. if industryCountList[i].ArtNum > 10 {
  226. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  227. }
  228. }
  229. deepIds := strings.Join(deepIdArr, ",")
  230. if deepIds != "" {
  231. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  232. }
  233. }
  234. // 推荐关注
  235. if recommendFocus == 1 {
  236. condition += ` AND man.recommended_index >= 80`
  237. }
  238. var list []*models.IndustrialManagement
  239. total, err := models.GetIndustrialManagementAllCount(condition)
  240. if err != nil {
  241. br.Msg = "获取信息失败"
  242. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  243. return
  244. }
  245. if orderColumn == "" {
  246. orderColumn = "NewTime"
  247. }
  248. if orderColumn == "NewTime" {
  249. orderSrt = "update_time DESC"
  250. } else {
  251. orderSrt = "man.recommended_index DESC,update_time DESC"
  252. }
  253. if isBillboard {
  254. // 查询有已归类行业报告的行业IDs
  255. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  256. if e != nil {
  257. br.Msg = "获取失败"
  258. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  259. return
  260. }
  261. activeIndustryLen := len(activeIndustryIds)
  262. //topNum := pageSize
  263. condition = ""
  264. var parsBd []interface{}
  265. if ChartPermissionId > 0 {
  266. condition += ` AND man.chart_permission_id = ? `
  267. parsBd = append(parsBd, ChartPermissionId)
  268. }
  269. if activeIndustryLen > 0 {
  270. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  271. parsBd = append(parsBd, activeIndustryIds)
  272. }
  273. nowTime := time.Now().Local()
  274. startTime := nowTime.AddDate(0, -1, 0)
  275. endTime := nowTime.AddDate(0, 0, -1)
  276. condition += ` AND idf.create_time BETWEEN ? AND ?`
  277. parsBd = append(parsBd, startTime, endTime)
  278. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  279. if e != nil {
  280. br.Msg = "获取失败"
  281. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  282. return
  283. }
  284. } else {
  285. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  286. if err != nil {
  287. br.Msg = "获取信息失败"
  288. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  289. return
  290. }
  291. }
  292. var resource string
  293. if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  294. resource = utils.REOURCE_YX
  295. } else {
  296. resource = utils.REOURCE_HZ
  297. }
  298. list, err = services.HandleIndustryList(list, user, resource)
  299. if err != nil {
  300. br.Msg = "获取信息失败"
  301. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  302. return
  303. }
  304. industrialIdArr := make([]int, 0)
  305. for k, v := range list {
  306. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  307. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  308. list[k].IsHot = true
  309. }
  310. }
  311. if orderColumnNew != "" {
  312. item := new(models.CygxReportIndustrialSeaarchHistory)
  313. item.UserId = user.UserId
  314. item.Mobile = user.Mobile
  315. item.CompanyId = user.CompanyId
  316. item.CompanyName = user.CompanyName
  317. item.CreateTime = time.Now()
  318. item.IsDeepLabel = isDeepLabel
  319. item.IsNewLabel = isNewLabel
  320. item.ChartPermissionId = ChartPermissionId
  321. if orderColumnNew == "NewTime" {
  322. item.OrderColumn = "0"
  323. } else {
  324. item.OrderColumn = "1"
  325. }
  326. go models.AddCygxReportIndustrialSeaarchHistory(item)
  327. }
  328. if len(list) == 0 {
  329. list = make([]*models.IndustrialManagement, 0)
  330. }
  331. page := paging.GetPaging(currentIndex, pageSize, total)
  332. if isBillboard {
  333. total = len(list)
  334. }
  335. resp.List = list
  336. resp.Paging = page
  337. br.Ret = 200
  338. br.Success = true
  339. br.Msg = "获取成功"
  340. br.Data = resp
  341. }
  342. // @Title 产业下所关联的文章分类列表
  343. // @Description 产业下所关联的文章分类列表接口
  344. // @Param IndustrialManagementId query int true "产业ID"
  345. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  346. // @router /toArticleCategoryList [get]
  347. func (this *MobileReportController) ArticleCategoryList() {
  348. br := new(models.BaseResponse).Init()
  349. defer func() {
  350. this.Data["json"] = br
  351. this.ServeJSON()
  352. }()
  353. user := this.User
  354. if user == nil {
  355. br.Msg = "请重新登录"
  356. br.Ret = 408
  357. return
  358. }
  359. //uid := user.UserId
  360. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  361. if industrialManagementId < 1 {
  362. br.Msg = "请输入分类ID"
  363. return
  364. }
  365. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  366. if err != nil {
  367. br.Msg = "获取信息失败"
  368. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  369. return
  370. }
  371. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  372. if err != nil {
  373. br.Msg = "获取信息失败"
  374. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  375. return
  376. }
  377. var list []*models.IndustrialToArticleCategoryRep
  378. categoryMap := make(map[int]int)
  379. for _, v := range listCategory {
  380. if categoryMap[v.CategoryId] > 0 {
  381. continue
  382. }
  383. categoryMap[v.CategoryId] = v.CategoryId
  384. list = append(list, v)
  385. //recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  386. //if err != nil && err.Error() != utils.ErrNoRow() {
  387. // br.Msg = "获取信息失败"
  388. // br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  389. // return
  390. //}
  391. //Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  392. //if err != nil {
  393. // br.Msg = "获取信息失败"
  394. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  395. // return
  396. //}
  397. //if Newdetail != nil {
  398. // if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  399. // list[k].IsRed = true
  400. // }
  401. //}
  402. }
  403. //标的列表
  404. industrialSubjectList, err := models.GetIndustrialSubjectAll(industrialManagementId)
  405. if err != nil {
  406. br.Msg = "获取信息失败"
  407. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  408. return
  409. }
  410. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  411. if err != nil {
  412. br.Msg = "获取失败"
  413. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  414. return
  415. }
  416. timeLineItem := models.IndustrialToArticleCategoryRep{
  417. CategoryId: utils.TIME_CATEGORYID,
  418. MatchTypeName: "时间线",
  419. }
  420. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  421. if err != nil {
  422. br.Msg = "获取失败"
  423. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  424. return
  425. }
  426. timeLineItem.IsRed = timeLineIsRed
  427. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  428. resp := new(models.IndustrialToArticleCategoryListRep)
  429. resp.List = list
  430. resp.ListSubject = industrialSubjectList
  431. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  432. resp.IndustryName = detail.IndustryName
  433. resp.IndustrialManagementId = industrialManagementId
  434. if videoSimple != nil && videoSimple.Id > 0 {
  435. resp.IndustryVideo = videoSimple
  436. }
  437. resp.AuthInfo = au
  438. br.Ret = 200
  439. br.Success = true
  440. br.Msg = "获取成功"
  441. br.Data = resp
  442. }
  443. // @Title 根据行业分类获取文章列表
  444. // @Description根据行业分类获取文章列表接口
  445. // @Param PageSize query int true "每页数据条数"
  446. // @Param CurrentIndex query int true "当前页页码,从1开始"
  447. // @Param CategoryId query int true "分类ID"
  448. // @Param IndustrialManagementId query int false "产业ID"
  449. // @Success 200 {object} models.TacticsListResp
  450. // @router /articleList/byCategoryId [get]
  451. func (this *MobileReportController) List() {
  452. br := new(models.BaseResponse).Init()
  453. defer func() {
  454. this.Data["json"] = br
  455. this.ServeJSON()
  456. }()
  457. user := this.User
  458. if user == nil {
  459. br.Msg = "请重新登录"
  460. br.Ret = 408
  461. return
  462. }
  463. //uid := user.UserId
  464. pageSize, _ := this.GetInt("PageSize")
  465. currentIndex, _ := this.GetInt("CurrentIndex")
  466. categoryId, _ := this.GetInt("CategoryId")
  467. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  468. uid := user.UserId
  469. var startSize int
  470. if pageSize <= 0 {
  471. pageSize = utils.PageSize20
  472. }
  473. if currentIndex <= 0 {
  474. currentIndex = 1
  475. }
  476. startSize = paging.StartIndex(currentIndex, pageSize)
  477. //var condition string
  478. var pars []interface{}
  479. var total int
  480. resp := new(models.TacticsListResp)
  481. page := paging.GetPaging(currentIndex, pageSize, total)
  482. list := make([]*models.ArticleListResp, 0)
  483. if categoryId == utils.TIME_CATEGORYID {
  484. var err error
  485. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  486. if err != nil {
  487. br.Msg = "获取信息失败"
  488. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  489. return
  490. }
  491. } else {
  492. //获取该产业下所对应的行业图片
  493. //var reportType int
  494. //if industrialManagementId > 0 {
  495. // reportType = 2
  496. //} else {
  497. // reportType = 1
  498. //}
  499. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  500. //if errCategory != nil {
  501. // br.Msg = "获取信息失败"
  502. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  503. // return
  504. //}
  505. //对应行业的图片
  506. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  513. mapChartPermission := make(map[string]string)
  514. var permissionName string
  515. var imgUrlChartPermission string
  516. for _, v := range chartPermissionUrlList {
  517. vslice := strings.Split(v, "_")
  518. permissionName = vslice[0]
  519. imgUrlChartPermission = vslice[len(vslice)-1]
  520. mapChartPermission[permissionName] = imgUrlChartPermission
  521. }
  522. //对应分类的所图片
  523. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  524. if err != nil {
  525. br.Msg = "获取数据失败"
  526. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  527. return
  528. }
  529. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  530. mapCategoryUrl := make(map[string]string)
  531. var categoryIdStr string
  532. var imgUrlChart string
  533. for _, v := range categoryUrlList {
  534. vslice := strings.Split(v, "_")
  535. categoryIdStr = vslice[0]
  536. imgUrlChart = vslice[len(vslice)-1]
  537. mapCategoryUrl[categoryIdStr] = imgUrlChart
  538. }
  539. //if detail.CeLueFieldId != "" {
  540. // condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
  541. //} else if detail.PolymerizationId != "" {
  542. // condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
  543. //} else {
  544. // categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
  545. // if errCategory != nil {
  546. // br.Msg = "获取信息失败"
  547. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  548. // return
  549. // }
  550. // if categoryIdSet != "" {
  551. // condition = ` AND category_id IN(` + categoryIdSet + `)`
  552. // } else {
  553. // condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
  554. // }
  555. //}
  556. //
  557. //if industrialManagementId > 0 {
  558. // industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
  559. // if err != nil {
  560. // br.Msg = "获取信息失败"
  561. // br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
  562. // return
  563. // }
  564. // articleIdList := make([]string, 0)
  565. // for _, v := range industrialManageentList {
  566. // articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
  567. // }
  568. // condition += ` AND a.article_id IN ( ` + utils.GetOrmInReplace(len(articleIdList)) + ` ) `
  569. // pars = append(pars, articleIdList)
  570. //}
  571. //total, err = models.GetHomeCount(condition, pars)
  572. //if err != nil {
  573. // br.Msg = "获取信息失败"
  574. // br.Msg = "获取帖子总数失败,Err:" + err.Error()
  575. // return
  576. //}
  577. //
  578. //list, err = models.GetHomeListNew(condition, pars, startSize, pageSize)
  579. //if err != nil {
  580. // br.Msg = "获取信息失败"
  581. // br.Msg = "获取帖子数据失败,Err:" + err.Error()
  582. // return
  583. //}
  584. list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  585. if err != nil {
  586. br.Msg = "获取信息失败"
  587. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  588. return
  589. }
  590. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  591. if err != nil {
  592. br.Msg = "获取信息失败"
  593. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  594. return
  595. }
  596. for k, v := range list {
  597. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  598. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  599. list[k].IsRed = true
  600. }
  601. }
  602. //if categoryId > 0 {
  603. // detail, errCategory := models.GetdetailByCategoryId(categoryId)
  604. // if errCategory != nil {
  605. // br.Msg = "获取信息失败"
  606. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  607. // return
  608. // }
  609. // resp.MatchTypeName = detail.MatchTypeName
  610. //}
  611. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  612. }
  613. listPublic, err := services.HandleArticleCategoryImg(list, user)
  614. if err != nil {
  615. br.Msg = "获取失败"
  616. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  617. return
  618. }
  619. listResp := make([]*models.HomeArticle, 0)
  620. //listResp :=
  621. for _, v := range listPublic {
  622. listResp = append(listResp, &models.HomeArticle{
  623. ArticleId: v.ArticleId,
  624. Title: v.Title,
  625. Annotation: "核心观点:" + v.Annotation,
  626. Abstract: v.Abstract,
  627. ImgUrlPc: v.ImgUrlPc,
  628. PublishDate: v.PublishDate,
  629. Resource: v.Resource,
  630. })
  631. }
  632. //lenList := len(list)
  633. //for i := 0; i < lenList; i++ {
  634. // item := list[i]
  635. // list[i].Body = ""
  636. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  637. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  638. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  639. // //行业比较研究、资金流向,显示报告的摘要
  640. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  641. // list[i].Annotation = list[i].Abstract
  642. // }
  643. //}
  644. if len(listResp) == 0 {
  645. listResp = make([]*models.HomeArticle, 0)
  646. }
  647. page = paging.GetPaging(currentIndex, pageSize, total)
  648. resp.List = listResp
  649. resp.Paging = page
  650. br.Ret = 200
  651. br.Success = true
  652. br.Msg = "获取成功"
  653. br.Data = resp
  654. }
  655. // @Title 产业关注/取消关注
  656. // @Description 产业关注/取消关注 接口
  657. // @Param request body models.CygxIndustryFllowRep true "type json string"
  658. // @Success 200
  659. // @router /industrial/fllow [post]
  660. func (this *ReportController) IndustrialFllow() {
  661. br := new(models.BaseResponse).Init()
  662. defer func() {
  663. this.Data["json"] = br
  664. this.ServeJSON()
  665. }()
  666. user := this.User
  667. if user == nil {
  668. br.Msg = "请重新登录"
  669. br.Ret = 408
  670. return
  671. }
  672. uid := user.UserId
  673. var req models.CygxIndustryFllowRep
  674. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  675. if err != nil {
  676. br.Msg = "参数解析异常!"
  677. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  678. return
  679. }
  680. industrialManagementId := req.IndustrialManagementId
  681. var condition string
  682. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  683. if err != nil {
  684. br.Msg = "获取数据失败!"
  685. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  686. return
  687. }
  688. if countIndustrial == 0 {
  689. br.Msg = "产业不存在!"
  690. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  691. return
  692. }
  693. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  694. if err != nil {
  695. br.Msg = "获取数据失败!"
  696. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  697. return
  698. }
  699. resp := new(models.CygxIndustryFllowResp)
  700. if count == 0 {
  701. item := new(models.CygxIndustryFllow)
  702. item.IndustrialManagementId = industrialManagementId
  703. item.UserId = uid
  704. item.Email = user.Email
  705. item.Mobile = user.Mobile
  706. item.RealName = user.RealName
  707. item.CompanyId = user.CompanyId
  708. item.CompanyName = user.CompanyName
  709. item.Type = 1
  710. item.CreateTime = time.Now()
  711. item.ModifyTime = time.Now()
  712. _, err = models.AddCygxIndustryFllow(item)
  713. if err != nil {
  714. br.Msg = "操作失败"
  715. br.ErrMsg = "操作失败,Err:" + err.Error()
  716. return
  717. }
  718. resp.Status = 1
  719. br.Msg = "关注成功"
  720. } else {
  721. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  722. if err != nil {
  723. br.Msg = "操作失败"
  724. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  725. return
  726. }
  727. resp.Status = 2
  728. br.Msg = "已取消关注"
  729. }
  730. //处理是否关注全部赛道字段
  731. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  732. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  733. br.Ret = 200
  734. br.Success = true
  735. br.Data = resp
  736. }
  737. // @Title 行业关注/取消关注
  738. // @Description 行业关注/取消关注 接口
  739. // @Param request body models.CygxCategoryFllowRep true "type json string"
  740. // @Success 200
  741. // @router /category/fllow [post]
  742. func (this *ReportController) CategoryFllow() {
  743. br := new(models.BaseResponse).Init()
  744. defer func() {
  745. this.Data["json"] = br
  746. this.ServeJSON()
  747. }()
  748. user := this.User
  749. if user == nil {
  750. br.Msg = "请重新登录"
  751. br.Ret = 408
  752. return
  753. }
  754. uid := user.UserId
  755. var req models.CygxCategoryFllowRep
  756. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  757. if err != nil {
  758. br.Msg = "参数解析异常!"
  759. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  760. return
  761. }
  762. categoryId := req.CategoryId
  763. var condition string
  764. //countCategory, err := models.GetCategoryCount(categoryId)
  765. //if err != nil {
  766. // br.Msg = "获取数据失败!"
  767. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  768. // return
  769. //}
  770. //if countCategory == 0 {
  771. // br.Msg = "产业不存在!"
  772. // br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  773. // return
  774. //}
  775. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  776. if err != nil {
  777. br.Msg = "操作失败!"
  778. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  779. return
  780. }
  781. mapReport := make(map[int]int)
  782. for _, v := range listMap {
  783. mapReport[v.Id] = v.CategoryId
  784. }
  785. if mapReport[categoryId] == 0 {
  786. br.Msg = "操作失败!"
  787. br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
  788. return
  789. }
  790. count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
  791. if err != nil {
  792. br.Msg = "获取数据失败!"
  793. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  794. return
  795. }
  796. resp := new(models.CygxIndustryFllowResp)
  797. if count == 0 {
  798. item := new(models.CygxXzsChooseCategory)
  799. item.CategoryId = mapReport[categoryId]
  800. item.IdCygx = categoryId
  801. item.UserId = uid
  802. item.Email = user.Email
  803. item.Mobile = user.Mobile
  804. item.RealName = user.RealName
  805. item.CompanyId = user.CompanyId
  806. item.CompanyName = user.CompanyName
  807. item.CreateTime = time.Now()
  808. item.ModifyTime = time.Now()
  809. _, err = models.AddCygxCategoryFllow(item)
  810. if err != nil {
  811. br.Msg = "操作失败"
  812. br.ErrMsg = "操作失败,Err:" + err.Error()
  813. return
  814. }
  815. resp.Status = 1
  816. br.Msg = "关注成功"
  817. } else {
  818. err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
  819. if err != nil {
  820. br.Msg = "操作失败"
  821. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  822. return
  823. }
  824. resp.Status = 2
  825. br.Msg = "已取消关注"
  826. }
  827. go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
  828. br.Ret = 200
  829. br.Success = true
  830. br.Data = resp
  831. }
  832. // @Title 报告搜索
  833. // @Description 报告搜索接口
  834. // @Param PageSize query int true "每页数据条数"
  835. // @Param CurrentIndex query int true "当前页页码,从1开始"
  836. // @Param KeyWord query string true "搜索关键词"
  837. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  838. // @Param IsAll query bool true "是否为综合 "
  839. // @Success 200 {object} models.ReoprtSearchResp
  840. // @router /searchReport [get]
  841. func (this *MobileReportController) SearchReport() {
  842. br := new(models.BaseResponse).Init()
  843. defer func() {
  844. this.Data["json"] = br
  845. this.ServeJSON()
  846. }()
  847. user := this.User
  848. if user == nil {
  849. br.Msg = "请重新登录"
  850. br.Ret = 408
  851. return
  852. }
  853. pageSize, _ := this.GetInt("PageSize")
  854. currentIndex, _ := this.GetInt("CurrentIndex")
  855. articleType, _ := this.GetInt("ArticleType", 1)
  856. keyWord := this.GetString("KeyWord")
  857. isAll, _ := this.GetBool("IsAll")
  858. var condition string
  859. var pars []interface{}
  860. //var conditionSql string
  861. var total int
  862. var startSize int
  863. if pageSize <= 0 {
  864. pageSize = utils.PageSize20
  865. }
  866. if isAll {
  867. pageSize = utils.PageSize5
  868. }
  869. if currentIndex <= 0 {
  870. currentIndex = 1
  871. }
  872. startSize = paging.StartIndex(currentIndex, pageSize)
  873. resp := new(models.ReoprtSearchResp)
  874. //匹配报告标题、
  875. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  876. if err != nil {
  877. br.Msg = "获取信息失败"
  878. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  879. return
  880. }
  881. if articleTypeIds == "" {
  882. br.Msg = "获取信息失败"
  883. br.ErrMsg = "研选分类ID不能为空"
  884. return
  885. }
  886. //处理对应的文章类型标签按钮
  887. nameMap, styleMap, err := services.GetArticleTypeMap()
  888. if err != nil {
  889. br.Msg = "获取信息失败"
  890. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  891. return
  892. }
  893. if isAll {
  894. total = utils.PageSize5
  895. conditionHz := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  896. conditionYx := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
  897. listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
  898. if err != nil {
  899. br.Msg = "获取信息失败"
  900. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  901. return
  902. }
  903. listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId)
  904. if err != nil {
  905. br.Msg = "获取信息失败"
  906. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  907. return
  908. }
  909. listHz, err = services.HandleArticleCategoryImg(listHz, user)
  910. if err != nil {
  911. br.Msg = "获取信息失败"
  912. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  913. return
  914. }
  915. listYx, err = services.HandleArticleCategoryImg(listYx, user)
  916. if err != nil {
  917. br.Msg = "获取信息失败"
  918. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  919. return
  920. }
  921. for _, v := range listHz {
  922. item := models.ArticleResearchResp{
  923. ArticleId: v.ArticleId,
  924. ArticleTypeId: v.ArticleTypeId,
  925. Title: v.Title,
  926. PublishDate: v.PublishDate,
  927. DepartmentId: v.DepartmentId,
  928. NickName: v.NickName,
  929. IsCollect: v.IsCollect,
  930. Pv: v.Pv,
  931. CollectNum: v.CollectNum,
  932. Abstract: v.Abstract,
  933. Annotation: v.Annotation,
  934. ImgUrlPc: v.ImgUrlPc,
  935. ArticleTypeName: nameMap[v.ArticleTypeId],
  936. ButtonStyle: styleMap[v.ArticleTypeId],
  937. List: v.List,
  938. }
  939. resp.ListHz = append(resp.ListHz, &item)
  940. }
  941. for _, v := range listYx {
  942. item := models.ArticleResearchResp{
  943. ArticleId: v.ArticleId,
  944. ArticleTypeId: v.ArticleTypeId,
  945. Title: v.Title,
  946. PublishDate: v.PublishDate,
  947. DepartmentId: v.DepartmentId,
  948. NickName: v.NickName,
  949. IsCollect: v.IsCollect,
  950. Pv: v.Pv,
  951. CollectNum: v.CollectNum,
  952. Abstract: v.Abstract,
  953. Annotation: v.Annotation,
  954. ImgUrlPc: v.ImgUrlPc,
  955. ArticleTypeName: nameMap[v.ArticleTypeId],
  956. ButtonStyle: styleMap[v.ArticleTypeId],
  957. List: v.List,
  958. }
  959. resp.ListYx = append(resp.ListYx, &item)
  960. }
  961. } else {
  962. //condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  963. if articleType == 1 {
  964. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  965. total, err = models.GetReoprtSearchCountHz(condition)
  966. } else {
  967. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
  968. total, err = models.GetReoprtSearchCountYx(condition)
  969. }
  970. if err != nil {
  971. br.Msg = "获取信息失败"
  972. br.Msg = "获取总数失败,Err:" + err.Error()
  973. return
  974. }
  975. var list []*models.ArticleListResp
  976. //list := new([]models.ArticleResearchResp)
  977. if articleType == 1 {
  978. list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  979. } else {
  980. list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
  981. }
  982. if err != nil {
  983. br.Msg = "获取信息失败"
  984. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  985. return
  986. }
  987. //return
  988. list, err = services.HandleArticleCategoryImg(list, user)
  989. if err != nil {
  990. br.Msg = "获取信息失败"
  991. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  992. return
  993. }
  994. for _, v := range list {
  995. item := models.ArticleResearchResp{
  996. ArticleId: v.ArticleId,
  997. ArticleTypeId: v.ArticleTypeId,
  998. Title: v.Title,
  999. PublishDate: v.PublishDate,
  1000. DepartmentId: v.DepartmentId,
  1001. NickName: v.NickName,
  1002. IsCollect: v.IsCollect,
  1003. Pv: v.Pv,
  1004. CollectNum: v.CollectNum,
  1005. Abstract: v.Abstract,
  1006. Annotation: v.Annotation,
  1007. ImgUrlPc: v.ImgUrlPc,
  1008. ArticleTypeName: nameMap[v.ArticleTypeId],
  1009. ButtonStyle: styleMap[v.ArticleTypeId],
  1010. List: v.List,
  1011. }
  1012. if articleType == 1 {
  1013. resp.ListHz = append(resp.ListHz, &item)
  1014. } else {
  1015. resp.ListYx = append(resp.ListYx, &item)
  1016. }
  1017. }
  1018. }
  1019. if keyWord != "" {
  1020. //go services.AddUserSearchLog(user, keyWord, 5)
  1021. }
  1022. if len(resp.ListHz) == 0 {
  1023. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  1024. }
  1025. if len(resp.ListYx) == 0 {
  1026. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  1027. }
  1028. page := paging.GetPaging(currentIndex, pageSize, total)
  1029. resp.Paging = page
  1030. br.Ret = 200
  1031. br.Success = true
  1032. br.Msg = "获取成功"
  1033. br.Data = resp
  1034. }
  1035. // @Title 资源包搜索
  1036. // @Description 资源包搜索接口
  1037. // @Param KeyWord query string true "搜索关键词"
  1038. // @Success 200 {object} models.SearchResourceResp
  1039. // @router /searchResource [get]
  1040. func (this *MobileReportController) SearchResource() {
  1041. br := new(models.BaseResponse).Init()
  1042. defer func() {
  1043. this.Data["json"] = br
  1044. this.ServeJSON()
  1045. }()
  1046. user := this.User
  1047. if user == nil {
  1048. br.Msg = "请重新登录"
  1049. br.Ret = 408
  1050. return
  1051. }
  1052. uid := user.UserId
  1053. fllowList, err := models.GetUserFllowIndustrialList(uid)
  1054. if err != nil {
  1055. br.Msg = "获取失败"
  1056. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  1057. return
  1058. }
  1059. fllowMap := make(map[int]int)
  1060. if len(fllowList) > 0 {
  1061. for _, v := range fllowList {
  1062. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1063. }
  1064. }
  1065. keyWord := this.GetString("KeyWord")
  1066. var condition string
  1067. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1068. if err != nil {
  1069. br.Msg = "获取信息失败"
  1070. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1071. return
  1072. }
  1073. if articleTypeIds == "" {
  1074. br.Msg = "获取信息失败"
  1075. br.ErrMsg = "研选分类ID不能为空"
  1076. return
  1077. }
  1078. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1079. listHz, err := models.GetSearchResourceList(condition)
  1080. if err != nil {
  1081. br.Msg = "获取信息失败"
  1082. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1083. return
  1084. }
  1085. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1086. listYx, err := models.GetSearchResourceList(condition)
  1087. if err != nil {
  1088. br.Msg = "获取信息失败"
  1089. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1090. return
  1091. }
  1092. if len(listYx) > 0 {
  1093. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1094. if err != nil {
  1095. br.Msg = "获取信息失败"
  1096. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1097. return
  1098. }
  1099. }
  1100. if len(listHz) > 0 {
  1101. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1102. if err != nil {
  1103. br.Msg = "获取信息失败"
  1104. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1105. return
  1106. }
  1107. }
  1108. if keyWord != "" {
  1109. //go services.AddUserSearchLog(user, keyWord, 4)
  1110. }
  1111. resp := new(models.SearchResourceResp)
  1112. if len(listHz) == 0 {
  1113. listHz = make([]*models.IndustrialManagement, 0)
  1114. }
  1115. if len(listYx) == 0 {
  1116. listYx = make([]*models.IndustrialManagement, 0)
  1117. }
  1118. resp.ListHz = listHz
  1119. resp.ListYx = listYx
  1120. br.Ret = 200
  1121. br.Success = true
  1122. br.Msg = "获取成功"
  1123. br.Data = resp
  1124. }
  1125. // @Title 报告搜索、资源包搜索接口
  1126. // @Description 报告搜索、资源包搜索接口接口
  1127. // @Param KeyWord query string true "搜索关键词"
  1128. // @Param PageSize query int true "每页数据条数"
  1129. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1130. // @Param SearchType query int true "1:综合,2:全部"
  1131. // @Success 200 {object} models.SearchReportAndResourceResp
  1132. // @router /searchReportAndResource [get]
  1133. func (this *MobileReportController) SearchReportAndResource() {
  1134. br := new(models.BaseResponse).Init()
  1135. defer func() {
  1136. this.Data["json"] = br
  1137. this.ServeJSON()
  1138. }()
  1139. user := this.User
  1140. if user == nil {
  1141. br.Msg = "请重新登录"
  1142. br.Ret = 408
  1143. return
  1144. }
  1145. //uid := user.UserId
  1146. keyWord := this.GetString("KeyWord")
  1147. pageSize, _ := this.GetInt("PageSize")
  1148. currentIndex, _ := this.GetInt("CurrentIndex")
  1149. searchType, _ := this.GetInt("SearchType")
  1150. var total int
  1151. var startSize int
  1152. if pageSize <= 0 {
  1153. pageSize = utils.PageSize20
  1154. }
  1155. if currentIndex <= 0 {
  1156. currentIndex = 1
  1157. }
  1158. startSize = paging.StartIndex(currentIndex, pageSize)
  1159. page := paging.GetPaging(currentIndex, pageSize, total)
  1160. var condition string
  1161. var conditionSql string
  1162. //匹配报告标题、
  1163. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1164. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1165. total, err := models.GetReoprtSearchCount(conditionSql)
  1166. if err != nil {
  1167. br.Msg = "获取信息失败"
  1168. br.Msg = "获取总数失败,Err:" + err.Error()
  1169. return
  1170. }
  1171. if searchType == 1 {
  1172. pageSize = utils.PageSize5
  1173. }
  1174. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1175. if err != nil {
  1176. br.Msg = "获取失败"
  1177. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1178. return
  1179. }
  1180. if len(ListHzReport) == 0 {
  1181. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1182. }
  1183. var conditionOr string
  1184. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1185. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1186. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1187. if err != nil {
  1188. br.Msg = "获取信息失败"
  1189. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1190. return
  1191. }
  1192. resp := new(models.SearchReportAndResourceResp)
  1193. if len(listHzResource) == 0 {
  1194. listHzResource = make([]*models.IndustrialManagement, 0)
  1195. }
  1196. if keyWord != "" {
  1197. //go services.AddUserSearchLog(user, keyWord, 5)
  1198. }
  1199. page = paging.GetPaging(currentIndex, pageSize, total)
  1200. resp.Paging = page
  1201. resp.ListHzResource = listHzResource
  1202. resp.ListHzReport = ListHzReport
  1203. br.Ret = 200
  1204. br.Success = true
  1205. br.Msg = "获取成功"
  1206. br.Data = resp
  1207. }
  1208. // @Title 公司速览
  1209. // @Description 公司速览接口
  1210. // @Param ChartPermissionId query int false "分类ID"
  1211. // @Success 200 {object} models.ArticleDataLogoListResp
  1212. // @router /companyList [get]
  1213. func (this *ReportCommonController) CompanyList() {
  1214. br := new(models.BaseResponse).Init()
  1215. defer func() {
  1216. this.Data["json"] = br
  1217. this.ServeJSON()
  1218. }()
  1219. var condition string
  1220. var pars []interface{}
  1221. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1222. if chartPermissionId > 1 {
  1223. categoryId, err := models.GetCategoryId(chartPermissionId)
  1224. if err != nil && err.Error() != utils.ErrNoRow() {
  1225. br.Msg = "获取信息失败"
  1226. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1227. return
  1228. }
  1229. if categoryId != "" {
  1230. condition += ` AND a.category_id IN (` + categoryId + `)`
  1231. }
  1232. }
  1233. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1234. list, err := models.CygxArticleDataList(condition, pars)
  1235. if err != nil {
  1236. br.Msg = "获取失败"
  1237. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1238. return
  1239. }
  1240. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1241. for i := range list {
  1242. v := list[i]
  1243. comapnyList := services.HandleArticleStock(v.Stock)
  1244. if len(comapnyList) > 1 {
  1245. for kC, vC := range comapnyList {
  1246. sliceCovers := strings.Split(v.Cover, "{|}")
  1247. cover := v.Cover
  1248. if len(sliceCovers) == len(comapnyList) {
  1249. cover = sliceCovers[kC]
  1250. }
  1251. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1252. ArticleId: v.ArticleId,
  1253. Cover: cover,
  1254. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1255. })
  1256. }
  1257. } else {
  1258. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1259. ArticleId: v.ArticleId,
  1260. Cover: v.Cover,
  1261. ComapnyList: services.HandleArticleStock(v.Stock),
  1262. })
  1263. }
  1264. }
  1265. resp := new(models.ArticleDataLogoListResp)
  1266. resp.List = listLogo
  1267. br.Ret = 200
  1268. br.Success = true
  1269. br.Msg = "获取成功"
  1270. br.Data = resp
  1271. }
  1272. // @Title 时间线
  1273. // @Description 时间线接口
  1274. // @Param PageSize query int true "每页数据条数"
  1275. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1276. // @Param IndustrialManagementId query int false "产业ID"
  1277. // @Success 200 {object} models.TacticsListResp
  1278. // @router /timeline [get]
  1279. func (this *MobileReportController) Timeline() {
  1280. br := new(models.BaseResponse).Init()
  1281. defer func() {
  1282. this.Data["json"] = br
  1283. this.ServeJSON()
  1284. }()
  1285. user := this.User
  1286. if user == nil {
  1287. br.Msg = "请重新登录"
  1288. br.Ret = 408
  1289. return
  1290. }
  1291. pageSize, _ := this.GetInt("PageSize")
  1292. currentIndex, _ := this.GetInt("CurrentIndex")
  1293. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1294. var startSize int
  1295. if pageSize <= 0 {
  1296. pageSize = utils.PageSize20
  1297. }
  1298. if currentIndex <= 0 {
  1299. currentIndex = 1
  1300. }
  1301. startSize = paging.StartIndex(currentIndex, pageSize)
  1302. var total int
  1303. resp := new(models.TacticsListTimeResp)
  1304. page := paging.GetPaging(currentIndex, pageSize, total)
  1305. list := make([]*models.TimeLineReportItem, 0)
  1306. var err error
  1307. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1308. if err != nil {
  1309. br.Msg = "获取信息失败"
  1310. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1311. return
  1312. }
  1313. //查询用户今天是否看过时间线
  1314. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1315. if err != nil {
  1316. br.Msg = "查询浏览记录数量失败"
  1317. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1318. return
  1319. }
  1320. var recordItem *models.CygxPageHistoryRecord
  1321. if count > 1 {
  1322. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1323. if err != nil {
  1324. br.Msg = "查询浏览记录失败"
  1325. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1326. return
  1327. }
  1328. }
  1329. for k, v := range list {
  1330. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1331. list[k].IsRed = true
  1332. }
  1333. timeLineRed := false
  1334. if count < 2 && v.SubCategoryName == "时间线" {
  1335. timeLineRed = true
  1336. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1337. timeLineRed = true
  1338. }
  1339. if v.SubCategoryName == "时间线" && timeLineRed {
  1340. list[k].IsRed = true
  1341. }
  1342. if v.VideoUrl != "" {
  1343. list[k].IsHaveVideo = true
  1344. }
  1345. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1346. }
  1347. //添加我的日程访问记录
  1348. item := new(models.CygxPageHistoryRecord)
  1349. item.UserId = user.UserId
  1350. item.CreateTime = time.Now()
  1351. item.CompanyId = user.CompanyId
  1352. item.CompanyName = user.CompanyName
  1353. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1354. go models.AddCygxPageHistoryRecord(item)
  1355. if len(list) == 0 {
  1356. list = make([]*models.TimeLineReportItem, 0)
  1357. }
  1358. page = paging.GetPaging(currentIndex, pageSize, total)
  1359. resp.List = list
  1360. resp.Paging = page
  1361. br.Ret = 200
  1362. br.Success = true
  1363. br.Msg = "获取成功"
  1364. br.Data = resp
  1365. }
  1366. // @Title 文章留言接口
  1367. // @Description 文章留言接口
  1368. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1369. // @Success 200 {object} models.TacticsListResp
  1370. // @router /commentAdd [post]
  1371. func (this *ReportController) CommentAdd() {
  1372. br := new(models.BaseResponse).Init()
  1373. defer func() {
  1374. this.Data["json"] = br
  1375. this.ServeJSON()
  1376. }()
  1377. user := this.User
  1378. if user == nil {
  1379. br.Msg = "请重新登录"
  1380. br.Ret = 408
  1381. return
  1382. }
  1383. var req models.AddCygxArticleCommentReq
  1384. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1385. if err != nil {
  1386. br.Msg = "参数解析异常!"
  1387. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1388. return
  1389. }
  1390. if req.ArticleId <= 0 {
  1391. br.Msg = "文章不存在"
  1392. br.ErrMsg = "文章不存在,文章ID错误"
  1393. return
  1394. }
  1395. if req.Content == "" {
  1396. br.Msg = "建议内容不可为空"
  1397. return
  1398. }
  1399. content := req.Content
  1400. if content == "" {
  1401. br.Msg = "留言内容不能为空!"
  1402. return
  1403. }
  1404. //itemToken, err := services.WxGetToken()
  1405. //if err != nil {
  1406. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1407. // return
  1408. //}
  1409. //if itemToken.AccessToken == "" {
  1410. // br.Msg = "accessToken is empty"
  1411. // return
  1412. //}
  1413. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1414. //if err != nil {
  1415. // br.Msg = "内容校验失败!"
  1416. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1417. // return
  1418. //}
  1419. //if commerr.ErrCode != 0 {
  1420. // br.Msg = "内容违规,请重新提交!"
  1421. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1422. // return
  1423. //}
  1424. articleId := req.ArticleId
  1425. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1426. if articleInfo == nil {
  1427. br.Msg = "操作失败"
  1428. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1429. return
  1430. }
  1431. if errInfo != nil {
  1432. br.Msg = "操作失败"
  1433. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1434. return
  1435. }
  1436. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1437. if err != nil {
  1438. br.Msg = "提交失败!"
  1439. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1440. return
  1441. }
  1442. if companyDetail == nil {
  1443. br.Msg = "提交失败!"
  1444. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1445. return
  1446. }
  1447. item := models.CygxArticleComment{
  1448. UserId: user.UserId,
  1449. ArticleId: req.ArticleId,
  1450. CreateTime: time.Now(),
  1451. Mobile: user.Mobile,
  1452. Email: user.Email,
  1453. CompanyId: user.CompanyId,
  1454. CompanyName: companyDetail.CompanyName,
  1455. Content: content,
  1456. Title: articleInfo.Title,
  1457. }
  1458. msgId, err := models.AddArticleComment(&item)
  1459. if err != nil {
  1460. br.Msg = "提交失败"
  1461. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1462. return
  1463. }
  1464. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1465. br.Ret = 200
  1466. br.Success = true
  1467. br.Msg = "提交成功"
  1468. }
  1469. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1470. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1471. // @Param PageSize query int true "每页数据条数"
  1472. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1473. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1474. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1475. // @router /reportList/byType [get]
  1476. func (this *ReportController) ReportListByType() {
  1477. br := new(models.BaseResponse).Init()
  1478. defer func() {
  1479. this.Data["json"] = br
  1480. this.ServeJSON()
  1481. }()
  1482. user := this.User
  1483. if user == nil {
  1484. br.Msg = "请重新登录"
  1485. br.Ret = 408
  1486. return
  1487. }
  1488. uid := user.UserId
  1489. pageSize, _ := this.GetInt("PageSize")
  1490. currentIndex, _ := this.GetInt("CurrentIndex")
  1491. reportType := this.GetString("ReportType")
  1492. var condition string
  1493. var startSize int
  1494. if pageSize <= 0 {
  1495. pageSize = utils.PageSize20
  1496. }
  1497. if currentIndex <= 0 {
  1498. currentIndex = 1
  1499. }
  1500. startSize = paging.StartIndex(currentIndex, pageSize)
  1501. var pars []interface{}
  1502. var total int
  1503. resp := new(models.CygxReportSelectionListPublicRep)
  1504. page := paging.GetPaging(currentIndex, pageSize, total)
  1505. var tbdb string
  1506. var readSql string
  1507. var reportTypeStr string
  1508. if reportType == "1" {
  1509. tbdb = "cygx_report_selection"
  1510. reportTypeStr = "bgjx"
  1511. } else if reportType == "2" {
  1512. tbdb = "cygx_research_summary"
  1513. reportTypeStr = "bzyjhz"
  1514. } else if reportType == "3" {
  1515. tbdb = "cygx_minutes_summary"
  1516. reportTypeStr = "szjyhz"
  1517. } else {
  1518. br.Msg = "请选择报告类型"
  1519. return
  1520. }
  1521. condition = ` AND publish_status = 1 `
  1522. if user.CompanyId != utils.HZ_COMPANY_ID {
  1523. condition += ` AND visible_range = 1 `
  1524. }
  1525. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1526. if err != nil {
  1527. br.Msg = "获取信息失败"
  1528. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1529. return
  1530. }
  1531. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1532. if reportType == "1" {
  1533. startSize = 0
  1534. pageSize = 1
  1535. total = 1
  1536. }
  1537. 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`
  1538. page = paging.GetPaging(currentIndex, pageSize, total)
  1539. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1540. if err != nil {
  1541. br.Msg = "获取失败"
  1542. br.ErrMsg = "获取失败,Err:" + err.Error()
  1543. return
  1544. }
  1545. for k, v := range list {
  1546. if reportType == "1" {
  1547. list[k].Abstract = v.UpdateDescription
  1548. }
  1549. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1550. if v.ReadNum == 0 {
  1551. list[k].IsRed = true
  1552. }
  1553. }
  1554. resp.List = list
  1555. resp.Paging = page
  1556. br.Ret = 200
  1557. br.Success = true
  1558. br.Msg = "获取成功"
  1559. br.Data = resp
  1560. }
  1561. // @Title 获取本周研究汇总详情
  1562. // @Description 获取本周研究汇总详情接口
  1563. // @Param ArticleId query int true "报告ID"
  1564. // @Success 200 {object} models.ResearchSummaryLetailResp
  1565. // @router /researchSummary/detail [get]
  1566. func (this *ReportController) ResearchDetail() {
  1567. br := new(models.BaseResponse).Init()
  1568. defer func() {
  1569. this.Data["json"] = br
  1570. this.ServeJSON()
  1571. }()
  1572. user := this.User
  1573. if user == nil {
  1574. br.Msg = "请重新登录"
  1575. br.Ret = 408
  1576. return
  1577. }
  1578. //uid := user.UserId
  1579. articleId, _ := this.GetInt("ArticleId")
  1580. if articleId < 0 {
  1581. br.Msg = "参数错误"
  1582. br.ErrMsg = "参数错误"
  1583. return
  1584. }
  1585. resp := new(models.ResearchSummaryLetailResp)
  1586. //判断用户权限
  1587. hasPermission, err := services.GetUserhasPermission(user)
  1588. if err != nil {
  1589. br.Msg = "获取信息失败"
  1590. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1591. }
  1592. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1593. if err != nil {
  1594. br.Msg = "获取信息失败"
  1595. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1596. return
  1597. }
  1598. //未设置全部可见的只能给弘则内部查看
  1599. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1600. resp.IsShow = true
  1601. }
  1602. resp.HasPermission = hasPermission
  1603. if hasPermission != 1 || !resp.IsShow {
  1604. br.Ret = 200
  1605. br.Success = true
  1606. br.Msg = "获取成功"
  1607. br.Data = resp
  1608. return
  1609. }
  1610. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1611. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1612. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1613. if err != nil {
  1614. br.Msg = "获取失败"
  1615. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1616. return
  1617. }
  1618. listArticleType, err := models.GetCygxArticleTypeList()
  1619. if err != nil {
  1620. br.Msg = "获取失败"
  1621. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1622. return
  1623. }
  1624. for k, v := range listFirst {
  1625. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1626. if err != nil && err.Error() != utils.ErrNoRow() {
  1627. br.Msg = "获取信息失败"
  1628. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1629. return
  1630. }
  1631. for k2, v2 := range listSecond {
  1632. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1633. if err != nil && err.Error() != utils.ErrNoRow() {
  1634. br.Msg = "获取信息失败"
  1635. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1636. return
  1637. }
  1638. for _, vType := range listArticleType {
  1639. if v2.ChartPermissionId == vType.YanxPermissionId {
  1640. listSecond[k2].IcoLink = vType.IcoLinkM
  1641. listSecond[k2].PermissionName = vType.YanxPermissionName
  1642. }
  1643. }
  1644. if len(listThird) > 0 {
  1645. for k3, v3 := range listThird {
  1646. if v3.VideoUrl != "" {
  1647. listThird[k3].IsHaveVideo = true
  1648. }
  1649. if v3.ReportLink == "0" {
  1650. listThird[k3].ReportLink = ""
  1651. }
  1652. }
  1653. listSecond[k2].List = listThird
  1654. }
  1655. }
  1656. if len(listSecond) > 0 {
  1657. listFirst[k].List = listSecond
  1658. }
  1659. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1660. if v.Type == "SDBG" {
  1661. listFirst[k].ListName = "深度报告"
  1662. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1663. } else if v.Type == "BZCHJH" {
  1664. listFirst[k].ListName = "本周晨会精华"
  1665. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1666. } else if v.Type == "CYDYJY" {
  1667. listFirst[k].ListName = "产业调研纪要"
  1668. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1669. } else if v.Type == "SSGS" {
  1670. listFirst[k].ListName = "上市公司调研纪要篇"
  1671. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1672. } else if v.Type == "SJDP" {
  1673. listFirst[k].ListName = "市场QA汇总"
  1674. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1675. } else if v.Type == "YANX" {
  1676. listFirst[k].ListName = "买方研选"
  1677. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1678. }
  1679. }
  1680. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1681. resp.List = listFirst
  1682. resp.Detail = detail
  1683. br.Ret = 200
  1684. br.Success = true
  1685. br.Msg = "获取成功"
  1686. br.Data = resp
  1687. }
  1688. // @Title 上周纪要汇总内容详情
  1689. // @Description 获取上周纪要汇总内容详情接口
  1690. // @Param ArticleId query int true "报告ID"
  1691. // @Success 200 {object} models.MinutesSummaryLetailResp
  1692. // @router /minutesSummary/detail [get]
  1693. func (this *ReportController) MinutesDetail() {
  1694. br := new(models.BaseResponse).Init()
  1695. defer func() {
  1696. this.Data["json"] = br
  1697. this.ServeJSON()
  1698. }()
  1699. user := this.User
  1700. if user == nil {
  1701. br.Msg = "请重新登录"
  1702. br.Ret = 408
  1703. return
  1704. }
  1705. articleId, _ := this.GetInt("ArticleId")
  1706. if articleId < 0 {
  1707. br.Msg = "参数错误"
  1708. br.ErrMsg = "参数错误"
  1709. return
  1710. }
  1711. resp := new(models.MinutesSummaryLetailRespV4)
  1712. //判断用户权限
  1713. hasPermission, err := services.GetUserhasPermission(user)
  1714. if err != nil {
  1715. br.Msg = "获取信息失败"
  1716. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1717. }
  1718. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1719. if err != nil {
  1720. br.Msg = "获取信息失败"
  1721. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1722. return
  1723. }
  1724. //未设置全部可见的只能给弘则内部查看
  1725. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1726. resp.IsShow = true
  1727. }
  1728. resp.HasPermission = hasPermission
  1729. if hasPermission != 1 || !resp.IsShow {
  1730. br.Ret = 200
  1731. br.Success = true
  1732. br.Msg = "获取成功"
  1733. br.Data = resp
  1734. return
  1735. }
  1736. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1737. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1738. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1739. if err != nil {
  1740. br.Msg = "获取失败"
  1741. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1742. return
  1743. }
  1744. for k, v := range listFirst {
  1745. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1746. if err != nil && err.Error() != utils.ErrNoRow() {
  1747. br.Msg = "获取信息失败"
  1748. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1749. return
  1750. }
  1751. for k2, v2 := range listSecond {
  1752. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1753. if err != nil && err.Error() != utils.ErrNoRow() {
  1754. br.Msg = "获取信息失败"
  1755. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1756. return
  1757. }
  1758. if len(listThird) > 0 {
  1759. for k3, v3 := range listThird {
  1760. if v3.VideoUrl != "" {
  1761. listThird[k3].IsHaveVideo = true
  1762. }
  1763. if v3.ReportLink == "0" {
  1764. listThird[k3].ReportLink = ""
  1765. }
  1766. }
  1767. listSecond[k2].List = listThird
  1768. }
  1769. }
  1770. if len(listSecond) > 0 {
  1771. listFirst[k].List = listSecond
  1772. }
  1773. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1774. if v.Type == "CYDYJY" {
  1775. listFirst[k].ListName = "产业调研纪要"
  1776. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1777. } else if v.Type == "SSGS" {
  1778. listFirst[k].ListName = "上市公司调研纪要篇"
  1779. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1780. } else if v.Type == "YANX" {
  1781. listFirst[k].ListName = "买方研选纪要"
  1782. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1783. }
  1784. }
  1785. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1786. resp.List = listFirst
  1787. resp.Detail = detail
  1788. br.Ret = 200
  1789. br.Success = true
  1790. br.Msg = "获取成功"
  1791. br.Data = resp
  1792. }
  1793. // @Title 记录用户浏览音频回放接口
  1794. // @Description 记录用户浏览音频回放接口
  1795. // @Param request body models.ArticleIdReq true "type json string"
  1796. // @Success Ret=200 操作成功
  1797. // @router /voiceHistory/add [post]
  1798. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1799. br := new(models.BaseResponse).Init()
  1800. defer func() {
  1801. this.Data["json"] = br
  1802. this.ServeJSON()
  1803. }()
  1804. user := this.User
  1805. if user == nil {
  1806. br.Msg = "请登录"
  1807. br.ErrMsg = "请登录,用户信息为空"
  1808. br.Ret = 408
  1809. return
  1810. }
  1811. uid := user.UserId
  1812. var req models.ArticleIdReq
  1813. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1814. if err != nil {
  1815. br.Msg = "参数解析异常!"
  1816. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1817. return
  1818. }
  1819. articleId := req.ArticleId
  1820. playSeconds := req.PlaySeconds
  1821. reportType := req.ReportType
  1822. //本周研究汇总
  1823. if reportType == 2 {
  1824. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1825. if articleInfo == nil {
  1826. br.Msg = "操作失败"
  1827. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1828. return
  1829. }
  1830. if errInfo != nil {
  1831. br.Msg = "操作失败"
  1832. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1833. return
  1834. }
  1835. var sellerName string
  1836. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1837. if err != nil {
  1838. br.Msg = "报名失败!"
  1839. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1840. return
  1841. }
  1842. item := models.CygxResearchSummaryVoiceHistory{
  1843. ArticleId: articleId,
  1844. UserId: uid,
  1845. CreateTime: time.Now(),
  1846. Mobile: user.Mobile,
  1847. Email: user.Email,
  1848. CompanyId: user.CompanyId,
  1849. CompanyName: user.CompanyName,
  1850. RealName: user.RealName,
  1851. SellerName: sellerName,
  1852. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1853. ModifyTime: time.Now(),
  1854. RegisterPlatform: utils.REGISTER_PLATFORM,
  1855. }
  1856. if playSeconds != 0 {
  1857. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1858. if err != nil {
  1859. br.Msg = "操作失败"
  1860. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1861. return
  1862. }
  1863. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1864. if err != nil {
  1865. br.Msg = "更新失败"
  1866. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1867. return
  1868. }
  1869. } else {
  1870. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1871. if err != nil {
  1872. br.Msg = "操作失败"
  1873. br.ErrMsg = "操作失败,Err:" + err.Error()
  1874. return
  1875. }
  1876. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1877. if err != nil {
  1878. br.Msg = "更新失败"
  1879. br.ErrMsg = "更新失败,Err:" + err.Error()
  1880. return
  1881. }
  1882. }
  1883. } else if reportType == 3 {
  1884. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1885. if articleInfo == nil {
  1886. br.Msg = "操作失败"
  1887. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1888. return
  1889. }
  1890. if errInfo != nil {
  1891. br.Msg = "操作失败"
  1892. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1893. return
  1894. }
  1895. var sellerName string
  1896. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1897. if err != nil {
  1898. br.Msg = "报名失败!"
  1899. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1900. return
  1901. }
  1902. item := models.CygxMinutesSummaryVoiceHistory{
  1903. ArticleId: articleId,
  1904. UserId: uid,
  1905. CreateTime: time.Now(),
  1906. Mobile: user.Mobile,
  1907. Email: user.Email,
  1908. CompanyId: user.CompanyId,
  1909. CompanyName: user.CompanyName,
  1910. RealName: user.RealName,
  1911. SellerName: sellerName,
  1912. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1913. ModifyTime: time.Now(),
  1914. RegisterPlatform: utils.REGISTER_PLATFORM,
  1915. }
  1916. if playSeconds != 0 {
  1917. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1918. if err != nil {
  1919. br.Msg = "操作失败"
  1920. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1921. return
  1922. }
  1923. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1924. if err != nil {
  1925. br.Msg = "更新失败"
  1926. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1927. return
  1928. }
  1929. } else {
  1930. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1931. if err != nil {
  1932. br.Msg = "操作失败"
  1933. br.ErrMsg = "操作失败,Err:" + err.Error()
  1934. return
  1935. }
  1936. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1937. if err != nil {
  1938. br.Msg = "更新失败"
  1939. br.ErrMsg = "更新失败,Err:" + err.Error()
  1940. return
  1941. }
  1942. }
  1943. }
  1944. br.Ret = 200
  1945. br.Success = true
  1946. br.Msg = "操作成功"
  1947. return
  1948. }
  1949. // @Title 根据行业分类获取行业文章列表
  1950. // @Description 根据行业分类获取行业文章列表接口
  1951. // @Param PageSize query int true "每页数据条数"
  1952. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1953. // @Param CategoryId query int true "分类ID"
  1954. // @Param IndustrialManagementId query int false "产业ID"
  1955. // @Success 200 {object} models.TacticsListResp
  1956. // @router /tactics/list [get]
  1957. func (this *MobileReportController) TacticsList() {
  1958. br := new(models.BaseResponse).Init()
  1959. defer func() {
  1960. this.Data["json"] = br
  1961. this.ServeJSON()
  1962. }()
  1963. user := this.User
  1964. if user == nil {
  1965. br.Msg = "请重新登录"
  1966. br.Ret = 408
  1967. return
  1968. }
  1969. //uid := user.UserId
  1970. pageSize, _ := this.GetInt("PageSize")
  1971. currentIndex, _ := this.GetInt("CurrentIndex")
  1972. categoryId, _ := this.GetInt("CategoryId")
  1973. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1974. var startSize int
  1975. if pageSize <= 0 {
  1976. pageSize = utils.PageSize20
  1977. }
  1978. if currentIndex <= 0 {
  1979. currentIndex = 1
  1980. }
  1981. startSize = paging.StartIndex(currentIndex, pageSize)
  1982. //var condition string
  1983. //var pars []interface{}
  1984. var total int
  1985. var err error
  1986. resp := new(models.TacticsListResp)
  1987. page := paging.GetPaging(currentIndex, pageSize, total)
  1988. list := make([]*models.ArticleListResp, 0)
  1989. if categoryId == utils.TIME_CATEGORYID {
  1990. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  1991. if err != nil {
  1992. br.Msg = "获取信息失败"
  1993. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1994. return
  1995. }
  1996. } else {
  1997. if categoryId == utils.ACTEGORY_ID_AI_QY {
  1998. listArticle := make([]*models.HomeArticle, 0)
  1999. listArticle, total, err = services.GetAiQianYanArtilceList(0, pageSize)
  2000. if err != nil {
  2001. br.Msg = "获取信息失败"
  2002. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  2003. return
  2004. }
  2005. for _, v := range listArticle {
  2006. list = append(list, &models.ArticleListResp{
  2007. ArticleId: v.ArticleId,
  2008. Title: v.Title,
  2009. CategoryId: v.CategoryId,
  2010. Annotation: v.Annotation,
  2011. Abstract: v.Abstract,
  2012. Body: v.Body,
  2013. PublishDate: v.PublishDate,
  2014. Resource: v.Resource,
  2015. })
  2016. }
  2017. } else {
  2018. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2019. if err != nil {
  2020. br.Msg = "获取信息失败"
  2021. br.Msg = "GetHomeList,Err:" + err.Error()
  2022. return
  2023. }
  2024. }
  2025. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2026. if err != nil {
  2027. br.Msg = "获取信息失败"
  2028. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2029. return
  2030. }
  2031. for k, v := range list {
  2032. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2033. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2034. list[k].IsRed = true
  2035. }
  2036. }
  2037. if categoryId > 0 {
  2038. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2039. if errCategory != nil {
  2040. br.Msg = "获取信息失败"
  2041. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2042. return
  2043. }
  2044. resp.MatchTypeName = detail.MatchTypeName
  2045. }
  2046. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2047. }
  2048. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2049. if err != nil {
  2050. br.Msg = "获取失败"
  2051. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2052. return
  2053. }
  2054. listResp := make([]*models.HomeArticle, 0)
  2055. for _, v := range listPublic {
  2056. listResp = append(listResp, &models.HomeArticle{
  2057. ArticleId: v.ArticleId,
  2058. Title: v.Title,
  2059. Annotation: "核心观点:" + v.Annotation,
  2060. Abstract: v.Abstract,
  2061. ImgUrlPc: v.ImgUrlPc,
  2062. PublishDate: v.PublishDate,
  2063. Resource: v.Resource,
  2064. })
  2065. }
  2066. if len(listResp) == 0 {
  2067. listResp = make([]*models.HomeArticle, 0)
  2068. }
  2069. page = paging.GetPaging(currentIndex, pageSize, total)
  2070. resp.List = listResp
  2071. resp.Paging = page
  2072. br.Ret = 200
  2073. br.Success = true
  2074. br.Msg = "获取成功"
  2075. br.Data = resp
  2076. }