x_organization_assemble_express.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import 'package:get/get.dart';
  2. import '../models/index.dart';
  3. import '../utils/index.dart';
  4. ///
  5. ///组织人员服务
  6. ///
  7. class OrganizationAssembleExpressService extends GetxService {
  8. static OrganizationAssembleExpressService get to => Get.find();
  9. //
  10. String baseUrl() {
  11. return O2ApiManager.instance.getModuleBaseUrl(
  12. O2DistributeModuleEnum.x_organization_assemble_express) ?? '';
  13. }
  14. ///
  15. /// 人员对象查询
  16. ///
  17. Future<O2Person?> person(String id) async {
  18. try {
  19. ApiResponse response = await O2HttpClient.instance.get('${baseUrl()}jaxrs/person/$id');
  20. return O2Person.fromJson(response.data);
  21. } catch (err, stackTrace) {
  22. OLogger.e('人员对象查询失败, id:$id ', err, stackTrace);
  23. }
  24. return null;
  25. }
  26. ///
  27. /// 批量获取person的DN
  28. /// @param body {"personList":["4b9df3c7-c0fa-4b64-9f98-034da8bb8f92"]}
  29. ///
  30. Future<SearchPersonList?> searchPersonDNList(List<String> personList) async {
  31. try {
  32. final body = {
  33. 'personList': personList
  34. };
  35. ApiResponse response =
  36. await O2HttpClient.instance.post('${baseUrl()}jaxrs/person/list', body);
  37. return SearchPersonList.fromJson(response.data);
  38. } catch (err, stackTrace) {
  39. OLogger.e('批量获取person的DN失败', err, stackTrace);
  40. }
  41. return null;
  42. }
  43. ///
  44. /// 根据职务、组织查询身份列表
  45. /// @param body {"nameList":["测试职务"],"unit":"人力资源部@2812170000@U"}
  46. ///
  47. Future<List<O2Identity>?> identityListByUnitAndDuty(List<String> dutyList, String parentUnit) async {
  48. try {
  49. final body = {
  50. 'nameList': dutyList,
  51. 'unit': parentUnit
  52. };
  53. ApiResponse response =
  54. await O2HttpClient.instance.post('${baseUrl()}jaxrs/unitduty/list/identity/unit/name/object', body);
  55. var list = response.data == null ? [] : response.data as List;
  56. return list.map((e) => O2Identity.fromJson(e)).toList();
  57. } catch (err, stackTrace) {
  58. OLogger.e('根据职务、组织查询身份列表失败', err, stackTrace);
  59. }
  60. return null;
  61. }
  62. ///
  63. /// 根据身份查询组织
  64. ///
  65. Future<List<O2Unit>?> unitListWithIdentities(List<String> identities) async {
  66. try {
  67. final body = {
  68. 'identityList': identities
  69. };
  70. ApiResponse response =
  71. await O2HttpClient.instance.post('${baseUrl()}jaxrs/unit/list/identity/object', body);
  72. var list = response.data == null ? [] : response.data as List;
  73. return list.map((group) => O2Unit.fromJson(group)).toList();
  74. } catch (err, stackTrace) {
  75. OLogger.e('根据身份查询组织失败', err, stackTrace);
  76. }
  77. return null;
  78. }
  79. ///
  80. /// 根据身份查询对应等级的组织
  81. ///
  82. Future<O2Unit?> unitByIdAndLevel(String identity, int level) async {
  83. try {
  84. final body = {
  85. 'identity': identity,
  86. 'level': level
  87. };
  88. ApiResponse response =
  89. await O2HttpClient.instance.post('${baseUrl()}jaxrs/unit/identity/level/object', body);
  90. return O2Unit.fromJson(response.data);
  91. } catch (err, stackTrace) {
  92. OLogger.e('根据身份查询对应等级的组织失败, identity:$identity, level: $level', err, stackTrace);
  93. }
  94. return null;
  95. }
  96. ///
  97. /// 根据人员所属的组织
  98. ///
  99. Future<List<O2Unit>?> listUnitByPerson(String person) async {
  100. try {
  101. final body = {
  102. 'personList': [person],
  103. };
  104. ApiResponse response =
  105. await O2HttpClient.instance.post('${baseUrl()}jaxrs/unit/list/person/object', body);
  106. var list = response.data == null ? [] : response.data as List;
  107. return list.map((p) => O2Unit.fromJson(p)).toList();
  108. } catch (err, stackTrace) {
  109. OLogger.e('根据人员所属的组织织失败, person:$person,', err, stackTrace);
  110. }
  111. return null;
  112. }
  113. ///
  114. /// 身份换人员对象
  115. ///
  116. Future<List<O2Person>?> listPersonWithIdentities(List<String> identities) async {
  117. try {
  118. final body = {
  119. 'identityList': identities
  120. };
  121. ApiResponse response =
  122. await O2HttpClient.instance.post('${baseUrl()}jaxrs/person/list/identity/object', body);
  123. var list = response.data == null ? [] : response.data as List;
  124. return list.map((p) => O2Person.fromJson(p)).toList();
  125. } catch (err, stackTrace) {
  126. OLogger.e('根据身份换人员对象失败', err, stackTrace);
  127. }
  128. return null;
  129. }
  130. ///
  131. /// 人员换身份对象
  132. ///
  133. Future<List<O2Identity>?> listIdentityWithPersons(List<String> persons) async {
  134. try {
  135. final body = {
  136. 'personList': persons
  137. };
  138. ApiResponse response =
  139. await O2HttpClient.instance.post('${baseUrl()}jaxrs/identity/list/person/object', body);
  140. var list = response.data == null ? [] : response.data as List;
  141. return list.map((p) => O2Identity.fromJson(p)).toList();
  142. } catch (err, stackTrace) {
  143. OLogger.e('根据人员换身份对象失败', err, stackTrace);
  144. }
  145. return null;
  146. }
  147. ///
  148. /// 获取身份对象
  149. ///
  150. Future<List<O2Identity>?> listIdentityObjects(List<String> identities) async {
  151. try {
  152. final body = {
  153. 'identityList': identities
  154. };
  155. ApiResponse response =
  156. await O2HttpClient.instance.post('${baseUrl()}jaxrs/identity/list/object', body);
  157. var list = response.data == null ? [] : response.data as List;
  158. return list.map((p) => O2Identity.fromJson(p)).toList();
  159. } catch (err, stackTrace) {
  160. OLogger.e('获取身份对象失败', err, stackTrace);
  161. }
  162. return null;
  163. }
  164. ///
  165. /// 获取组织对象
  166. ///
  167. Future<List<O2Unit>?> listUnitObjects(List<String> units) async {
  168. try {
  169. final body = {
  170. 'unitList': units
  171. };
  172. ApiResponse response =
  173. await O2HttpClient.instance.post('${baseUrl()}jaxrs/unit/list/object', body);
  174. var list = response.data == null ? [] : response.data as List;
  175. return list.map((p) => O2Unit.fromJson(p)).toList();
  176. } catch (err, stackTrace) {
  177. OLogger.e('获取组织对象失败', err, stackTrace);
  178. }
  179. return null;
  180. }
  181. /// 获取群组对象
  182. Future<List<O2Group>?> listGroupObjects(List<String> groupIds) async {
  183. try {
  184. final body = {
  185. 'groupList': groupIds
  186. };
  187. ApiResponse response = await O2HttpClient.instance.post('${baseUrl()}jaxrs/group/list/object', body);
  188. final list = response.data == null ? [] : response.data as List;
  189. return list.map((p) => O2Group.fromJson(p)).toList();
  190. } catch (err, stackTrace) {
  191. OLogger.e('获取群组对象失败', err, stackTrace);
  192. }
  193. return null;
  194. }
  195. }