package com.ruoyi.bst.device.service.impl;

import org.springframework.stereotype.Service;

import com.ruoyi.bst.device.domain.Device;
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
import com.ruoyi.bst.device.service.DeviceConverter;

@Service
public class DeviceConverterImpl implements DeviceConverter{

    @Override
    public Device toPoByCreate(Device data) {
        if (data == null) {
            return null;
        }
        Device po = new Device();
        // 设置设备基本信息
        po.setMac(data.getMac());
        po.setSn(data.getSn());
        po.setVehicleNum(data.getVehicleNum());
        po.setModelId(data.getModelId());
        po.setStatus(DeviceStatus.STORAGE.getCode());
        
        // 设置运营相关信息
        po.setMchId(data.getMchId());
        po.setAreaId(data.getAreaId());
        return po;
    }

    @Override
    public Device toPoByUpdate(Device data) {
        if (data == null) {
            return null;
        }
        Device po = new Device();
        // 设置设备基本信息
        po.setVehicleNum(data.getVehicleNum());
        po.setModelId(data.getModelId());
        
        // 设置运营相关信息
        po.setMchId(data.getMchId());
        po.setAreaId(data.getAreaId());
        return po;
        
    }
    
}
