//
//  YHCompanyViewModel.swift
//  galaxy
//
//  Created by EDY on 2024/2/22.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHCompanyViewModel: YHBaseViewModel {
    override init() {
        super.init()
    }
    
    func requestCompany(_ key: String, callBackBlock:@escaping (_ success: [YHCompanyModelListModel]?, _ error:YHErrorModel?)->()) {
        let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.WorkExperience.company + "?company_name=\(key)&page_size=20&current_page=1"
        YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
            //1. json字符串 转 对象
            guard let self = self else { return }
            let dic = json.data
            guard let result = YHCompanyModel.deserialize(from: dic as? Dictionary) else {
                callBackBlock([],nil)
                return
            }
            
            callBackBlock(result.list, nil)
        } failBlock: { err in
            callBackBlock([],err)
        }

    }
}

