package com.zcloud.primeport.command;

import com.zcloud.primeport.domain.gateway.EVehicleArrivalDepartureInfoGateway;
import com.zcloud.primeport.domain.model.EVehicleArrivalDepartureInfoE;
import com.zcloud.primeport.dto.EVehicleArrivalDepartureInfoAddCmd;
import com.alibaba.cola.exception.BizException;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author dearLin
 * @Date 2026-05-27 17:45:43
 */
@Component
@AllArgsConstructor
public class EVehicleArrivalDepartureInfoAddExe {
    private final EVehicleArrivalDepartureInfoGateway eVehicleArrivalDepartureInfoGateway;

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(EVehicleArrivalDepartureInfoAddCmd cmd) {
        EVehicleArrivalDepartureInfoE eVehicleArrivalDepartureInfoE = new EVehicleArrivalDepartureInfoE();
        BeanUtils.copyProperties(cmd, eVehicleArrivalDepartureInfoE);
        boolean res = false;
        try {
            res = eVehicleArrivalDepartureInfoGateway.add(eVehicleArrivalDepartureInfoE);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (!res) {
            throw new BizException("保存失败");
        }
        return true;
    }
}

