2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-06 c61daa1070487b6adeff3438633c10f750ac45ab
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleBindingService.java
@@ -159,6 +159,13 @@
        if (deviceCode == null) {
            throw new BusinessException("设备编号不能为空");
        }
        if (SecurityUtils.getClientId() != null) {
            //查灯杆归属关系
            boolean belong = isBelong(deviceCode, null);
            if (!belong) {
                throw new BusinessException("该灯杆不属于您,无法解绑!");
            }
        }
        //直接删除设备不需要灯杆ID
        PoleBinding one = getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode));
@@ -179,12 +186,9 @@
     *
     * @param deviceCode 设备编号
     * @param type       设备类型
     * @return 已绑定返回true,未绑定返回false
     * @return 属于该用户返回true,不是返回false
     */
    public boolean isBelong(String deviceCode, String type) {
        if (type.isEmpty() || deviceCode.isEmpty()) {
            throw new BusinessException("设备编号或类型不能为空");
        }
        Long userId = SecurityUtils.getClientId();
        Pole binding = baseMapper.getPoleByBinding(type, deviceCode, userId);
        if (binding != null) {