jsdw_ios/QuickLocation/API/GroupAPI.swift

56 lines
1.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// GroupAPI.swift
// QuickLocation
//
// Created by 八条 on 2026/6/1.
//
import Moya
import SwiftyUserDefaults
internal import Alamofire
/// 圈子相关API
enum GroupAPI {
/// 圈子信息
case groupInfo
/// 圈子操作(创建、解散、设为默认等)
/// - Parameters:
/// - opType: create、dismiss、setdefault
/// - requestData:[String: Any] 根据操作传入对应的值
case operate(opType: String, requestData: [String: Any])
}
extension GroupAPI: MultiTargetProtocol {
var path: String {
switch self {
case .groupInfo:
return "mapi/user/fullinfo"
case .operate:
return "mapi/group/operate"
}
}
var method: Moya.Method {
switch self {
case .groupInfo:
return .get
default:
return .post
}
}
var task: Moya.Task {
switch self {
case .groupInfo:
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
case let .operate(opType, requestData):
var params = Parameters()
params["op_type"] = opType
params.merge(requestData) { _, new in new }
return .requestParameters(parameters: params, encoding: JSONEncoding())
}
}
}