123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // CoachAPI.swift
- // JiaPeiManage
- //
- // Created by Ning.ge on 2023/6/13.
- //
- import Moya
- import SwiftyUserDefaults
- enum CoachAPI {
-
- //获取教练信息
- case coachInfo(id:String ,city:String)
- //获取教练二维码
- case coachQrInfo(id:String ,city:String)
- //获取教练的学员
- case coachInfoList(city:String,appCoachId:String ,coachId:String ,field:String ,pageNum:Int ,pageSize:Int ,schoolId:Int ,state:String )
- //通过id获取学员详细
- case studentInfoById(city:String,id:Int )
- }
- extension CoachAPI: TargetType {
-
- var baseURL: URL {
- switch self {
- case .coachInfo,.coachQrInfo,.coachInfoList,.studentInfoById:
- return URL(string: HttpRequest.api.path)!
- }
- }
-
- var path: String {
- switch self {
- case .coachInfo(_,_):
- return "/jsjp-admin/open-api/tms/coachInfo/getCoachInfo"
- case .coachQrInfo(_,_):
- return "/jsjp-admin/open-api/tms/coachInfo/getCoachQrInfo"
- case .coachInfoList(_,_,_,_,_,_,_,_):
- return "/jsjp-admin/open-api/tms/coachInfo/list"
- case .studentInfoById(_,_):
- return "/jsjp-admin/open-api/tms/coachInfo/getTmsStudentInfoById"
- }
- }
-
- var method: Moya.Method {
- switch self {
- case .coachInfo,.coachQrInfo,.coachInfoList,.studentInfoById:
- return .get
- default:
- return .get
- }
- }
-
- var sampleData: Data {
- return Data()
- }
-
- var task: Moya.Task {
- switch self {
- case .coachInfo(_,_),.coachQrInfo(_,_),.coachInfoList(_,_,_,_,_,_,_,_),.studentInfoById(_,_):
- if let parameters = parameters {
- return .requestParameters(parameters: parameters, encoding: URLEncoding.default)
- }
- return .requestPlain
- }
- }
-
- var headers: [String: String]? {
- return ["Content-Type":"application/json"]
- }
-
- var parameters: [String : Any]? {
- switch self {
- case let .coachInfo(id,city):
- return ["city": city,
- "id": id,]
- case let .coachQrInfo(id,city):
- return ["city": city,
- "id": id,]
- case let .coachInfoList(city,appCoachId ,coachId ,field ,pageNum ,pageSize ,schoolId ,state):
- return ["city": city,
- "appCoachId": appCoachId,
- "coachId": coachId,
- "field": field,
- "pageNum": pageNum,
- "pageSize": pageSize,
- "schoolId": schoolId==0 ?"":"\(schoolId)",
- "state": state,]
- case let .studentInfoById(city,id):
- return ["city": city,
- "id": id,]
- default:
- return nil
- }
- }
-
-
- }
|