2021与蓝度共同重构项目,服务端
Van333
2022-12-29 727a69f859060093e685582fa10e5de82dcc138a
ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
@@ -17,6 +17,7 @@
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -34,6 +35,10 @@
     * 添加主机
     */
    public boolean addHost(InterphoneHostParam interphoneHostParam) {
        List<InterphoneHost> list = list(Wrappers.lambdaQuery(InterphoneHost.class).eq(InterphoneHost::getHostMac, interphoneHostParam.getHostMac()));
        if (list.size() > 0) {
            throw new BusinessException("该设备已存在");
        }
        InterphoneHost interphoneHost = new InterphoneHost();
        BeanUtils.copyProperties(interphoneHostParam, interphoneHost);
        boolean save = save(interphoneHost);
@@ -56,15 +61,18 @@
    /**
     * 修改主机
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean updateHost(Integer id, InterphoneHostParam interphoneHostParam) {
        InterphoneHost byId = getById(id);
        if (byId == null) {
            return false;
        }
        boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getHostMac(), PoleBindingEnums.FOR_HELP);
        if (!belong) {
            throw new BusinessException("该设备不属于您,不能修改设备信息");
        if (SecurityUtils.getClientId() != null) {
            boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getHostMac(), PoleBindingEnums.FOR_HELP);
            if (!belong) {
                throw new BusinessException("该设备不属于您,不能修改设备信息");
            }
        }
        InterphoneHost interphoneHost = new InterphoneHost();
        interphoneHost.setHostId(id);
@@ -82,7 +90,12 @@
        /**
         * 编辑一键求助主机 日志记录结束
         */
        return updateById(interphoneHost);
        boolean b = updateById(interphoneHost);
        List<InterphoneHost> list = list(Wrappers.lambdaQuery(InterphoneHost.class).eq(InterphoneHost::getHostMac, interphoneHostParam.getHostMac()));
        if (list.size() > 1) {
            throw new BusinessException("请检查设备mac是否重复");
        }
        return b;
    }
    /**
@@ -94,12 +107,13 @@
    public boolean deleteHost(Integer id) {
        InterphoneHost byId = getById(id);
        if (byId == null) {
            throw new BusinessException("主机不存在!");
        }
        InterphoneHostSubPole one = interphoneHostSubService.getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getHostId, id));
        if (one != null) {
            throw new BusinessException("该主机存在绑定关系,不能删除");
        }
        if (byId == null) {
            return false;
        }
        /**