package com.jkcredit.invoice.hub.service.carFreeCarrierBillEnd;

import com.jkcredit.invoice.hub.mapper.CarFreeCarrierBillEndMapper;
import com.jkcredit.invoice.hub.model.dto.carFreeCarrierBillEnd.CarFreeCarrierBillEndDto;
import com.jkcredit.invoice.hub.model.po.carFreeCarrierBillEnd.CarFreeCarrierBillEndPo;
import com.jkcredit.invoice.hub.service.base.BaseService;
import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
import com.jkcredit.invoice.hub.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @description:
 * @author: xusonglin
 * @create: 2020/1/17 16:15
 * @version: V1.0
 **/
@Slf4j
@Service
public class CarFreeCarrierBillEndServiceImpl extends BaseService implements CarFreeCarrierBillEndService {
    @Resource
    CarFreeCarrierBillEndMapper mapper;

    @Override
    public void saveBillEnd(CarFreeCarrierBillEndDto dto) {
        try {
            validate(dto);
            CarFreeCarrierBillEndPo po = new CarFreeCarrierBillEndPo();
            BeanUtil.copyProperties(po, dto);
            po.setCreateTime(new Date());
            mapper.insert(po);
        } catch (Exception e) {
            log.error("新增运单结束指令数据失败，失败原因：{}", e.getMessage());
            throw new ServiceException("新增运单开始指令数据失败");
        }
    }
}
