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

import UIKit

class YHWorkIntroductionViewModel: YHBaseViewModel {
    var introducetionExampleModels: [YHWorkExampleModel]?

    override init() {
        super.init()
    }
    
    func requestIntroducetionExample(callBackBlock:@escaping (_ success: Bool?, _ error:YHErrorModel?)->()) {
        let strUrl = YHBaseUrlManager.shared.curURL() + "frontend/workInfo/item-example"
        let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
            //1. json字符串 转 对象
            guard let self = self else { return }
            guard let model = NetBaseModel.deserialize(dict: json) else {
                let error : YHErrorModel = YHErrorModel(errorCode:YHErrorCode.dictParseError.rawValue,errorMsg: YHErrorCode.dictParseError.description())
                
                callBackBlock(false,error)
                return
            }
            let dic = model.data?.peel
            guard let result = [YHWorkExampleModel].deserialize(array: dic as? [Any]) else {
                callBackBlock(false,nil)
                return
            }
            self.introducetionExampleModels = result as? [YHWorkExampleModel]
            callBackBlock(true, nil)
        } failBlock: { err in
            callBackBlock(false,err)
        }
    }
}

