//
//  TSNetWork+Business.swift
//  AIEmoji
//
//  Created by 100Years on 2025/1/16.
//

/// 基础 URL（根据需求修改）
private let baseURL = "http://ai.100yearslater.com"

enum TSNeURLType:String {
    
    case imageEmoji = "/api/image/emoji"
    case actionInfo = "/api/action/info"
    
    func getUrlString() -> String {
        return baseURL + self.rawValue
    }
}


extension TSNetworkManager {
    
    /// 通用 get 请求
    func get<T: TSBaseModel>(
        urlType: TSNeURLType,
        parameters: [String: Any]? = nil,
        responseType: T.Type? = nil,
        completion: @escaping (Result<Any, Error>) -> Void
    ) {
        let urlString = urlType.getUrlString()
        request(method: .get, urlString: urlString, parameters:parameters) { result in
            completion(result)
        }
    }


    /// 通用 POST 请求
    /// - Parameters:
    ///   - endpoint: 接口路径
    ///   - parameters: 请求参数
    ///   - responseType: 响应数据模型（可选）
    ///   - completion: 请求完成的回调
    func post<T: TSBaseModel>(
        urlType: TSNeURLType,
        parameters: [String: Any]? = nil,
        responseType: T.Type? = nil,
        completion: @escaping (Result<Any, Error>) -> Void
    ) {
        let urlString = urlType.getUrlString()
        request(method: .post, urlString: urlString, parameters:parameters) { result in
            completion(result)
        }
    }
    
}



