//
//  YHHomeViewController.swift
//  galaxy
//
//  Created by EDY on 2023/12/20.
//

import UIKit
import SmartCodable

//智慧服务
class YHIntelligentServiceViewController: YHBaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        initView()
        
        testModelParse()
    }
    
    func initView() {
        navigationItem.title = "智慧服务"
        view.backgroundColor = YHColorWithHex(0xE9E9E9)
        
        
        
        
    }
    
    
    func testModelParse() {
        
        SmartConfig.debugMode = .verbose
        
        let json = """
        {
            "data": "balabala Team",
            "errorCode": 0,
            "errorMessage": "操作成功",
            "success":true,
            "test": {
                "test1": "test1-value",
                "test2": "test2-value",
                "test333": "test3-value",
            },
            "testArr":[
                {
                    "test1": "test1-value",
                    "test2": "test2-value",
                    "test333": "test3-value",
                },
                {
                    "test1": "test1-value",
                    "test2": "test2-value",
                    "test333": "test3-value",
                },
                {
                    "test1": "test1-value",
                    "test2": "test2-value",
                    "test333": "test3-value",
                }
            ]
        }
        """
        
        
        //1. json字符串 转 对象
        guard let model = NetBaseModel.deserialize(json: json) else { return }
        print("model 是 ==>",model)
        print(model)
        
        //2. 对象 转 dictionary
        let dic = model.toDictionary()
        print("dic 是 ==>",dic as Any)
        
        //3. dictionary 转 string
        let jsonString = dic?.jsonString()
        print("jsonString 是 ==>",jsonString ?? "")
        
        //4.model 转 string
        let jsonString2 = model.toJSONString()
        print("jsonString2 是 ==>",jsonString2 ?? "")
        
        //5. dic 转 model
        guard let model1 = NetBaseModel.deserialize(dict: dic) else { return }
        print("model1 是 ==>",model1)
        
    }
}
