chart_permission.go 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. for _, v := range list {
  226. resp.List = append(resp.List, v)
  227. }
  228. br.Ret = 200
  229. br.Success = true
  230. br.Msg = "获取成功"
  231. br.Data = resp
  232. }
  233. // @Title 获取所有品种(无需token)
  234. // @Description 获取所有品种(无需token)
  235. // @Success 200 {object} models.ChartPermissionResp
  236. // @router /allPublic [get]
  237. func (this *ChartPermissionController) DetailPublic() {
  238. br := new(models.BaseResponse).Init()
  239. defer func() {
  240. this.Data["json"] = br
  241. this.ServeJSON()
  242. }()
  243. var condition string
  244. list, err := models.GetChartPermissionAll(condition)
  245. if err != nil {
  246. br.Msg = "获取信息失败"
  247. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  248. return
  249. }
  250. resp := new(models.ChartPermissionResp)
  251. for k, v := range list {
  252. resp.List = append(resp.List, v)
  253. if services.GetShowSustainable() && v.PermissionName == "研选" {
  254. resp.List[k].IsShowSustainable = true
  255. }
  256. }
  257. resp.List = list
  258. br.Ret = 200
  259. br.Success = true
  260. br.Msg = "获取成功"
  261. br.Data = resp
  262. }
  263. // @Title 获取报告所有品种7.0版本
  264. // @Description 获取报告所有品种接口7.0版本
  265. // @Success 200 {object} models.ChartPermissionResp
  266. // @router /reportallV7 [get]
  267. func (this *ChartPermissionAuthController) ReportDetailV7() {
  268. br := new(models.BaseResponse).Init()
  269. defer func() {
  270. this.Data["json"] = br
  271. this.ServeJSON()
  272. }()
  273. user := this.User
  274. if user == nil {
  275. br.Msg = "请重新登录"
  276. br.Ret = 408
  277. return
  278. }
  279. var condition string
  280. //var userType int
  281. //if user.CompanyId > 1 {
  282. // total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
  283. // if err != nil {
  284. // br.Msg = "获取失败"
  285. // br.ErrMsg = "获取失败,Err:" + err.Error()
  286. // return
  287. // }
  288. // if total == 0 {
  289. // userType = 0
  290. // } else {
  291. // companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
  292. // if err != nil {
  293. // br.Msg = "获取信息失败!"
  294. // br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  295. // return
  296. // }
  297. // if companyDetail.Status == "永续" {
  298. // userType = 1
  299. // }
  300. // }
  301. //}
  302. condition += ` AND chart_permission_id NOT IN (31,52)`
  303. list, err := models.GetChartPermissionReportAll(condition)
  304. if err != nil {
  305. br.Msg = "获取信息失败"
  306. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  307. return
  308. }
  309. resp := new(models.ChartPermissionResp)
  310. for k, v := range list {
  311. //if userType == 1 {
  312. // if v.PermissionName != "研选" {
  313. // resp.List = append(resp.List, v)
  314. // }
  315. //} else {
  316. // resp.List = append(resp.List, v)
  317. //}
  318. resp.List = append(resp.List, v)
  319. //if strings.Contains(v.PermissionName,"")
  320. if services.GetShowSustainable() && v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  321. resp.List[k].IsShowSustainable = true
  322. }
  323. }
  324. //item := new(models.ChartPermission)
  325. //item.PermissionName = utils.GU_SHOU_NAME
  326. //item.ChartPermissionId = utils.GU_SHOU_ID
  327. //resp.List = append(resp.List, item)
  328. br.Ret = 200
  329. br.Success = true
  330. br.Msg = "获取成功"
  331. br.Data = resp
  332. }
  333. // @Title 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  334. // @Description 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  335. // @Success 200 {object} models.ChartPermissionResp
  336. // @router /noyx [get]
  337. func (this *ChartPermissionAuthController) Noyx() {
  338. br := new(models.BaseResponse).Init()
  339. defer func() {
  340. this.Data["json"] = br
  341. this.ServeJSON()
  342. }()
  343. user := this.User
  344. if user == nil {
  345. br.Msg = "请重新登录"
  346. br.Ret = 408
  347. return
  348. }
  349. var condition string
  350. condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
  351. list, err := models.GetChartPermissionReportAll(condition)
  352. if err != nil {
  353. br.Msg = "获取信息失败"
  354. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  355. return
  356. }
  357. resp := new(models.ChartPermissionResp)
  358. resp.List = list
  359. br.Ret = 200
  360. br.Success = true
  361. br.Msg = "获取成功"
  362. br.Data = resp
  363. }