package com.zcloud.personnel.positioning.command;

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

/**
 * web-app
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Component
@AllArgsConstructor
public class TerminalBindRemoveExe {
    private final TerminalBindGateway terminalBindGateway;

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

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