report.go 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427
  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: utils.ACTEGORY_ID_AI_QY})
  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. }
  386. //标的列表
  387. industrialSubjectList, err := models.GetIndustrialArticleGroupSubjectListByHz(industrialManagementId)
  388. if err != nil {
  389. br.Msg = "获取信息失败"
  390. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  391. return
  392. }
  393. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  394. if err != nil {
  395. br.Msg = "获取失败"
  396. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  397. return
  398. }
  399. timeLineItem := models.IndustrialToArticleCategoryRep{
  400. CategoryId: utils.TIME_CATEGORYID,
  401. MatchTypeName: "时间线",
  402. }
  403. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  404. if err != nil {
  405. br.Msg = "获取失败"
  406. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  407. return
  408. }
  409. timeLineItem.IsRed = timeLineIsRed
  410. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  411. resp := new(models.IndustrialToArticleCategoryListRep)
  412. resp.List = list
  413. resp.ListSubject = industrialSubjectList
  414. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  415. resp.IndustryName = detail.IndustryName
  416. resp.IndustrialManagementId = industrialManagementId
  417. if videoSimple != nil && videoSimple.Id > 0 {
  418. resp.IndustryVideo = videoSimple
  419. }
  420. resp.AuthInfo = au
  421. br.Ret = 200
  422. br.Success = true
  423. br.Msg = "获取成功"
  424. br.Data = resp
  425. }
  426. // @Title 根据行业分类获取文章列表
  427. // @Description根据行业分类获取文章列表接口
  428. // @Param PageSize query int true "每页数据条数"
  429. // @Param CurrentIndex query int true "当前页页码,从1开始"
  430. // @Param CategoryId query int true "分类ID"
  431. // @Param IndustrialManagementId query int false "产业ID"
  432. // @Success 200 {object} models.TacticsListResp
  433. // @router /articleList/byCategoryId [get]
  434. func (this *MobileReportController) List() {
  435. br := new(models.BaseResponse).Init()
  436. defer func() {
  437. this.Data["json"] = br
  438. this.ServeJSON()
  439. }()
  440. user := this.User
  441. if user == nil {
  442. br.Msg = "请重新登录"
  443. br.Ret = 408
  444. return
  445. }
  446. //uid := user.UserId
  447. pageSize, _ := this.GetInt("PageSize")
  448. currentIndex, _ := this.GetInt("CurrentIndex")
  449. categoryId, _ := this.GetInt("CategoryId")
  450. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  451. uid := user.UserId
  452. var startSize int
  453. if pageSize <= 0 {
  454. pageSize = utils.PageSize20
  455. }
  456. if currentIndex <= 0 {
  457. currentIndex = 1
  458. }
  459. startSize = paging.StartIndex(currentIndex, pageSize)
  460. //var condition string
  461. var pars []interface{}
  462. var total int
  463. resp := new(models.TacticsListResp)
  464. page := paging.GetPaging(currentIndex, pageSize, total)
  465. list := make([]*models.ArticleListResp, 0)
  466. if categoryId == utils.TIME_CATEGORYID {
  467. var err error
  468. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  469. if err != nil {
  470. br.Msg = "获取信息失败"
  471. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  472. return
  473. }
  474. } else {
  475. //获取该产业下所对应的行业图片
  476. //var reportType int
  477. //if industrialManagementId > 0 {
  478. // reportType = 2
  479. //} else {
  480. // reportType = 1
  481. //}
  482. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  483. //if errCategory != nil {
  484. // br.Msg = "获取信息失败"
  485. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  486. // return
  487. //}
  488. //对应行业的图片
  489. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  490. if err != nil {
  491. br.Msg = "获取数据失败"
  492. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  493. return
  494. }
  495. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  496. mapChartPermission := make(map[string]string)
  497. var permissionName string
  498. var imgUrlChartPermission string
  499. for _, v := range chartPermissionUrlList {
  500. vslice := strings.Split(v, "_")
  501. permissionName = vslice[0]
  502. imgUrlChartPermission = vslice[len(vslice)-1]
  503. mapChartPermission[permissionName] = imgUrlChartPermission
  504. }
  505. //对应分类的所图片
  506. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  513. mapCategoryUrl := make(map[string]string)
  514. var categoryIdStr string
  515. var imgUrlChart string
  516. for _, v := range categoryUrlList {
  517. vslice := strings.Split(v, "_")
  518. categoryIdStr = vslice[0]
  519. imgUrlChart = vslice[len(vslice)-1]
  520. mapCategoryUrl[categoryIdStr] = imgUrlChart
  521. }
  522. list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  523. if err != nil {
  524. br.Msg = "获取信息失败"
  525. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  526. return
  527. }
  528. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  529. if err != nil {
  530. br.Msg = "获取信息失败"
  531. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  532. return
  533. }
  534. for k, v := range list {
  535. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  536. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  537. list[k].IsRed = true
  538. }
  539. }
  540. }
  541. listPublic, err := services.HandleArticleCategoryImg(list, user)
  542. if err != nil {
  543. br.Msg = "获取失败"
  544. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  545. return
  546. }
  547. var articleIds []int
  548. for _, v := range listPublic {
  549. if v.Resource == 1 {
  550. articleIds = append(articleIds, v.ArticleId)
  551. }
  552. }
  553. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  554. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  555. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  556. listResp := make([]*models.HomeArticle, 0)
  557. //listResp :=
  558. for _, v := range listPublic {
  559. listResp = append(listResp, &models.HomeArticle{
  560. ArticleId: v.ArticleId,
  561. Title: v.Title,
  562. Annotation: "核心观点:" + v.Annotation,
  563. Abstract: v.Abstract,
  564. ImgUrlPc: v.ImgUrlPc,
  565. PublishDate: v.PublishDate,
  566. Resource: v.Resource,
  567. Pv: articleMapPv[v.ArticleId],
  568. IsCollect: articleCollectMap[v.ArticleId],
  569. CollectNum: articleCollectNumMap[v.ArticleId],
  570. })
  571. }
  572. //lenList := len(list)
  573. //for i := 0; i < lenList; i++ {
  574. // item := list[i]
  575. // list[i].Body = ""
  576. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  577. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  578. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  579. // //行业比较研究、资金流向,显示报告的摘要
  580. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  581. // list[i].Annotation = list[i].Abstract
  582. // }
  583. //}
  584. if len(listResp) == 0 {
  585. listResp = make([]*models.HomeArticle, 0)
  586. }
  587. page = paging.GetPaging(currentIndex, pageSize, total)
  588. resp.List = listResp
  589. resp.Paging = page
  590. br.Ret = 200
  591. br.Success = true
  592. br.Msg = "获取成功"
  593. br.Data = resp
  594. }
  595. // @Title 产业关注/取消关注
  596. // @Description 产业关注/取消关注 接口
  597. // @Param request body models.CygxIndustryFllowRep true "type json string"
  598. // @Success 200
  599. // @router /industrial/fllow [post]
  600. func (this *ReportController) IndustrialFllow() {
  601. br := new(models.BaseResponse).Init()
  602. defer func() {
  603. this.Data["json"] = br
  604. this.ServeJSON()
  605. }()
  606. user := this.User
  607. if user == nil {
  608. br.Msg = "请重新登录"
  609. br.Ret = 408
  610. return
  611. }
  612. uid := user.UserId
  613. var req models.CygxIndustryFllowRep
  614. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  615. if err != nil {
  616. br.Msg = "参数解析异常!"
  617. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  618. return
  619. }
  620. industrialManagementId := req.IndustrialManagementId
  621. var condition string
  622. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  623. if err != nil {
  624. br.Msg = "获取数据失败!"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. if countIndustrial == 0 {
  629. br.Msg = "产业不存在!"
  630. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  631. return
  632. }
  633. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  634. if err != nil {
  635. br.Msg = "获取数据失败!"
  636. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  637. return
  638. }
  639. resp := new(models.CygxIndustryFllowResp)
  640. item := new(models.CygxIndustryFllow)
  641. item.IndustrialManagementId = industrialManagementId
  642. item.UserId = uid
  643. item.Email = user.Email
  644. item.Mobile = user.Mobile
  645. item.RealName = user.RealName
  646. item.Source = utils.REGISTER_PLATFORM
  647. item.CompanyId = user.CompanyId
  648. item.CompanyName = user.CompanyName
  649. if count == 0 {
  650. item.Type = 1
  651. item.CreateTime = time.Now()
  652. item.ModifyTime = time.Now()
  653. _, err = models.AddCygxIndustryFllow(item)
  654. if err != nil {
  655. br.Msg = "操作失败"
  656. br.ErrMsg = "操作失败,Err:" + err.Error()
  657. return
  658. }
  659. resp.Status = 1
  660. br.Msg = "关注成功"
  661. } else {
  662. item.Type = 2
  663. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  664. if err != nil {
  665. br.Msg = "操作失败"
  666. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  667. return
  668. }
  669. resp.Status = 2
  670. br.Msg = "已取消关注"
  671. }
  672. //处理是否关注全部赛道字段
  673. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  674. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  675. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  676. br.Ret = 200
  677. br.Success = true
  678. br.Data = resp
  679. }
  680. // @Title 行业关注/取消关注
  681. // @Description 行业关注/取消关注 接口
  682. // @Param request body models.CygxCategoryFllowRep true "type json string"
  683. // @Success 200
  684. // @router /category/fllow [post]
  685. func (this *ReportController) CategoryFllow() {
  686. br := new(models.BaseResponse).Init()
  687. defer func() {
  688. this.Data["json"] = br
  689. this.ServeJSON()
  690. }()
  691. user := this.User
  692. if user == nil {
  693. br.Msg = "请重新登录"
  694. br.Ret = 408
  695. return
  696. }
  697. uid := user.UserId
  698. var req models.CygxCategoryFllowRep
  699. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  700. if err != nil {
  701. br.Msg = "参数解析异常!"
  702. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  703. return
  704. }
  705. categoryId := req.CategoryId
  706. var condition string
  707. //countCategory, err := models.GetCategoryCount(categoryId)
  708. //if err != nil {
  709. // br.Msg = "获取数据失败!"
  710. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  711. // return
  712. //}
  713. //if countCategory == 0 {
  714. // br.Msg = "产业不存在!"
  715. // br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  716. // return
  717. //}
  718. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  719. if err != nil {
  720. br.Msg = "操作失败!"
  721. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  722. return
  723. }
  724. mapReport := make(map[int]int)
  725. for _, v := range listMap {
  726. mapReport[v.Id] = v.CategoryId
  727. }
  728. if mapReport[categoryId] == 0 {
  729. br.Msg = "操作失败!"
  730. br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
  731. return
  732. }
  733. count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
  734. if err != nil {
  735. br.Msg = "获取数据失败!"
  736. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. return
  738. }
  739. resp := new(models.CygxIndustryFllowResp)
  740. if count == 0 {
  741. item := new(models.CygxXzsChooseCategory)
  742. item.CategoryId = mapReport[categoryId]
  743. item.IdCygx = categoryId
  744. item.UserId = uid
  745. item.Email = user.Email
  746. item.Mobile = user.Mobile
  747. item.RealName = user.RealName
  748. item.CompanyId = user.CompanyId
  749. item.CompanyName = user.CompanyName
  750. item.CreateTime = time.Now()
  751. item.ModifyTime = time.Now()
  752. _, err = models.AddCygxCategoryFllow(item)
  753. if err != nil {
  754. br.Msg = "操作失败"
  755. br.ErrMsg = "操作失败,Err:" + err.Error()
  756. return
  757. }
  758. resp.Status = 1
  759. br.Msg = "关注成功"
  760. } else {
  761. err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
  762. if err != nil {
  763. br.Msg = "操作失败"
  764. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  765. return
  766. }
  767. resp.Status = 2
  768. br.Msg = "已取消关注"
  769. }
  770. go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
  771. br.Ret = 200
  772. br.Success = true
  773. br.Data = resp
  774. }
  775. // @Title 报告搜索
  776. // @Description 报告搜索接口
  777. // @Param PageSize query int true "每页数据条数"
  778. // @Param CurrentIndex query int true "当前页页码,从1开始"
  779. // @Param KeyWord query string true "搜索关键词"
  780. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  781. // @Param IsAll query bool true "是否为综合 "
  782. // @Success 200 {object} models.ReoprtSearchResp
  783. // @router /searchReport [get]
  784. func (this *MobileReportController) SearchReport() {
  785. br := new(models.BaseResponse).Init()
  786. defer func() {
  787. this.Data["json"] = br
  788. this.ServeJSON()
  789. }()
  790. user := this.User
  791. if user == nil {
  792. br.Msg = "请重新登录"
  793. br.Ret = 408
  794. return
  795. }
  796. pageSize, _ := this.GetInt("PageSize")
  797. currentIndex, _ := this.GetInt("CurrentIndex")
  798. //articleType, _ := this.GetInt("ArticleType", 1)
  799. keyWord := this.GetString("KeyWord")
  800. //isAll, _ := this.GetBool("IsAll")
  801. var condition string
  802. var conditionYxSpecial string
  803. var pars []interface{}
  804. //var conditionSql string
  805. var total int
  806. var startSize int
  807. if pageSize <= 0 {
  808. pageSize = utils.PageSize20
  809. }
  810. //if isAll {
  811. // pageSize = utils.PageSize5
  812. //}
  813. if currentIndex <= 0 {
  814. currentIndex = 1
  815. }
  816. startSize = paging.StartIndex(currentIndex, pageSize)
  817. resp := new(models.ReoprtSearchResp)
  818. //匹配报告标题、
  819. //articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  820. //if err != nil {
  821. // br.Msg = "获取信息失败"
  822. // br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  823. // return
  824. //}
  825. //if articleTypeIds == "" {
  826. // br.Msg = "获取信息失败"
  827. // br.ErrMsg = "研选分类ID不能为空"
  828. // return
  829. //}
  830. //处理对应的文章类型标签按钮
  831. nameMap, styleMap, err := services.GetArticleTypeMap()
  832. if err != nil {
  833. br.Msg = "获取信息失败"
  834. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  835. return
  836. }
  837. if keyWord != "" {
  838. //if articleType == 1 {
  839. // 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 + `) `
  840. // total, err = models.GetReoprtSearchCountHz(condition)
  841. //} else {
  842. // 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 + `) `
  843. // total, err = models.GetReoprtSearchCountYx(condition)
  844. //}
  845. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body_text LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  846. conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
  847. }
  848. if err != nil {
  849. br.Msg = "获取信息失败"
  850. br.Msg = "获取总数失败,Err:" + err.Error()
  851. return
  852. }
  853. var list []*models.ArticleListResp
  854. //list := new([]models.ArticleResearchResp)
  855. //if articleType == 1 {
  856. // list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  857. //} else {
  858. // total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  859. //}
  860. total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  861. if err != nil {
  862. br.Msg = "获取信息失败"
  863. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  864. return
  865. }
  866. //return
  867. list, err = services.HandleArticleCategoryImg(list, user)
  868. if err != nil {
  869. br.Msg = "获取信息失败"
  870. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  871. return
  872. }
  873. for _, v := range list {
  874. item := models.ArticleResearchResp{
  875. ArticleId: v.ArticleId,
  876. ArticleTypeId: v.ArticleTypeId,
  877. Title: v.Title,
  878. PublishDate: v.PublishDate,
  879. DepartmentId: v.DepartmentId,
  880. NickName: v.NickName,
  881. IsCollect: v.IsCollect,
  882. Pv: v.Pv,
  883. CollectNum: v.CollectNum,
  884. Abstract: v.Abstract,
  885. Annotation: v.Annotation,
  886. ImgUrlPc: v.ImgUrlPc,
  887. ArticleTypeName: nameMap[v.ArticleTypeId],
  888. ButtonStyle: styleMap[v.ArticleTypeId],
  889. List: v.List,
  890. }
  891. if v.IsSpecial == 1 {
  892. //去除图片标签
  893. item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
  894. item.IsSpecial = true
  895. item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
  896. if v.CompanyTags != "" {
  897. item.CompanyTags = strings.Split(v.CompanyTags, ",")
  898. } else {
  899. item.CompanyTags = []string{}
  900. }
  901. if v.IndustryTags != "" {
  902. item.IndustryTags = strings.Split(v.IndustryTags, ",")
  903. } else {
  904. item.IndustryTags = []string{}
  905. }
  906. item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  907. if v.SpecialType == 1 {
  908. item.Title = "【笔记】" + item.Title
  909. } else if v.SpecialType == 2 {
  910. item.Title = "【观点】" + item.Title
  911. }
  912. if v.MyCollectNum > 0 {
  913. item.IsCollect = true
  914. }
  915. item.Resource = 2
  916. } else {
  917. if v.ReportId > 0 {
  918. item.Resource = 3
  919. item.ReportId = v.ReportId
  920. } else {
  921. item.Resource = 1
  922. }
  923. }
  924. resp.ListHz = append(resp.ListHz, &item)
  925. //if articleType == 1 {
  926. // resp.ListHz = append(resp.ListHz, &item)
  927. //} else {
  928. // resp.ListYx = append(resp.ListYx, &item)
  929. //}
  930. }
  931. //if keyWord != "" {
  932. //go services.AddUserSearchLog(user, keyWord, 5)
  933. //}
  934. if len(resp.ListHz) == 0 {
  935. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  936. }
  937. if len(resp.ListYx) == 0 {
  938. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  939. }
  940. page := paging.GetPaging(currentIndex, pageSize, total)
  941. resp.Paging = page
  942. br.Ret = 200
  943. br.Success = true
  944. br.Msg = "获取成功"
  945. br.Data = resp
  946. }
  947. // @Title 资源包搜索
  948. // @Description 资源包搜索接口
  949. // @Param KeyWord query string true "搜索关键词"
  950. // @Success 200 {object} models.SearchResourceResp
  951. // @router /searchResource [get]
  952. func (this *MobileReportController) SearchResource() {
  953. br := new(models.BaseResponse).Init()
  954. defer func() {
  955. this.Data["json"] = br
  956. this.ServeJSON()
  957. }()
  958. user := this.User
  959. if user == nil {
  960. br.Msg = "请重新登录"
  961. br.Ret = 408
  962. return
  963. }
  964. uid := user.UserId
  965. fllowList, err := models.GetUserFllowIndustrialList(uid)
  966. if err != nil {
  967. br.Msg = "获取失败"
  968. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  969. return
  970. }
  971. fllowMap := make(map[int]int)
  972. if len(fllowList) > 0 {
  973. for _, v := range fllowList {
  974. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  975. }
  976. }
  977. keyWord := this.GetString("KeyWord")
  978. var condition string
  979. //articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  980. //if err != nil {
  981. // br.Msg = "获取信息失败"
  982. // br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  983. // return
  984. //}
  985. //if articleTypeIds == "" {
  986. // br.Msg = "获取信息失败"
  987. // br.ErrMsg = "研选分类ID不能为空"
  988. // return
  989. //}
  990. condition = ` AND a.publish_status = 1 AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  991. listHz, err := models.GetSearchResourceList(condition)
  992. if err != nil {
  993. br.Msg = "获取信息失败"
  994. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  995. return
  996. }
  997. //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 + `%' ) `
  998. //listYx, err := models.GetSearchResourceList(condition)
  999. //if err != nil {
  1000. // br.Msg = "获取信息失败"
  1001. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1002. // return
  1003. //}
  1004. //if len(listYx) > 0 {
  1005. // listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1006. // if err != nil {
  1007. // br.Msg = "获取信息失败"
  1008. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1009. // return
  1010. // }
  1011. //}
  1012. if len(listHz) > 0 {
  1013. listHz, err = services.HandleIndustryListHzAndYx(listHz, user, "Hz")
  1014. if err != nil {
  1015. br.Msg = "获取信息失败"
  1016. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1017. return
  1018. }
  1019. }
  1020. //if keyWord != "" {
  1021. //go services.AddUserSearchLog(user, keyWord, 4)
  1022. //}
  1023. resp := new(models.SearchResourceResp)
  1024. if len(listHz) == 0 {
  1025. listHz = make([]*models.IndustrialManagement, 0)
  1026. }
  1027. //if len(listYx) == 0 {
  1028. // listYx = make([]*models.IndustrialManagement, 0)
  1029. //}
  1030. resp.ListHz = listHz
  1031. resp.ListYx = make([]*models.IndustrialManagement, 0)
  1032. br.Ret = 200
  1033. br.Success = true
  1034. br.Msg = "获取成功"
  1035. br.Data = resp
  1036. }
  1037. // @Title 报告搜索、资源包搜索接口
  1038. // @Description 报告搜索、资源包搜索接口接口
  1039. // @Param KeyWord query string true "搜索关键词"
  1040. // @Param PageSize query int true "每页数据条数"
  1041. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1042. // @Param SearchType query int true "1:综合,2:全部"
  1043. // @Success 200 {object} models.SearchReportAndResourceResp
  1044. // @router /searchReportAndResource [get]
  1045. func (this *MobileReportController) SearchReportAndResource() {
  1046. br := new(models.BaseResponse).Init()
  1047. defer func() {
  1048. this.Data["json"] = br
  1049. this.ServeJSON()
  1050. }()
  1051. user := this.User
  1052. if user == nil {
  1053. br.Msg = "请重新登录"
  1054. br.Ret = 408
  1055. return
  1056. }
  1057. //uid := user.UserId
  1058. keyWord := this.GetString("KeyWord")
  1059. pageSize, _ := this.GetInt("PageSize")
  1060. currentIndex, _ := this.GetInt("CurrentIndex")
  1061. searchType, _ := this.GetInt("SearchType")
  1062. var total int
  1063. var startSize int
  1064. if pageSize <= 0 {
  1065. pageSize = utils.PageSize20
  1066. }
  1067. if currentIndex <= 0 {
  1068. currentIndex = 1
  1069. }
  1070. startSize = paging.StartIndex(currentIndex, pageSize)
  1071. page := paging.GetPaging(currentIndex, pageSize, total)
  1072. var condition string
  1073. var conditionSql string
  1074. //匹配报告标题、
  1075. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1076. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1077. total, err := models.GetReoprtSearchCount(conditionSql)
  1078. if err != nil {
  1079. br.Msg = "获取信息失败"
  1080. br.Msg = "获取总数失败,Err:" + err.Error()
  1081. return
  1082. }
  1083. if searchType == 1 {
  1084. pageSize = utils.PageSize5
  1085. }
  1086. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1087. if err != nil {
  1088. br.Msg = "获取失败"
  1089. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1090. return
  1091. }
  1092. if len(ListHzReport) == 0 {
  1093. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1094. }
  1095. var conditionOr string
  1096. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1097. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1098. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1099. if err != nil {
  1100. br.Msg = "获取信息失败"
  1101. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1102. return
  1103. }
  1104. resp := new(models.SearchReportAndResourceResp)
  1105. if len(listHzResource) == 0 {
  1106. listHzResource = make([]*models.IndustrialManagement, 0)
  1107. }
  1108. if keyWord != "" {
  1109. //go services.AddUserSearchLog(user, keyWord, 5)
  1110. }
  1111. page = paging.GetPaging(currentIndex, pageSize, total)
  1112. resp.Paging = page
  1113. resp.ListHzResource = listHzResource
  1114. resp.ListHzReport = ListHzReport
  1115. br.Ret = 200
  1116. br.Success = true
  1117. br.Msg = "获取成功"
  1118. br.Data = resp
  1119. }
  1120. // @Title 公司速览
  1121. // @Description 公司速览接口
  1122. // @Param ChartPermissionId query int false "分类ID"
  1123. // @Success 200 {object} models.ArticleDataLogoListResp
  1124. // @router /companyList [get]
  1125. func (this *ReportCommonController) CompanyList() {
  1126. br := new(models.BaseResponse).Init()
  1127. defer func() {
  1128. this.Data["json"] = br
  1129. this.ServeJSON()
  1130. }()
  1131. var condition string
  1132. var pars []interface{}
  1133. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1134. if chartPermissionId > 1 {
  1135. categoryId, err := models.GetCategoryId(chartPermissionId)
  1136. if err != nil && err.Error() != utils.ErrNoRow() {
  1137. br.Msg = "获取信息失败"
  1138. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1139. return
  1140. }
  1141. if categoryId != "" {
  1142. condition += ` AND a.category_id IN (` + categoryId + `)`
  1143. }
  1144. }
  1145. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1146. list, err := models.CygxArticleDataList(condition, pars)
  1147. if err != nil {
  1148. br.Msg = "获取失败"
  1149. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1150. return
  1151. }
  1152. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1153. for i := range list {
  1154. v := list[i]
  1155. comapnyList := services.HandleArticleStock(v.Stock)
  1156. if len(comapnyList) > 1 {
  1157. for kC, vC := range comapnyList {
  1158. sliceCovers := strings.Split(v.Cover, "{|}")
  1159. cover := v.Cover
  1160. if len(sliceCovers) == len(comapnyList) {
  1161. cover = sliceCovers[kC]
  1162. }
  1163. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1164. ArticleId: v.ArticleId,
  1165. Cover: cover,
  1166. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1167. })
  1168. }
  1169. } else {
  1170. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1171. ArticleId: v.ArticleId,
  1172. Cover: v.Cover,
  1173. ComapnyList: services.HandleArticleStock(v.Stock),
  1174. })
  1175. }
  1176. }
  1177. resp := new(models.ArticleDataLogoListResp)
  1178. resp.List = listLogo
  1179. br.Ret = 200
  1180. br.Success = true
  1181. br.Msg = "获取成功"
  1182. br.Data = resp
  1183. }
  1184. // @Title 时间线
  1185. // @Description 时间线接口
  1186. // @Param PageSize query int true "每页数据条数"
  1187. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1188. // @Param IndustrialManagementId query int false "产业ID"
  1189. // @Success 200 {object} models.TacticsListResp
  1190. // @router /timeline [get]
  1191. func (this *MobileReportController) Timeline() {
  1192. br := new(models.BaseResponse).Init()
  1193. defer func() {
  1194. this.Data["json"] = br
  1195. this.ServeJSON()
  1196. }()
  1197. user := this.User
  1198. if user == nil {
  1199. br.Msg = "请重新登录"
  1200. br.Ret = 408
  1201. return
  1202. }
  1203. pageSize, _ := this.GetInt("PageSize")
  1204. currentIndex, _ := this.GetInt("CurrentIndex")
  1205. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1206. var startSize int
  1207. if pageSize <= 0 {
  1208. pageSize = utils.PageSize20
  1209. }
  1210. if currentIndex <= 0 {
  1211. currentIndex = 1
  1212. }
  1213. startSize = paging.StartIndex(currentIndex, pageSize)
  1214. var total int
  1215. resp := new(models.TacticsListTimeResp)
  1216. page := paging.GetPaging(currentIndex, pageSize, total)
  1217. list := make([]*models.TimeLineReportItem, 0)
  1218. var err error
  1219. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1220. if err != nil {
  1221. br.Msg = "获取信息失败"
  1222. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1223. return
  1224. }
  1225. //处理晨会精华关联的标的,以及要跳转的文章ID
  1226. var meetingreviewchaptIds []int
  1227. var articleIds []int
  1228. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1229. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1230. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  1231. for _, v := range list {
  1232. if v.Resource == 3 {
  1233. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1234. }
  1235. if v.Resource == 1 {
  1236. articleIds = append(articleIds, v.ArticleId)
  1237. }
  1238. }
  1239. if len(meetingreviewchaptIds) > 0 {
  1240. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1241. if err != nil {
  1242. br.Msg = "获取失败"
  1243. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1244. }
  1245. for _, v := range listMeet {
  1246. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1247. mapchaptIdListSubject[v.Id] = v.ListSubject
  1248. }
  1249. }
  1250. if len(articleIds) > 0 {
  1251. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  1252. }
  1253. //查询用户今天是否看过时间线
  1254. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1255. //if err != nil {
  1256. // br.Msg = "查询浏览记录数量失败"
  1257. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1258. // return
  1259. //}
  1260. //var recordItem *models.CygxPageHistoryRecord
  1261. //if count > 1 {
  1262. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1263. // if err != nil {
  1264. // br.Msg = "查询浏览记录失败"
  1265. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1266. // return
  1267. // }
  1268. //}
  1269. for k, v := range list {
  1270. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1271. list[k].IsRed = true
  1272. }
  1273. //timeLineRed := false
  1274. //if count < 2 && v.SubCategoryName == "时间线" {
  1275. // timeLineRed = true
  1276. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1277. // timeLineRed = true
  1278. //}
  1279. //if v.SubCategoryName == "时间线" && timeLineRed {
  1280. list[k].IsRed = true
  1281. //}
  1282. if v.VideoUrl != "" {
  1283. list[k].IsHaveVideo = true
  1284. }
  1285. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1286. if v.Resource == 3 {
  1287. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1288. v.ListSubject = mapchaptIdListSubject[v.Id]
  1289. }
  1290. if v.Resource == 1 {
  1291. v.ListSubject = mapArticleIdListSubject[v.Id]
  1292. }
  1293. }
  1294. //添加我的日程访问记录
  1295. item := new(models.CygxPageHistoryRecord)
  1296. item.UserId = user.UserId
  1297. item.CreateTime = time.Now()
  1298. item.CompanyId = user.CompanyId
  1299. item.CompanyName = user.CompanyName
  1300. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1301. go models.AddCygxPageHistoryRecord(item)
  1302. if len(list) == 0 {
  1303. list = make([]*models.TimeLineReportItem, 0)
  1304. }
  1305. go services.AddCygxTimelineLog(user, industrialManagementId)
  1306. page = paging.GetPaging(currentIndex, pageSize, total)
  1307. resp.List = list
  1308. resp.Paging = page
  1309. br.Ret = 200
  1310. br.Success = true
  1311. br.Msg = "获取成功"
  1312. br.Data = resp
  1313. }
  1314. // @Title 文章留言接口
  1315. // @Description 文章留言接口
  1316. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1317. // @Success 200 {object} models.TacticsListResp
  1318. // @router /commentAdd [post]
  1319. func (this *ReportController) CommentAdd() {
  1320. br := new(models.BaseResponse).Init()
  1321. defer func() {
  1322. this.Data["json"] = br
  1323. this.ServeJSON()
  1324. }()
  1325. user := this.User
  1326. if user == nil {
  1327. br.Msg = "请重新登录"
  1328. br.Ret = 408
  1329. return
  1330. }
  1331. var req models.AddCygxArticleCommentReq
  1332. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1333. if err != nil {
  1334. br.Msg = "参数解析异常!"
  1335. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1336. return
  1337. }
  1338. if req.ArticleId <= 0 {
  1339. br.Msg = "文章不存在"
  1340. br.ErrMsg = "文章不存在,文章ID错误"
  1341. return
  1342. }
  1343. if req.Content == "" {
  1344. br.Msg = "建议内容不可为空"
  1345. return
  1346. }
  1347. content := req.Content
  1348. if content == "" {
  1349. br.Msg = "留言内容不能为空!"
  1350. return
  1351. }
  1352. //itemToken, err := services.WxGetToken()
  1353. //if err != nil {
  1354. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1355. // return
  1356. //}
  1357. //if itemToken.AccessToken == "" {
  1358. // br.Msg = "accessToken is empty"
  1359. // return
  1360. //}
  1361. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1362. //if err != nil {
  1363. // br.Msg = "内容校验失败!"
  1364. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1365. // return
  1366. //}
  1367. //if commerr.ErrCode != 0 {
  1368. // br.Msg = "内容违规,请重新提交!"
  1369. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1370. // return
  1371. //}
  1372. articleId := req.ArticleId
  1373. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1374. if articleInfo == nil {
  1375. br.Msg = "操作失败"
  1376. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1377. return
  1378. }
  1379. if errInfo != nil {
  1380. br.Msg = "操作失败"
  1381. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1382. return
  1383. }
  1384. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1385. if err != nil {
  1386. br.Msg = "提交失败!"
  1387. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1388. return
  1389. }
  1390. if companyDetail == nil {
  1391. br.Msg = "提交失败!"
  1392. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1393. return
  1394. }
  1395. item := models.CygxArticleComment{
  1396. UserId: user.UserId,
  1397. ArticleId: req.ArticleId,
  1398. CreateTime: time.Now(),
  1399. Mobile: user.Mobile,
  1400. Email: user.Email,
  1401. CompanyId: user.CompanyId,
  1402. CompanyName: companyDetail.CompanyName,
  1403. Content: content,
  1404. Title: articleInfo.Title,
  1405. }
  1406. msgId, err := models.AddArticleComment(&item)
  1407. if err != nil {
  1408. br.Msg = "提交失败"
  1409. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1410. return
  1411. }
  1412. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1413. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  1414. br.Ret = 200
  1415. br.Success = true
  1416. br.Msg = "提交成功"
  1417. }
  1418. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1419. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1420. // @Param PageSize query int true "每页数据条数"
  1421. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1422. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1423. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1424. // @router /reportList/byType [get]
  1425. func (this *ReportController) ReportListByType() {
  1426. br := new(models.BaseResponse).Init()
  1427. defer func() {
  1428. this.Data["json"] = br
  1429. this.ServeJSON()
  1430. }()
  1431. user := this.User
  1432. if user == nil {
  1433. br.Msg = "请重新登录"
  1434. br.Ret = 408
  1435. return
  1436. }
  1437. uid := user.UserId
  1438. pageSize, _ := this.GetInt("PageSize")
  1439. currentIndex, _ := this.GetInt("CurrentIndex")
  1440. reportType := this.GetString("ReportType")
  1441. var condition string
  1442. var startSize int
  1443. if pageSize <= 0 {
  1444. pageSize = utils.PageSize20
  1445. }
  1446. if currentIndex <= 0 {
  1447. currentIndex = 1
  1448. }
  1449. startSize = paging.StartIndex(currentIndex, pageSize)
  1450. var pars []interface{}
  1451. var total int
  1452. resp := new(models.CygxReportSelectionListPublicRep)
  1453. page := paging.GetPaging(currentIndex, pageSize, total)
  1454. var tbdb string
  1455. var readSql string
  1456. var reportTypeStr string
  1457. if reportType == "1" {
  1458. tbdb = "cygx_report_selection"
  1459. reportTypeStr = "bgjx"
  1460. } else if reportType == "2" {
  1461. tbdb = "cygx_research_summary"
  1462. reportTypeStr = "bzyjhz"
  1463. } else if reportType == "3" {
  1464. tbdb = "cygx_minutes_summary"
  1465. reportTypeStr = "szjyhz"
  1466. } else {
  1467. br.Msg = "请选择报告类型"
  1468. return
  1469. }
  1470. condition = ` AND publish_status = 1 `
  1471. if user.CompanyId != utils.HZ_COMPANY_ID {
  1472. condition += ` AND visible_range = 1 `
  1473. }
  1474. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1475. if err != nil {
  1476. br.Msg = "获取信息失败"
  1477. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1478. return
  1479. }
  1480. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1481. if reportType == "1" {
  1482. startSize = 0
  1483. pageSize = 1
  1484. total = 1
  1485. }
  1486. 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`
  1487. page = paging.GetPaging(currentIndex, pageSize, total)
  1488. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1489. if err != nil {
  1490. br.Msg = "获取失败"
  1491. br.ErrMsg = "获取失败,Err:" + err.Error()
  1492. return
  1493. }
  1494. for k, v := range list {
  1495. if reportType == "1" {
  1496. list[k].Abstract = v.UpdateDescription
  1497. }
  1498. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1499. if v.ReadNum == 0 {
  1500. list[k].IsRed = true
  1501. }
  1502. }
  1503. resp.List = list
  1504. resp.Paging = page
  1505. br.Ret = 200
  1506. br.Success = true
  1507. br.Msg = "获取成功"
  1508. br.Data = resp
  1509. }
  1510. // @Title 获取本周研究汇总详情
  1511. // @Description 获取本周研究汇总详情接口
  1512. // @Param ArticleId query int true "报告ID"
  1513. // @Success 200 {object} models.ResearchSummaryLetailResp
  1514. // @router /researchSummary/detail [get]
  1515. func (this *ReportController) ResearchDetail() {
  1516. br := new(models.BaseResponse).Init()
  1517. defer func() {
  1518. this.Data["json"] = br
  1519. this.ServeJSON()
  1520. }()
  1521. user := this.User
  1522. if user == nil {
  1523. br.Msg = "请重新登录"
  1524. br.Ret = 408
  1525. return
  1526. }
  1527. //uid := user.UserId
  1528. articleId, _ := this.GetInt("ArticleId")
  1529. if articleId < 0 {
  1530. br.Msg = "参数错误"
  1531. br.ErrMsg = "参数错误"
  1532. return
  1533. }
  1534. resp := new(models.ResearchSummaryLetailResp)
  1535. //判断用户权限
  1536. hasPermission, err := services.GetUserhasPermission(user)
  1537. if err != nil {
  1538. br.Msg = "获取信息失败"
  1539. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1540. }
  1541. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1542. if err != nil {
  1543. br.Msg = "获取信息失败"
  1544. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1545. return
  1546. }
  1547. PermissionNameMap, err := services.GetPermissionNameMap()
  1548. if err != nil {
  1549. br.Msg = "获取失败"
  1550. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1551. return
  1552. }
  1553. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1554. if err != nil {
  1555. br.Msg = "获取失败"
  1556. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1557. return
  1558. }
  1559. //未设置全部可见的只能给弘则内部查看
  1560. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1561. resp.IsShow = true
  1562. }
  1563. resp.HasPermission = hasPermission
  1564. if hasPermission != 1 || !resp.IsShow {
  1565. br.Ret = 200
  1566. br.Success = true
  1567. br.Msg = "获取成功"
  1568. br.Data = resp
  1569. return
  1570. }
  1571. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1572. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1573. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1574. if err != nil {
  1575. br.Msg = "获取失败"
  1576. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1577. return
  1578. }
  1579. listArticleType, err := models.GetCygxArticleTypeList()
  1580. if err != nil {
  1581. br.Msg = "获取失败"
  1582. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1583. return
  1584. }
  1585. for k, v := range listFirst {
  1586. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1587. if err != nil && err.Error() != utils.ErrNoRow() {
  1588. br.Msg = "获取信息失败"
  1589. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1590. return
  1591. }
  1592. for k2, v2 := range listSecond {
  1593. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1594. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1595. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1596. if err != nil && err.Error() != utils.ErrNoRow() {
  1597. br.Msg = "获取信息失败"
  1598. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1599. return
  1600. }
  1601. for _, vType := range listArticleType {
  1602. if v2.ChartPermissionId == vType.YanxPermissionId {
  1603. listSecond[k2].IcoLink = vType.IcoLinkM
  1604. listSecond[k2].PermissionName = vType.YanxPermissionName
  1605. }
  1606. }
  1607. if len(listThird) > 0 {
  1608. for k3, v3 := range listThird {
  1609. if v3.VideoUrl != "" {
  1610. listThird[k3].IsHaveVideo = true
  1611. }
  1612. if v3.ReportLink == "0" {
  1613. listThird[k3].ReportLink = ""
  1614. }
  1615. }
  1616. listSecond[k2].List = listThird
  1617. }
  1618. }
  1619. if len(listSecond) > 0 {
  1620. listFirst[k].List = listSecond
  1621. }
  1622. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1623. if v.Type == "SDBG" {
  1624. listFirst[k].ListName = "深度报告"
  1625. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1626. } else if v.Type == "BZCHJH" {
  1627. listFirst[k].ListName = "本周晨会精华"
  1628. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1629. } else if v.Type == "CYDYJY" {
  1630. listFirst[k].ListName = "产业调研纪要"
  1631. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1632. } else if v.Type == "SSGS" {
  1633. listFirst[k].ListName = "上市公司调研纪要篇"
  1634. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1635. } else if v.Type == "SJDP" {
  1636. listFirst[k].ListName = "市场QA汇总"
  1637. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1638. } else if v.Type == "YANX" {
  1639. listFirst[k].ListName = "买方研选"
  1640. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1641. }
  1642. }
  1643. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1644. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1645. resp.List = listFirst
  1646. resp.Detail = detail
  1647. br.Ret = 200
  1648. br.Success = true
  1649. br.Msg = "获取成功"
  1650. br.Data = resp
  1651. }
  1652. // @Title 上周纪要汇总内容详情
  1653. // @Description 获取上周纪要汇总内容详情接口
  1654. // @Param ArticleId query int true "报告ID"
  1655. // @Success 200 {object} models.MinutesSummaryLetailResp
  1656. // @router /minutesSummary/detail [get]
  1657. func (this *ReportController) MinutesDetail() {
  1658. br := new(models.BaseResponse).Init()
  1659. defer func() {
  1660. this.Data["json"] = br
  1661. this.ServeJSON()
  1662. }()
  1663. user := this.User
  1664. if user == nil {
  1665. br.Msg = "请重新登录"
  1666. br.Ret = 408
  1667. return
  1668. }
  1669. articleId, _ := this.GetInt("ArticleId")
  1670. if articleId < 0 {
  1671. br.Msg = "参数错误"
  1672. br.ErrMsg = "参数错误"
  1673. return
  1674. }
  1675. resp := new(models.MinutesSummaryLetailRespV4)
  1676. //判断用户权限
  1677. hasPermission, err := services.GetUserhasPermission(user)
  1678. if err != nil {
  1679. br.Msg = "获取信息失败"
  1680. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1681. }
  1682. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1683. if err != nil {
  1684. br.Msg = "获取信息失败"
  1685. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1686. return
  1687. }
  1688. PermissionNameMap, err := services.GetPermissionNameMap()
  1689. if err != nil {
  1690. br.Msg = "获取失败"
  1691. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1692. return
  1693. }
  1694. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1695. if err != nil {
  1696. br.Msg = "获取失败"
  1697. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1698. return
  1699. }
  1700. //未设置全部可见的只能给弘则内部查看
  1701. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1702. resp.IsShow = true
  1703. }
  1704. resp.HasPermission = hasPermission
  1705. if hasPermission != 1 || !resp.IsShow {
  1706. br.Ret = 200
  1707. br.Success = true
  1708. br.Msg = "获取成功"
  1709. br.Data = resp
  1710. return
  1711. }
  1712. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1713. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1714. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1715. if err != nil {
  1716. br.Msg = "获取失败"
  1717. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1718. return
  1719. }
  1720. for k, v := range listFirst {
  1721. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1722. if err != nil && err.Error() != utils.ErrNoRow() {
  1723. br.Msg = "获取信息失败"
  1724. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1725. return
  1726. }
  1727. for k2, v2 := range listSecond {
  1728. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1729. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1730. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1731. if err != nil && err.Error() != utils.ErrNoRow() {
  1732. br.Msg = "获取信息失败"
  1733. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1734. return
  1735. }
  1736. if len(listThird) > 0 {
  1737. for k3, v3 := range listThird {
  1738. if v3.VideoUrl != "" {
  1739. listThird[k3].IsHaveVideo = true
  1740. }
  1741. if v3.ReportLink == "0" {
  1742. listThird[k3].ReportLink = ""
  1743. }
  1744. }
  1745. listSecond[k2].List = listThird
  1746. }
  1747. }
  1748. if len(listSecond) > 0 {
  1749. listFirst[k].List = listSecond
  1750. }
  1751. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1752. if v.Type == "CYDYJY" {
  1753. listFirst[k].ListName = "产业调研纪要"
  1754. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1755. } else if v.Type == "SSGS" {
  1756. listFirst[k].ListName = "上市公司调研纪要篇"
  1757. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1758. } else if v.Type == "YANX" {
  1759. listFirst[k].ListName = "买方研选纪要"
  1760. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1761. }
  1762. }
  1763. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1764. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1765. resp.List = listFirst
  1766. resp.Detail = detail
  1767. br.Ret = 200
  1768. br.Success = true
  1769. br.Msg = "获取成功"
  1770. br.Data = resp
  1771. }
  1772. // @Title 记录用户浏览音频回放接口
  1773. // @Description 记录用户浏览音频回放接口
  1774. // @Param request body models.ArticleIdReq true "type json string"
  1775. // @Success Ret=200 操作成功
  1776. // @router /voiceHistory/add [post]
  1777. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1778. br := new(models.BaseResponse).Init()
  1779. defer func() {
  1780. this.Data["json"] = br
  1781. this.ServeJSON()
  1782. }()
  1783. user := this.User
  1784. if user == nil {
  1785. br.Msg = "请登录"
  1786. br.ErrMsg = "请登录,用户信息为空"
  1787. br.Ret = 408
  1788. return
  1789. }
  1790. uid := user.UserId
  1791. var req models.ArticleIdReq
  1792. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1793. if err != nil {
  1794. br.Msg = "参数解析异常!"
  1795. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1796. return
  1797. }
  1798. articleId := req.ArticleId
  1799. playSeconds := req.PlaySeconds
  1800. reportType := req.ReportType
  1801. //本周研究汇总
  1802. if reportType == 2 {
  1803. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1804. if articleInfo == nil {
  1805. br.Msg = "操作失败"
  1806. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1807. return
  1808. }
  1809. if errInfo != nil {
  1810. br.Msg = "操作失败"
  1811. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1812. return
  1813. }
  1814. var sellerName string
  1815. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1816. if err != nil {
  1817. br.Msg = "报名失败!"
  1818. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1819. return
  1820. }
  1821. item := models.CygxResearchSummaryVoiceHistory{
  1822. ArticleId: articleId,
  1823. UserId: uid,
  1824. CreateTime: time.Now(),
  1825. Mobile: user.Mobile,
  1826. Email: user.Email,
  1827. CompanyId: user.CompanyId,
  1828. CompanyName: user.CompanyName,
  1829. RealName: user.RealName,
  1830. SellerName: sellerName,
  1831. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1832. ModifyTime: time.Now(),
  1833. RegisterPlatform: utils.REGISTER_PLATFORM,
  1834. }
  1835. if playSeconds != 0 {
  1836. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1837. if err != nil {
  1838. br.Msg = "操作失败"
  1839. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1840. return
  1841. }
  1842. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1843. if err != nil {
  1844. br.Msg = "更新失败"
  1845. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1846. return
  1847. }
  1848. } else {
  1849. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1850. if err != nil {
  1851. br.Msg = "操作失败"
  1852. br.ErrMsg = "操作失败,Err:" + err.Error()
  1853. return
  1854. }
  1855. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1856. if err != nil {
  1857. br.Msg = "更新失败"
  1858. br.ErrMsg = "更新失败,Err:" + err.Error()
  1859. return
  1860. }
  1861. }
  1862. } else if reportType == 3 {
  1863. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1864. if articleInfo == nil {
  1865. br.Msg = "操作失败"
  1866. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1867. return
  1868. }
  1869. if errInfo != nil {
  1870. br.Msg = "操作失败"
  1871. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1872. return
  1873. }
  1874. var sellerName string
  1875. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1876. if err != nil {
  1877. br.Msg = "报名失败!"
  1878. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1879. return
  1880. }
  1881. item := models.CygxMinutesSummaryVoiceHistory{
  1882. ArticleId: articleId,
  1883. UserId: uid,
  1884. CreateTime: time.Now(),
  1885. Mobile: user.Mobile,
  1886. Email: user.Email,
  1887. CompanyId: user.CompanyId,
  1888. CompanyName: user.CompanyName,
  1889. RealName: user.RealName,
  1890. SellerName: sellerName,
  1891. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1892. ModifyTime: time.Now(),
  1893. RegisterPlatform: utils.REGISTER_PLATFORM,
  1894. }
  1895. if playSeconds != 0 {
  1896. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1897. if err != nil {
  1898. br.Msg = "操作失败"
  1899. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1900. return
  1901. }
  1902. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1903. if err != nil {
  1904. br.Msg = "更新失败"
  1905. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1906. return
  1907. }
  1908. } else {
  1909. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1910. if err != nil {
  1911. br.Msg = "操作失败"
  1912. br.ErrMsg = "操作失败,Err:" + err.Error()
  1913. return
  1914. }
  1915. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1916. if err != nil {
  1917. br.Msg = "更新失败"
  1918. br.ErrMsg = "更新失败,Err:" + err.Error()
  1919. return
  1920. }
  1921. }
  1922. }
  1923. br.Ret = 200
  1924. br.Success = true
  1925. br.Msg = "操作成功"
  1926. return
  1927. }
  1928. // @Title 根据行业分类获取行业文章列表
  1929. // @Description 根据行业分类获取行业文章列表接口
  1930. // @Param PageSize query int true "每页数据条数"
  1931. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1932. // @Param CategoryId query int true "分类ID"
  1933. // @Param IndustrialManagementId query int false "产业ID"
  1934. // @Success 200 {object} models.TacticsListResp
  1935. // @router /tactics/list [get]
  1936. func (this *MobileReportController) TacticsList() {
  1937. br := new(models.BaseResponse).Init()
  1938. defer func() {
  1939. this.Data["json"] = br
  1940. this.ServeJSON()
  1941. }()
  1942. user := this.User
  1943. if user == nil {
  1944. br.Msg = "请重新登录"
  1945. br.Ret = 408
  1946. return
  1947. }
  1948. //uid := user.UserId
  1949. pageSize, _ := this.GetInt("PageSize")
  1950. currentIndex, _ := this.GetInt("CurrentIndex")
  1951. categoryId, _ := this.GetInt("CategoryId")
  1952. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1953. var startSize int
  1954. if pageSize <= 0 {
  1955. pageSize = utils.PageSize20
  1956. }
  1957. if currentIndex <= 0 {
  1958. currentIndex = 1
  1959. }
  1960. startSize = paging.StartIndex(currentIndex, pageSize)
  1961. //var condition string
  1962. //var pars []interface{}
  1963. var total int
  1964. var err error
  1965. resp := new(models.TacticsListResp)
  1966. page := paging.GetPaging(currentIndex, pageSize, total)
  1967. list := make([]*models.ArticleListResp, 0)
  1968. if categoryId == utils.TIME_CATEGORYID {
  1969. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  1970. if err != nil {
  1971. br.Msg = "获取信息失败"
  1972. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1973. return
  1974. }
  1975. } else {
  1976. if categoryId == utils.ACTEGORY_ID_AI_QY {
  1977. listArticle := make([]*models.HomeArticle, 0)
  1978. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  1979. if err != nil {
  1980. br.Msg = "获取信息失败"
  1981. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  1982. return
  1983. }
  1984. for _, v := range listArticle {
  1985. list = append(list, &models.ArticleListResp{
  1986. ArticleId: v.ArticleId,
  1987. Title: v.Title,
  1988. CategoryId: v.CategoryId,
  1989. Annotation: v.Annotation,
  1990. Abstract: v.Abstract,
  1991. Body: v.Body,
  1992. PublishDate: v.PublishDate,
  1993. Resource: 1,
  1994. })
  1995. }
  1996. } else {
  1997. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  1998. if err != nil {
  1999. br.Msg = "获取信息失败"
  2000. br.Msg = "GetHomeList,Err:" + err.Error()
  2001. return
  2002. }
  2003. }
  2004. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2005. if err != nil {
  2006. br.Msg = "获取信息失败"
  2007. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2008. return
  2009. }
  2010. for k, v := range list {
  2011. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2012. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2013. list[k].IsRed = true
  2014. }
  2015. }
  2016. if categoryId > 0 {
  2017. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2018. if errCategory != nil {
  2019. br.Msg = "获取信息失败"
  2020. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2021. return
  2022. }
  2023. resp.MatchTypeName = detail.MatchTypeName
  2024. }
  2025. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2026. }
  2027. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2028. if err != nil {
  2029. br.Msg = "获取失败"
  2030. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2031. return
  2032. }
  2033. var articleIds []int
  2034. var productInteriorIs []int
  2035. for _, v := range listPublic {
  2036. if v.Resource == 1 {
  2037. articleIds = append(articleIds, v.ArticleId)
  2038. }
  2039. if v.Resource == 2 {
  2040. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2041. }
  2042. }
  2043. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2044. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2045. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2046. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2047. listResp := make([]*models.HomeArticle, 0)
  2048. for _, v := range listPublic {
  2049. item := new(models.HomeArticle)
  2050. item.ArticleId = v.ArticleId
  2051. item.ReportId = v.ReportId
  2052. item.Title = v.Title
  2053. item.Annotation = v.Annotation
  2054. item.Abstract = v.Abstract
  2055. item.ImgUrlPc = v.ImgUrlPc
  2056. item.PublishDate = v.PublishDate
  2057. item.Resource = v.Resource
  2058. if v.Resource == 1 {
  2059. item.Pv = articleMapPv[v.ArticleId]
  2060. item.IsCollect = articleCollectMap[v.ArticleId]
  2061. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2062. }
  2063. if v.Resource == 2 {
  2064. item.Pv = productInteriorMapPv[v.ArticleId]
  2065. }
  2066. if v.ReportId > 0 {
  2067. item.Resource = 3
  2068. }
  2069. listResp = append(listResp, item)
  2070. }
  2071. if len(listResp) == 0 {
  2072. listResp = make([]*models.HomeArticle, 0)
  2073. }
  2074. page = paging.GetPaging(currentIndex, pageSize, total)
  2075. resp.List = listResp
  2076. resp.Paging = page
  2077. br.Ret = 200
  2078. br.Success = true
  2079. br.Msg = "获取成功"
  2080. br.Data = resp
  2081. }
  2082. // @Title 周期行业报告分类列表接口
  2083. // @Description 周期获取行业报告分类列表接口
  2084. // @Success 200 {object} models.TradeReportMappingResp
  2085. // @router /zhouqi_tradeList [get]
  2086. func (this *MobileReportController) ZouqiTradeList() {
  2087. br := new(models.BaseResponse).Init()
  2088. defer func() {
  2089. this.Data["json"] = br
  2090. this.ServeJSON()
  2091. }()
  2092. user := this.User
  2093. if user == nil {
  2094. br.Msg = "请重新登录"
  2095. br.Ret = 408
  2096. return
  2097. }
  2098. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  2099. if err != nil {
  2100. br.Msg = "获取信息失败"
  2101. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2102. return
  2103. }
  2104. fllowMap := services.GetXzsChooseCategoryZhouqiMapByMobile(user.Mobile)
  2105. resp := new(models.TradeReportMappingResp)
  2106. var list []*models.TradeReportMapping
  2107. if len(listCategory) == 0 {
  2108. list = make([]*models.TradeReportMapping, 0)
  2109. } else {
  2110. for _, v := range listCategory {
  2111. item := new(models.TradeReportMapping)
  2112. item.CategoryId = v.CategoryId
  2113. item.MatchTypeName = v.MatchTypeName
  2114. item.UpdateTime = utils.TimeRemoveHms(v.ArticleUpdateTime)
  2115. item.IsFollow = fllowMap[item.CategoryId]
  2116. item.ListArticle = make([]*models.HomeArticle, 0)
  2117. list = append(list, item)
  2118. }
  2119. }
  2120. resp.List = list
  2121. br.Ret = 200
  2122. br.Success = true
  2123. br.Msg = "获取成功"
  2124. br.Data = resp
  2125. }
  2126. // @Title 周期根据行业分类获取行业文章列表
  2127. // @Description 周期根据行业分类获取行业文章列表接口
  2128. // @Param PageSize query int true "每页数据条数"
  2129. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2130. // @Param CategoryId query int true "分类ID"
  2131. // @Success 200 {object} models.TacticsListResp
  2132. // @router /tactics/zhouqi_list [get]
  2133. func (this *MobileReportController) ZhouqiTacticsList() {
  2134. br := new(models.BaseResponse).Init()
  2135. defer func() {
  2136. this.Data["json"] = br
  2137. this.ServeJSON()
  2138. }()
  2139. user := this.User
  2140. if user == nil {
  2141. br.Msg = "请重新登录"
  2142. br.Ret = 408
  2143. return
  2144. }
  2145. //uid := user.UserId
  2146. pageSize, _ := this.GetInt("PageSize")
  2147. currentIndex, _ := this.GetInt("CurrentIndex")
  2148. categoryId, _ := this.GetInt("CategoryId")
  2149. var startSize int
  2150. if pageSize <= 0 {
  2151. pageSize = utils.PageSize20
  2152. }
  2153. if currentIndex <= 0 {
  2154. currentIndex = 1
  2155. }
  2156. startSize = paging.StartIndex(currentIndex, pageSize)
  2157. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  2158. if err != nil {
  2159. br.Msg = "获取信息失败"
  2160. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2161. return
  2162. }
  2163. var total int
  2164. //var err error
  2165. resp := new(models.TacticsListResp)
  2166. page := paging.GetPaging(currentIndex, pageSize, total)
  2167. list := make([]*models.ArticleListResp, 0)
  2168. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  2169. if err != nil {
  2170. br.Msg = "获取信息失败"
  2171. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2172. return
  2173. }
  2174. var matchTypeName = []string{}
  2175. var seriesName = []string{}
  2176. for _, v := range listCategory {
  2177. if v.MatchTypeName != "" {
  2178. matchTypeName = append(matchTypeName, v.MatchTypeName)
  2179. }
  2180. if v.SeriesName != "" {
  2181. seriesName = append(seriesName, v.SeriesName)
  2182. }
  2183. }
  2184. var conditionOr string
  2185. if detail.FiccReportId != "" {
  2186. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  2187. }
  2188. if len(seriesName) > 0 {
  2189. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  2190. }
  2191. var condition string
  2192. //var pars []interface{}
  2193. //if len(seriesName) == 0 {
  2194. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  2195. //} else {
  2196. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  2197. //}
  2198. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  2199. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  2200. if err != nil {
  2201. br.Msg = "获取信息失败"
  2202. br.Msg = "GetHomeList,Err:" + err.Error()
  2203. return
  2204. }
  2205. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2206. if err != nil {
  2207. br.Msg = "获取失败"
  2208. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2209. return
  2210. }
  2211. var articleIds []int
  2212. var productInteriorIs []int
  2213. for _, v := range listPublic {
  2214. if v.Resource == 1 {
  2215. articleIds = append(articleIds, v.ArticleId)
  2216. }
  2217. if v.Resource == 2 {
  2218. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2219. }
  2220. }
  2221. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2222. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2223. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2224. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2225. listResp := make([]*models.HomeArticle, 0)
  2226. for _, v := range listPublic {
  2227. item := new(models.HomeArticle)
  2228. item.ArticleId = v.ArticleId
  2229. item.ReportId = v.ReportId
  2230. item.Title = v.Title
  2231. item.Annotation = v.Annotation
  2232. item.Abstract = v.Abstract
  2233. item.ImgUrlPc = v.ImgUrlPc
  2234. item.PublishDate = v.PublishDate
  2235. item.Resource = v.Resource
  2236. if v.Resource == 1 {
  2237. item.Pv = articleMapPv[v.ArticleId]
  2238. item.IsCollect = articleCollectMap[v.ArticleId]
  2239. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2240. }
  2241. if v.Resource == 2 {
  2242. item.Pv = productInteriorMapPv[v.ArticleId]
  2243. }
  2244. if v.ReportId > 0 {
  2245. item.Resource = 3
  2246. }
  2247. listResp = append(listResp, item)
  2248. }
  2249. if len(listResp) == 0 {
  2250. listResp = make([]*models.HomeArticle, 0)
  2251. }
  2252. page = paging.GetPaging(currentIndex, pageSize, total)
  2253. resp.List = listResp
  2254. resp.Paging = page
  2255. br.Ret = 200
  2256. br.Success = true
  2257. br.Msg = "获取成功"
  2258. br.Data = resp
  2259. }
  2260. // @Title 周期行业关注/取消关注
  2261. // @Description 周期行业关注/取消关注 接口
  2262. // @Param request body models.CygxCategoryFllowRep true "type json string"
  2263. // @Success 200
  2264. // @router /category/zhouqi_fllow [post]
  2265. func (this *ReportController) CategoryZhouqiFllow() {
  2266. br := new(models.BaseResponse).Init()
  2267. defer func() {
  2268. this.Data["json"] = br
  2269. this.ServeJSON()
  2270. }()
  2271. user := this.User
  2272. if user == nil {
  2273. br.Msg = "请重新登录"
  2274. br.Ret = 408
  2275. return
  2276. }
  2277. uid := user.UserId
  2278. var req models.CygxCategoryFllowRep
  2279. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2280. if err != nil {
  2281. br.Msg = "参数解析异常!"
  2282. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2283. return
  2284. }
  2285. categoryId := req.CategoryId
  2286. count, err := models.GetCountCategoryFllowZhouqi(categoryId, user.Mobile)
  2287. if err != nil {
  2288. br.Msg = "获取数据失败!"
  2289. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2290. return
  2291. }
  2292. resp := new(models.CygxIndustryFllowResp)
  2293. if count == 0 {
  2294. item := new(models.CygxXzsChooseCategoryZhouqi)
  2295. item.CategoryId = categoryId
  2296. item.UserId = uid
  2297. item.Email = user.Email
  2298. item.Mobile = user.Mobile
  2299. item.RealName = user.RealName
  2300. item.CompanyId = user.CompanyId
  2301. item.CompanyName = user.CompanyName
  2302. item.CreateTime = time.Now()
  2303. item.ModifyTime = time.Now()
  2304. _, err = models.AddCygxCategoryFllowZhouqi(item)
  2305. if err != nil {
  2306. br.Msg = "操作失败"
  2307. br.ErrMsg = "操作失败,Err:" + err.Error()
  2308. return
  2309. }
  2310. resp.Status = 1
  2311. br.Msg = "关注成功"
  2312. } else {
  2313. err = models.RemoveCygxCategoryFllowZhouqi(user.Mobile, categoryId)
  2314. if err != nil {
  2315. br.Msg = "操作失败"
  2316. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  2317. return
  2318. }
  2319. resp.Status = 2
  2320. br.Msg = "已取消关注"
  2321. }
  2322. br.Ret = 200
  2323. br.Success = true
  2324. br.Data = resp
  2325. }