OrganizationPermissionManager.swift 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // OrganizationPermissionManager.swift
  3. // O2Platform
  4. // 应用市场 通讯录应用 可以管理通讯录权限
  5. // Created by FancyLou on 2021/7/28.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import CocoaLumberjack
  9. class OrganizationPermissionManager {
  10. static let shared: OrganizationPermissionManager = {
  11. return OrganizationPermissionManager()
  12. }()
  13. private init() {}
  14. // 隐藏手机号码的人员列表
  15. var hideMobilePersons: [String] = []
  16. // 不查询的人员列表
  17. var excludePersons: [String] = []
  18. // 不查询的组织列表
  19. var excludeUnits: [String] = []
  20. // 不允许查询通讯录的人员
  21. var limitAll: [String] = []
  22. // 不允许查看外部门 包含人员和组织
  23. var limitOuter: [String] = []
  24. // 初始化数据
  25. func initData(data: OrganizationPermissionData) {
  26. DDLogDebug("初始化通讯录权限数据。。。。。。。")
  27. self.hideMobilePersons.removeAll()
  28. if let hidePersons = data.hideMobilePerson {
  29. let hidePersonsArr = hidePersons.split(",")
  30. for item in hidePersonsArr {
  31. self.hideMobilePersons.append(item)
  32. }
  33. }
  34. self.excludeUnits.removeAll()
  35. if let units = data.excludeUnit {
  36. let unitsArr = units.split(",")
  37. for item in unitsArr {
  38. self.excludeUnits.append(item)
  39. }
  40. }
  41. self.excludePersons.removeAll()
  42. if let eperson = data.excludePerson {
  43. let epersonArr = eperson.split(",")
  44. for item in epersonArr {
  45. self.excludePersons.append(item)
  46. }
  47. }
  48. self.limitAll.removeAll()
  49. if let all = data.limitQueryAll {
  50. let allArr = all.split(",")
  51. for item in allArr {
  52. self.limitAll.append(item)
  53. }
  54. }
  55. self.limitOuter.removeAll()
  56. if let outer = data.limitQueryOuter {
  57. let outerArr = outer.split(",")
  58. for item in outerArr {
  59. self.limitOuter.append(item)
  60. }
  61. }
  62. }
  63. /**
  64. * 判断 传入的人员是否需要隐藏手机号码
  65. * @param person 程剑@chengjian@P
  66. */
  67. func isHiddenMobile(person: String) -> Bool {
  68. return self.hideMobilePersons.contains(person)
  69. }
  70. /**
  71. * 判断 传入的人员是否要排除
  72. * @param person 程剑@chengjian@P
  73. */
  74. func isExcludePerson(person: String) -> Bool {
  75. return self.excludePersons.contains(person)
  76. }
  77. /**
  78. * 判断 传入的组织是否要排除
  79. * @param unit 团队领导@b7e3a8d3-21d4-4802-babf-9fc85392333d@U
  80. */
  81. func isExcludeUnit(unit: String) -> Bool {
  82. return self.excludeUnits.contains(unit)
  83. }
  84. /**
  85. * 判断 当前用户是否不能查询通讯录
  86. */
  87. func isCurrentPersonCannotQueryAll() -> Bool {
  88. if let currentDN = O2AuthSDK.shared.myInfo()?.distinguishedName {
  89. return self.limitAll.contains(currentDN)
  90. } else {
  91. return false
  92. }
  93. }
  94. /**
  95. * 判断 当前用户是否不能查询外部门
  96. */
  97. func isCurrentPersonCannotQueryOuter() -> Bool {
  98. if let currentDN = O2AuthSDK.shared.myInfo()?.distinguishedName {
  99. return limitOuter.contains(currentDN)
  100. } else {
  101. return false
  102. }
  103. }
  104. }