chart_permission.go 10 KB

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