package com.cf.imes.module.system.convert.machine;

import com.alibaba.fastjson.JSON;
import com.cf.imes.module.system.controller.admin.machine.vo.CuttingRespVO;
import com.cf.imes.module.system.controller.admin.machine.vo.CuttingTemplateRespVO;
import com.cf.imes.module.system.controller.admin.machine.vo.CuttingTemplateSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO;

/**
 * @author Beal
 */
public class MachineTemplateConvert {

    public static CuttingRespVO convert(MachineTemplateDO templateDO) {
        return CuttingRespVO.builder()
                .labelId(templateDO.getId())
                .machineType(templateDO.getMachineType())
                .id(templateDO.getId())
                .name(templateDO.getName())
                .createTime(templateDO.getCreateTime())
                .machineSettingDO(JSON.parseObject(templateDO.getSetting()))
                .build();
    }

    public static  MachineTemplateDO convert(CuttingTemplateSaveReqVO reqVO) {
        return MachineTemplateDO.builder()
                .machineType(reqVO.getMachineType())
                .id(reqVO.getId())
                .name(reqVO.getName())
                .setting(reqVO.getSetting().toJSONString())
                .build();
    }

    public static CuttingTemplateRespVO convert1(MachineTemplateDO templateDO) {
        return CuttingTemplateRespVO.builder()
                .machineType(templateDO.getMachineType())
                .id(templateDO.getId())
                .name(templateDO.getName())
                .createTime(templateDO.getCreateTime())
                .cuttingTemplateMachineDO(JSON.parseObject(templateDO.getSetting()))
                .build();
    }
}
