report.go 70 KB

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