package com.zcloud.primeport.command;

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


/**
 * web-app
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:24
 */
@Component
@AllArgsConstructor
public class VehicleAuditAddExe {
    private final VehicleAuditGateway vehicleAuditGateway;

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

