chart_permission.go 10 KB

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