package com.zcloud.primeport.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.VehicleApplyGateway;
import com.zcloud.primeport.domain.gateway.VehicleAuditGateway;
import lombok.AllArgsConstructor;
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 VehicleApplyRemoveExe {
    private final VehicleApplyGateway vehicleApplyGateway;
    private final VehicleAuditGateway vehicleAuditGateway;

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(Long id) {
        boolean res = vehicleApplyGateway.deletedVehicleApplyById(id);
        vehicleAuditGateway.deletedVehicleAuditByApplyId(id);
        if (!res) {
            throw new BizException("删除失败");
        }
        return true;
    }

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(Long[] ids) {
        boolean res = vehicleApplyGateway.deletedVehicleApplyByIds(ids);
        if (!res) {
            throw new BizException("删除失败");
        }
        return true;
    }
}

