OOContactExpressAPI.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // OOContactExpressAPI.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2019/8/13.
  6. // Copyright © 2019 zoneland. All rights reserved.
  7. //
  8. import Moya
  9. //x_organization_assemble_express
  10. enum OOContactExpressAPI {
  11. //根据职务列表和组织查询 组织下对应的身份列表
  12. case identityListByUnitAndDuty([String], String)
  13. //查询人员person的dn
  14. case personListDN([String])
  15. // 人员转身份
  16. case personIdentityByPersonList([String])
  17. }
  18. extension OOContactExpressAPI: OOAPIContextCapable {
  19. var apiContextKey: String {
  20. return "x_organization_assemble_express"
  21. }
  22. }
  23. extension OOContactExpressAPI: OOAccessTokenAuthorizable {
  24. var shouldAuthorize: Bool {
  25. return true
  26. }
  27. }
  28. extension OOContactExpressAPI: TargetType {
  29. var baseURL: URL {
  30. let model = O2AuthSDK.shared.o2APIServer(context: .x_organization_assemble_express)
  31. let baseURLString = "\(model?.httpProtocol ?? "http")://\(model?.host ?? ""):\(model?.port ?? 80)\(model?.context ?? "")"
  32. if let trueUrl = O2AuthSDK.shared.bindUnitTransferUrl2Mapping(url: baseURLString) {
  33. return URL(string: trueUrl)!
  34. }
  35. return URL(string: baseURLString)!
  36. }
  37. var path: String {
  38. switch self {
  39. case .identityListByUnitAndDuty(_, _):
  40. return "/jaxrs/unitduty/list/identity/unit/name/object"
  41. case .personListDN(_):
  42. return "/jaxrs/person/list"
  43. case .personIdentityByPersonList(_):
  44. return "/jaxrs/identity/list/person"
  45. }
  46. }
  47. var method: Moya.Method {
  48. switch self {
  49. case .identityListByUnitAndDuty(_, _), .personListDN(_), .personIdentityByPersonList(_):
  50. return .post
  51. }
  52. }
  53. var sampleData: Data {
  54. return "".data(using: String.Encoding.utf8)!
  55. }
  56. var task: Task {
  57. switch self {
  58. case .identityListByUnitAndDuty(let dutyList, let unit):
  59. return .requestParameters(parameters: ["nameList": dutyList, "unit": unit], encoding: JSONEncoding.default)
  60. case .personListDN(let idList):
  61. return.requestParameters(parameters: ["personList": idList], encoding: JSONEncoding.default)
  62. case .personIdentityByPersonList(let personList):
  63. return.requestParameters(parameters: ["personList": personList], encoding: JSONEncoding.default)
  64. }
  65. }
  66. var headers: [String : String]? {
  67. return nil
  68. }
  69. }