report.go 77 KB

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