chart_permission.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package services
  2. import (
  3. "encoding/json"
  4. "eta/eta_mini_api/models"
  5. "eta/eta_mini_api/utils"
  6. "fmt"
  7. )
  8. // GetChartPermissionSecondList 获取二级品种权限
  9. func GetChartPermissionSecondList(chartPermissionId int) (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
  10. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/second/list"
  11. url += fmt.Sprintf("?chartPermissonId=%d", chartPermissionId)
  12. body, err := HttpGet(url)
  13. if err != nil {
  14. return
  15. }
  16. err = json.Unmarshal(body, &resp)
  17. if err != nil {
  18. return
  19. }
  20. return
  21. }
  22. // GetChartPermissionList 获取一级品种权限
  23. func GetChartPermissionList() (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
  24. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/list"
  25. body, err := HttpGet(url)
  26. if err != nil {
  27. return
  28. }
  29. err = json.Unmarshal(body, &resp)
  30. if err != nil {
  31. return
  32. }
  33. return
  34. }
  35. // GetPublicChartPermissionList 获取公共品种权限列表
  36. func GetPublicChartPermissionList() (resp *models.ChartPermissionResp[[]*models.ChartPermissionTreeView], err error) {
  37. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/public/list"
  38. body, err := HttpGet(url)
  39. if err != nil {
  40. return
  41. }
  42. err = json.Unmarshal(body, &resp)
  43. if err != nil {
  44. return
  45. }
  46. return
  47. }
  48. // GetPrivateChartPermissionList 获取私有品种权限列表
  49. func GetPrivateChartPermissionList() (resp *models.ChartPermissionResp[[]*models.ChartPermissionTreeView], err error) {
  50. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/private/list"
  51. body, err := HttpGet(url)
  52. if err != nil {
  53. return
  54. }
  55. err = json.Unmarshal(body, &resp)
  56. if err != nil {
  57. return
  58. }
  59. return
  60. }
  61. // GetChartPermissionAllList 获取所有品种权限列表
  62. func GetChartPermissionAllList() (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
  63. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/allList"
  64. body, err := HttpGet(url)
  65. if err != nil {
  66. return
  67. }
  68. err = json.Unmarshal(body, &resp)
  69. if err != nil {
  70. return
  71. }
  72. return
  73. }
  74. // GetReportChartPermissionList 获取研报的权限列表
  75. func GetReportChartPermissionList(reportId int) (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
  76. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/detail"
  77. url += fmt.Sprintf("?ReportId=%d", reportId)
  78. body, err := HttpGet(url)
  79. if err != nil {
  80. return
  81. }
  82. err = json.Unmarshal(body, &resp)
  83. if err != nil {
  84. return
  85. }
  86. return
  87. }
  88. // GetChartPermissionListByClassifyId 根据分类id获取权限列表 scope 0:二级品种权限,1:一级品种权限,2:所有权限
  89. func GetChartPermissionListByClassifyId(classifyId, scope int) (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
  90. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/classify/detail"
  91. url += fmt.Sprintf("?ClassifyId=%d&Scope=%d", classifyId, scope)
  92. body, err := HttpGet(url)
  93. if err != nil {
  94. return
  95. }
  96. err = json.Unmarshal(body, &resp)
  97. if err != nil {
  98. return
  99. }
  100. return
  101. }
  102. // GetClassifyTreeByChartPermission 获取绑定该品种的分类树
  103. func GetClassifyTreeByChartPermission(chartPermissionId int) (resp *models.ChartPermissionResp[[]*models.ClassifyView], err error) {
  104. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/classify/tree"
  105. url += fmt.Sprintf("?ChartPermissionId=%d", chartPermissionId)
  106. body, err := HttpGet(url)
  107. if err != nil {
  108. return
  109. }
  110. err = json.Unmarshal(body, &resp)
  111. if err != nil {
  112. return
  113. }
  114. return
  115. }
  116. // GetClassifyListByChartPermission 获取绑定该品种的分类列表
  117. func GetClassifyListByChartPermission(chartPermissionId int) (resp *models.ChartPermissionResp[[]*models.ClassifyView], err error) {
  118. url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/classify/list"
  119. url += fmt.Sprintf("?ChartPermissionId=%d", chartPermissionId)
  120. body, err := HttpGet(url)
  121. if err != nil {
  122. return
  123. }
  124. err = json.Unmarshal(body, &resp)
  125. if err != nil {
  126. return
  127. }
  128. return
  129. }