ElogCoachAPI.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // ElogCoachAPI.swift
  3. // JiaPeiManage
  4. //
  5. // Created by Ning.ge on 2023/8/30.
  6. //
  7. import Moya
  8. import SwiftyUserDefaults
  9. enum ElogCoachAPI {
  10. //根据学员id获取电子教学日志
  11. case elogTmsStudentTeachLogById(city:String ,id:Int ,pageNum:Int ,pageSize:Int)
  12. //根据学员id和classId获取电子教学日志照片
  13. case elogTmsStudentPhotoById(city:String ,classId:String ,id:Int ,pageNum:Int ,pageSize:Int)
  14. }
  15. extension ElogCoachAPI: TargetType {
  16. var baseURL: URL {
  17. switch self {
  18. case .elogTmsStudentTeachLogById,.elogTmsStudentPhotoById:
  19. return URL(string: HttpRequest.api.path)!
  20. }
  21. }
  22. var path: String {
  23. // city:String ,coachId:String ,field:String ,pageNum:Int ,pageSize:Int ,schoolId:Int
  24. switch self {
  25. case .elogTmsStudentTeachLogById(_,_,_,_):
  26. return "/jsjp-admin/open-api/tms/coachInfo/getTmsStudentTeachLogById"
  27. case .elogTmsStudentPhotoById(_,_,_,_,_):
  28. return "/jsjp-admin/open-api/tms/coachInfo/getTmsStudentPhotoById"
  29. }
  30. }
  31. var method: Moya.Method {
  32. switch self {
  33. case .elogTmsStudentTeachLogById,.elogTmsStudentPhotoById:
  34. return .get
  35. default:
  36. return .get
  37. }
  38. }
  39. var sampleData: Data {
  40. return Data()
  41. }
  42. var task: Moya.Task {
  43. switch self {
  44. case .elogTmsStudentTeachLogById(_,_,_,_),.elogTmsStudentPhotoById(_,_,_,_,_):
  45. if let parameters = parameters {
  46. return .requestParameters(parameters: parameters, encoding: URLEncoding.default)
  47. }
  48. return .requestPlain
  49. }
  50. }
  51. var headers: [String: String]? {
  52. return ["Content-Type":"application/json"]
  53. }
  54. var parameters: [String : Any]? {
  55. switch self {
  56. case let .elogTmsStudentTeachLogById(city, id, pageNum, pageSize):
  57. return ["city": city,
  58. "id": id,
  59. "pageNum": pageNum,
  60. "pageSize": pageSize]
  61. case let .elogTmsStudentPhotoById(city, classId, id, pageNum, pageSize):
  62. return ["city": city,
  63. "classId": classId,
  64. "id": id,
  65. "pageNum": pageNum,
  66. "pageSize": pageSize]
  67. default:
  68. return nil
  69. }
  70. }
  71. }