package com.zcloud.accident.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.accident.domain.gateway.AccidentGateway;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author fangjiakai
 * @Date 2025-10-29 14:28:45
 */
@Component
@AllArgsConstructor
public class AccidentRemoveExe {
    private final AccidentGateway accidentGateway;

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

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

