import Foundation

/// API基础响应模型
struct BaseResponse<T: Codable>: Codable {
    let code: Int
    let data: T?
    let message: String?
}

/// 用户登录信息
struct UserLoginInfo: Codable {
    let userId: String
    let accessToken: String
    let refreshToken: String
    let nickname: String
    let account: String
    let email: String
    let avatarFileUrl: String?
    
    enum CodingKeys: String, CodingKey {
        case userId = "user_id"
        case accessToken = "access_token"
        case refreshToken = "refresh_token"
        case nickname
        case account
        case email
        case avatarFileUrl = "avatar_file_url"
    }
}

/// 登录响应数据
struct LoginResponseData: Codable {
    let userLoginInfo: UserLoginInfo
    let isNewUser: Bool
    
    enum CodingKeys: String, CodingKey {
        case userLoginInfo = "user_login_info"
        case isNewUser = "is_new_user"
    }
}

/// 认证响应模型
typealias AuthResponse = BaseResponse<LoginResponseData>

/// 用户信息响应数据
struct UserInfoData: Codable {
    let userId: String
    let username: String
    let avatarFileId: String?
    
    enum CodingKeys: String, CodingKey {
        case userId = "user_id"
        case username
        case avatarFileId = "avatar_file_id"
    }
}

/// 用户信息响应模型
typealias UserInfoResponse = BaseResponse<UserInfoData>
