chart_permission.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. package controllers
  2. import (
  3. "hongze/hongze_cygx/models"
  4. "hongze/hongze_cygx/services"
  5. "hongze/hongze_cygx/utils"
  6. )
  7. // 品种
  8. type ChartPermissionController struct {
  9. BaseCommonController
  10. }
  11. type ChartPermissionAuthController struct {
  12. BaseAuthController
  13. }
  14. // @Title 获取所有品种
  15. // @Description 获取用户详情接口
  16. // @Success 200 {object} models.ChartPermissionResp
  17. // @router /all [get]
  18. func (this *ChartPermissionAuthController) Detail() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. user := this.User
  25. if user == nil {
  26. br.Msg = "请重新登录"
  27. br.Ret = 408
  28. return
  29. }
  30. var condition string
  31. var userType int
  32. if user.CompanyId > 1 {
  33. total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
  34. if err != nil {
  35. br.Msg = "获取失败"
  36. br.ErrMsg = "获取失败,Err:" + err.Error()
  37. return
  38. }
  39. if total == 0 {
  40. userType = 0
  41. } else {
  42. companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
  43. if err != nil {
  44. br.Msg = "获取信息失败!"
  45. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  46. return
  47. }
  48. if companyDetail.Status == "永续" {
  49. userType = 1
  50. }
  51. }
  52. }
  53. if userType == 1 {
  54. condition += ` AND permission_name != '研选'`
  55. }
  56. condition += ` AND permission_name != '医药'`
  57. list, err := models.GetChartPermissionAll(condition)
  58. if err != nil {
  59. br.Msg = "获取信息失败"
  60. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  61. return
  62. }
  63. resp := new(models.ChartPermissionResp)
  64. for k, v := range list {
  65. //研选订阅包不进行展示
  66. if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
  67. continue
  68. }
  69. //固收不进行展示
  70. if v.ChartPermissionId == utils.GU_SHOU_ID_CHART {
  71. continue
  72. }
  73. if userType == 1 {
  74. if v.PermissionName != "研选" {
  75. resp.List = append(resp.List, v)
  76. }
  77. } else {
  78. if v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  79. v.PermissionName = "买方研选"
  80. }
  81. resp.List = append(resp.List, v)
  82. }
  83. if services.GetShowSustainable() && v.PermissionName == "研选" {
  84. resp.List[k].IsShowSustainable = true
  85. }
  86. }
  87. //resp.List = list
  88. br.Ret = 200
  89. br.Success = true
  90. br.Msg = "获取成功"
  91. br.Data = resp
  92. }
  93. // @Title 获取报告所有品种
  94. // @Description 获取报告所有品种接口
  95. // @Success 200 {object} models.ChartPermissionResp
  96. // @router /reportall [get]
  97. func (this *ChartPermissionAuthController) ReportDetail() {
  98. br := new(models.BaseResponse).Init()
  99. defer func() {
  100. this.Data["json"] = br
  101. this.ServeJSON()
  102. }()
  103. user := this.User
  104. if user == nil {
  105. br.Msg = "请重新登录"
  106. br.Ret = 408
  107. return
  108. }
  109. var condition string
  110. var userType int
  111. if user.CompanyId > 1 {
  112. total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
  113. if err != nil {
  114. br.Msg = "获取失败"
  115. br.ErrMsg = "获取失败,Err:" + err.Error()
  116. return
  117. }
  118. if total == 0 {
  119. userType = 0
  120. } else {
  121. companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
  122. if err != nil {
  123. br.Msg = "获取信息失败!"
  124. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  125. return
  126. }
  127. if companyDetail.Status == "永续" {
  128. userType = 1
  129. }
  130. }
  131. }
  132. if userType == 1 {
  133. condition += ` AND permission_name != '买方研选'`
  134. }
  135. list, err := models.GetChartPermissionReportAll(condition)
  136. if err != nil {
  137. br.Msg = "获取信息失败"
  138. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  139. return
  140. }
  141. resp := new(models.ChartPermissionResp)
  142. for k, v := range list {
  143. if userType == 1 {
  144. if v.PermissionName != "研选" {
  145. resp.List = append(resp.List, v)
  146. }
  147. } else {
  148. resp.List = append(resp.List, v)
  149. }
  150. if services.GetShowSustainable() && v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  151. resp.List[k].IsShowSustainable = true
  152. }
  153. }
  154. br.Ret = 200
  155. br.Success = true
  156. br.Msg = "获取成功"
  157. br.Data = resp
  158. }
  159. // @Title 获取策略下的所有分类
  160. // @Description 获取策略下的所有分类接口
  161. // @Param ChartPermissionId query int false "行业id"
  162. // @Success 200 {object} models.ReportMappingResp
  163. // @router /strategyAll [get]
  164. func (this *ChartPermissionAuthController) StrategyDetail() {
  165. br := new(models.BaseResponse).Init()
  166. defer func() {
  167. this.Data["json"] = br
  168. this.ServeJSON()
  169. }()
  170. user := this.User
  171. if user == nil {
  172. br.Msg = "请重新登录"
  173. br.Ret = 408
  174. return
  175. }
  176. //默认给策略的ID
  177. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  178. if chartPermissionId == 0 {
  179. chartPermissionId = utils.CE_LUE_ID
  180. }
  181. uid := user.UserId
  182. list, err := models.GetReportMappingStrategyHomeAllByCygx(chartPermissionId)
  183. if err != nil {
  184. br.Msg = "获取信息失败"
  185. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  186. return
  187. }
  188. for k, v := range list {
  189. count, err := models.GetUserIsReadThisNewCategoryArticleCount(v.CategoryId, uid)
  190. if err != nil && err.Error() != utils.ErrNoRow() {
  191. br.Msg = "获取信息失败"
  192. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  193. return
  194. }
  195. Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
  196. if err != nil {
  197. br.Msg = "获取信息失败"
  198. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  199. return
  200. }
  201. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  202. list[k].IsRed = true
  203. }
  204. }
  205. cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
  206. if err != nil {
  207. br.Msg = "获取失败"
  208. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  209. return
  210. }
  211. resp := new(models.ReportMappingHomeResp)
  212. if chartPermissionId != utils.GU_SHOU_ID_CHART {
  213. if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  214. item := new(models.ReportMappingHome)
  215. item.CategoryId = utils.TIME_LINE_ID
  216. item.SubCategoryName = utils.TIME_LINE_NAME
  217. item.MatchTypeName = utils.TIME_LINE_NAME
  218. item.ListGroup = 1
  219. resp.List = append(resp.List, item)
  220. }
  221. }
  222. for _, v := range list {
  223. resp.List = append(resp.List, v)
  224. }
  225. if chartPermissionId == utils.CE_LUE_ID {
  226. for _, v := range resp.List {
  227. switch v.ListGroup {
  228. case 1:
  229. resp.ListGroup1 = append(resp.ListGroup1, v)
  230. case 2:
  231. resp.ListGroup2 = append(resp.ListGroup2, v)
  232. case 3:
  233. resp.ListGroup3 = append(resp.ListGroup3, v)
  234. case 4:
  235. resp.ListGroup4 = append(resp.ListGroup4, v)
  236. }
  237. }
  238. }
  239. br.Ret = 200
  240. br.Success = true
  241. br.Msg = "获取成功"
  242. br.Data = resp
  243. }
  244. // @Title 获取所有品种(无需token)
  245. // @Description 获取所有品种(无需token)
  246. // @Success 200 {object} models.ChartPermissionResp
  247. // @router /allPublic [get]
  248. func (this *ChartPermissionController) DetailPublic() {
  249. br := new(models.BaseResponse).Init()
  250. defer func() {
  251. this.Data["json"] = br
  252. this.ServeJSON()
  253. }()
  254. var condition string
  255. list, err := models.GetChartPermissionAll(condition)
  256. if err != nil {
  257. br.Msg = "获取信息失败"
  258. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  259. return
  260. }
  261. resp := new(models.ChartPermissionResp)
  262. for k, v := range list {
  263. resp.List = append(resp.List, v)
  264. if services.GetShowSustainable() && v.PermissionName == "研选" {
  265. resp.List[k].IsShowSustainable = true
  266. }
  267. }
  268. resp.List = list
  269. br.Ret = 200
  270. br.Success = true
  271. br.Msg = "获取成功"
  272. br.Data = resp
  273. }
  274. // @Title 获取报告所有品种7.0版本
  275. // @Description 获取报告所有品种接口7.0版本
  276. // @Success 200 {object} models.ChartPermissionResp
  277. // @router /reportallV7 [get]
  278. func (this *ChartPermissionAuthController) ReportDetailV7() {
  279. br := new(models.BaseResponse).Init()
  280. defer func() {
  281. this.Data["json"] = br
  282. this.ServeJSON()
  283. }()
  284. user := this.User
  285. if user == nil {
  286. br.Msg = "请重新登录"
  287. br.Ret = 408
  288. return
  289. }
  290. var condition string
  291. //var userType int
  292. //if user.CompanyId > 1 {
  293. // total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
  294. // if err != nil {
  295. // br.Msg = "获取失败"
  296. // br.ErrMsg = "获取失败,Err:" + err.Error()
  297. // return
  298. // }
  299. // if total == 0 {
  300. // userType = 0
  301. // } else {
  302. // companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
  303. // if err != nil {
  304. // br.Msg = "获取信息失败!"
  305. // br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  306. // return
  307. // }
  308. // if companyDetail.Status == "永续" {
  309. // userType = 1
  310. // }
  311. // }
  312. //}
  313. condition += ` AND chart_permission_id NOT IN (31,52)`
  314. list, err := models.GetChartPermissionReportAll(condition)
  315. if err != nil {
  316. br.Msg = "获取信息失败"
  317. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  318. return
  319. }
  320. resp := new(models.ChartPermissionResp)
  321. for k, v := range list {
  322. //if userType == 1 {
  323. // if v.PermissionName != "研选" {
  324. // resp.List = append(resp.List, v)
  325. // }
  326. //} else {
  327. // resp.List = append(resp.List, v)
  328. //}
  329. resp.List = append(resp.List, v)
  330. //if strings.Contains(v.PermissionName,"")
  331. if services.GetShowSustainable() && v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  332. resp.List[k].IsShowSustainable = true
  333. }
  334. }
  335. //item := new(models.ChartPermission)
  336. //item.PermissionName = utils.GU_SHOU_NAME
  337. //item.ChartPermissionId = utils.GU_SHOU_ID
  338. //resp.List = append(resp.List, item)
  339. br.Ret = 200
  340. br.Success = true
  341. br.Msg = "获取成功"
  342. br.Data = resp
  343. }
  344. // @Title 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  345. // @Description 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  346. // @Success 200 {object} models.ChartPermissionResp
  347. // @router /noyx [get]
  348. func (this *ChartPermissionAuthController) Noyx() {
  349. br := new(models.BaseResponse).Init()
  350. defer func() {
  351. this.Data["json"] = br
  352. this.ServeJSON()
  353. }()
  354. user := this.User
  355. if user == nil {
  356. br.Msg = "请重新登录"
  357. br.Ret = 408
  358. return
  359. }
  360. var condition string
  361. condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收') `
  362. list, err := models.GetChartPermissionReportAll(condition)
  363. if err != nil {
  364. br.Msg = "获取信息失败"
  365. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  366. return
  367. }
  368. resp := new(models.ChartPermissionResp)
  369. resp.List = list
  370. br.Ret = 200
  371. br.Success = true
  372. br.Msg = "获取成功"
  373. br.Data = resp
  374. }