permission_service.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package report
  2. import (
  3. logger "eta/eta_mini_ht_api/common/component/log"
  4. configService "eta/eta_mini_ht_api/domian/config"
  5. permissionDao "eta/eta_mini_ht_api/models/config"
  6. )
  7. func GetClassifyIdsByPermissionIds(permissionIds []int) (classifyIds []int, err error) {
  8. return permissionDao.GetClassifyIdsByPermissionIds(permissionIds)
  9. }
  10. func GetPermissionNamesByPermissionIds(permissionIds []int) (permissionNames []string, err error) {
  11. return permissionDao.GetPermissionNamesByPermissionIds(permissionIds)
  12. }
  13. func GetPermissionsByPermissionIds(permissionIds []int) (permissionDTOs []configService.PermissionDTO, err error) {
  14. permission, err := permissionDao.GetPermissionsByPermissionIds(permissionIds)
  15. if err != nil {
  16. return
  17. }
  18. for _, node := range permission {
  19. permissionDTOs = append(permissionDTOs, convertPermissionDTO(node))
  20. }
  21. return
  22. //return etaDao.GetPermissionNamesByPermissionIds(permissionIds)
  23. }
  24. func GetFirstPermissionsByIds(ids []int) (permissionDTOS []configService.PermissionDTO, err error) {
  25. //list, err := etaDao.GetFirstPermissionsByIds(ids)
  26. list, err := permissionDao.GetFirstPermissionsByIds(ids)
  27. if err != nil {
  28. logger.Error("查询品种信息失败:%v", err)
  29. }
  30. for _, node := range list {
  31. permissionDTOS = append(permissionDTOS, convertPermissionDTO(node))
  32. }
  33. return
  34. }
  35. // 获取一级品种(海通的板块)
  36. func GetReportPermissionsById(id int, source string) (permissionIds []configService.PermissionDTO) {
  37. switch source {
  38. case SourceETA:
  39. //展示一级品种
  40. return getETAReportFirstPermissions(id)
  41. case SourceHT:
  42. return getHTReportFirstPermissions(id)
  43. }
  44. return
  45. }
  46. func GetReportSecondPermissionsById(id int, source string) (permissionIds []configService.PermissionDTO) {
  47. switch source {
  48. case SourceETA:
  49. return getETAReportSecondPermissions(id)
  50. case SourceHT:
  51. return getHTReportSecondPermissions(id)
  52. }
  53. return
  54. }
  55. func convertPermissionDTO(node permissionDao.Permission) configService.PermissionDTO {
  56. return configService.PermissionDTO{
  57. PermissionId: node.PermissionId,
  58. PermissionName: node.Name,
  59. ParentId: node.ParentId,
  60. RiskLevel: node.RiskLevel,
  61. }
  62. }