excel.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package data_manage_permission
  2. import (
  3. "eta_gn/eta_api/models/data_manage/data_manage_permission"
  4. "eta_gn/eta_api/models/data_manage/excel"
  5. "eta_gn/eta_api/utils"
  6. "fmt"
  7. )
  8. func CheckExcelPermissionByPermissionIdList(excelIsJoinPermission, excelClassifyIsJoinPermission, excelInfoId, excelClassifyId int, permissionExcelInfoIdList, permissionExcelClassifyIdList []int) (hasAuth bool) {
  9. if excelClassifyIsJoinPermission == 1 {
  10. if !utils.InArrayByInt(permissionExcelClassifyIdList, excelClassifyId) {
  11. return false
  12. }
  13. }
  14. if excelIsJoinPermission == 1 {
  15. if !utils.InArrayByInt(permissionExcelInfoIdList, excelInfoId) {
  16. return false
  17. }
  18. }
  19. hasAuth = true
  20. return
  21. }
  22. func CheckExcelClassifyPermissionByPermissionIdList(excelClassifyIsJoinPermission, excelClassifyId int, permissionExcelClassifyIdList []int) (hasAuth bool) {
  23. if excelClassifyIsJoinPermission == 1 {
  24. if !utils.InArrayByInt(permissionExcelClassifyIdList, excelClassifyId) {
  25. return
  26. }
  27. }
  28. hasAuth = true
  29. return
  30. }
  31. func GetUserExcelAndClassifyPermissionList(userId, excelInfoId, classifyId int) (excelIdList, classifyIdList []int, err error) {
  32. excelIdList, err = data_manage_permission.GetPermissionExcelIdList(userId, excelInfoId)
  33. if err != nil {
  34. fmt.Println("获取授权指标列表失败, err:", err)
  35. return
  36. }
  37. classifyIdList, err = data_manage_permission.GetPermissionExcelClassifyIdList(userId, classifyId)
  38. if err != nil {
  39. fmt.Println("获取授权指标分类列表失败, err:", err)
  40. return
  41. }
  42. return
  43. }
  44. func CheckExcelPermissionByExcelInfoId(excelInfoId, excelClassifyId, excelIsJoinPermission, userId int) (hasAuth bool, err error) {
  45. currClassify, err := excel.GetExcelClassifyById(excelClassifyId)
  46. if err != nil {
  47. return
  48. }
  49. if currClassify != nil {
  50. return CheckExcelPermission(excelIsJoinPermission, currClassify.IsJoinPermission, userId, excelInfoId, excelClassifyId)
  51. }
  52. return
  53. }
  54. func CheckExcelPermission(excelIsJoinPermission, excelClassifyIsJoinPermission, userId, excelInfoId, excelClassifyId int) (hasAuth bool, err error) {
  55. excelIdList, classifyIdList, err := GetUserExcelAndClassifyPermissionList(userId, excelInfoId, excelClassifyId)
  56. if err != nil {
  57. fmt.Println("GetUserExcelAndClassifyPermissionList err:", err)
  58. return
  59. }
  60. hasAuth = CheckExcelPermissionByPermissionIdList(excelIsJoinPermission, excelClassifyIsJoinPermission, excelInfoId, excelClassifyId, excelIdList, classifyIdList)
  61. return
  62. }