//
//  Config.swift
//  Toolboxes
//
//  Created by 研发2组 on 2025/12/4.
//


import Foundation
import ObjectMapper

/// Pub配置项
struct PubItem {
    var event: String = ""
    var chance: String = ""
}

extension PubItem: Mappable {
    init?(map: Map) {
    }
    
    mutating func mapping(map: Map) {
        event <- map["event"]
        chance <- map["chance"]
    }
}

/// 配置模型
struct Config {
    var code: Int = 0
    var msg: String = ""
    var pub: [PubItem] = []
    
    var isSuccess:Bool{
        code == 1
    }
}

extension Config: Mappable {
    init?(map: Map) {
    }
    
    mutating func mapping(map: Map) {
        code <- map["code"]
        msg <- map["msg"]
        pub <- map["pub"]
    }
}

extension Config: Parsable {
    static func parse(json: [String: Any]) -> Config? {
        return Mapper<Config>().map(JSON: json)
    }
}
