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.CuttingSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;

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

    public static MachineDO convert(CuttingSaveReqVO createReqVO) {
       return MachineDO.builder()
               .machineType(createReqVO.getMachineType())
               .name(createReqVO.getName())
               .id(createReqVO.getId())
               .labelId(createReqVO.getLabelId())
               .setting(createReqVO.getMachineSettingDO().toJSONString())
               .brandId(createReqVO.getBrandId())
               .build();

    }

    public static CuttingRespVO convert(MachineDO machineDO) {
        return CuttingRespVO.builder()
                .id(machineDO.getId())
                .machineSettingDO(JSON.parseObject(machineDO.getSetting()))
                .createTime(machineDO.getCreateTime())
                .brandId(machineDO.getBrandId())
//                .model(machineDO.getModel())
                .name(machineDO.getName())
                .machineType(machineDO.getMachineType())
                .labelId(machineDO.getLabelId())
                .build();

    }
}
