report.go 78 KB

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