sanlin.shi 2 months ago
parent
commit
1dc452bf76

+ 9 - 12
src/main/java/cn/hanghui/outapi/platform/tenant/service/impl/IotDeviceConfigServiceImpl.java

@@ -395,19 +395,16 @@ public class IotDeviceConfigServiceImpl extends BaseService implements IotDevice
         LambdaQueryWrapper<AccountAuthConfig> awrapper = new LambdaQueryWrapper<>();
         awrapper.eq(AccountAuthConfig::getAccountId, account.getId()).eq(AccountAuthConfig::getIsDeleted, Boolean.FALSE);
         AccountAuthConfig config = accountAuthConfigMapper.selectOne(awrapper);
-        if (Preconditions.isBlank(config) || Preconditions.isBlank(config.getHhAromeSwitch()) || !config.getHhAromeSwitch()) {
+        if (Preconditions.isBlank(config) || Preconditions.isBlank(config.getHhAromeSwitch()) || !config.getHhAromeSwitch() || Preconditions.isBlank(config.getPurchaserId())) {
             throw new BusinessException("禁止访问该资源");
         }
-        List<Long> ampeIds = commonImpl.getAuthAmpeIds(account);
-        List<Long> tenantIds = commonImpl.getAmpeTenantIds(account);
-        if (Preconditions.isBlank(ampeIds) && Preconditions.isBlank(tenantIds)) {
-//            throw new BusinessException("未找到访问资源");
-            return RestResult.ok(initEmptyPage());
-        }
-        if (Preconditions.isNotBlank(dto.getTenantId()) && !tenantIds.contains(dto.getTenantId())) {
-            throw new BusinessException("禁止访问该资源");
-        }
-//        if (Preconditions.isNotBlank(dto.getAmpeId()) && !ampeIds.contains(dto.getAmpeId())) {
+//        List<Long> ampeIds = commonImpl.getAuthAmpeIds(account);
+//        List<Long> tenantIds = commonImpl.getAmpeTenantIds(account);
+//        if (Preconditions.isBlank(ampeIds) && Preconditions.isBlank(tenantIds)) {
+//            //throw new BusinessException("未找到访问资源");
+//            return RestResult.ok(initEmptyPage());
+//        }
+//        if (Preconditions.isNotBlank(dto.getTenantId()) && !tenantIds.contains(dto.getTenantId())) {
 //            throw new BusinessException("禁止访问该资源");
 //        }
         LambdaQueryWrapper<IotDeviceConfig> wrapper = new LambdaQueryWrapper<>();
@@ -415,7 +412,7 @@ public class IotDeviceConfigServiceImpl extends BaseService implements IotDevice
         wrapper.like(StrUtil.isNotBlank(dto.getSn()), IotDeviceConfig::getSn, dto.getSn());
         wrapper.eq(Preconditions.isNotBlank(dto.getAmpeId()), IotDeviceConfig::getAmpeId, dto.getAmpeId());
         wrapper.eq(Preconditions.isNotBlank(dto.getTenantId()), IotDeviceConfig::getTenantId, dto.getTenantId());
-        wrapper.in(Preconditions.isNotBlank(tenantIds), IotDeviceConfig::getTenantId, tenantIds);
+        wrapper.eq(IotDeviceConfig::getPurchaserId, config.getPurchaserId());
         //基础条件
         wrapper.eq(IotDeviceConfig::getIsDeleted, Boolean.FALSE);
         wrapper.orderByDesc(IotDeviceConfig::getId);

+ 11 - 11
src/main/java/cn/hanghui/outapi/platform/tenant/service/impl/TenantServiceImpl.java

@@ -313,25 +313,25 @@ public class TenantServiceImpl extends BaseService implements TenantService {
         LambdaQueryWrapper<AccountAuthConfig> awrapper = new LambdaQueryWrapper<>();
         awrapper.eq(AccountAuthConfig::getAccountId, account.getId()).eq(AccountAuthConfig::getIsDeleted, Boolean.FALSE);
         AccountAuthConfig config = accountAuthConfigMapper.selectOne(awrapper);
-        if (Preconditions.isBlank(config) || Preconditions.isBlank(config.getHhFaceSwitch()) || !config.getHhFaceSwitch()) {
-            throw new BusinessException("禁止访问该资源");
-        }
-        List<Long> userLibIds = commonImpl.getAuthModuleIds(account, AuthModuleTypeEnum.HHFACE_USER_LIB);
-        List<Long> tenantIds = commonImpl.getAuthModuleIds(account, AuthModuleTypeEnum.HHFACE_TENANT);
-        if (Preconditions.isBlank(tenantIds) && Preconditions.isBlank(tenantIds)) {
-//            throw new BusinessException("未找到访问资源");
-            return RestResult.ok(initEmptyPage());
-        }
-        if (Preconditions.isNotBlank(dto.getTenantId()) && !tenantIds.contains(dto.getTenantId())) {
+        if (Preconditions.isBlank(config) || Preconditions.isBlank(config.getHhFaceSwitch()) || !config.getHhFaceSwitch() || Preconditions.isBlank(config.getPurchaserId())) {
             throw new BusinessException("禁止访问该资源");
         }
+//        List<Long> userLibIds = commonImpl.getAuthModuleIds(account, AuthModuleTypeEnum.HHFACE_USER_LIB);
+//        List<Long> tenantIds = commonImpl.getAuthModuleIds(account, AuthModuleTypeEnum.HHFACE_TENANT);
+//        if (Preconditions.isBlank(tenantIds) && Preconditions.isBlank(tenantIds)) {
+////            throw new BusinessException("未找到访问资源");
+//            return RestResult.ok(initEmptyPage());
+//        }
+//        if (Preconditions.isNotBlank(dto.getTenantId()) && !tenantIds.contains(dto.getTenantId())) {
+//            throw new BusinessException("禁止访问该资源");
+//        }
 
         LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>();
         //查询的传参条件
         wrapper.like(Preconditions.isNotBlank(dto.getSn()), Device::getSn, dto.getSn());
         wrapper.eq(Preconditions.isNotBlank(dto.getTenantId()), Device::getTenantId, dto.getTenantId());
         wrapper.eq(Preconditions.isNotBlank(dto.getUserLibId()), Device::getUserLibId, dto.getUserLibId());
-        wrapper.in(Preconditions.isNotBlank(tenantIds), Device::getTenantId, tenantIds);
+        wrapper.eq(Device::getPurchaserId, config.getPurchaserId());
         //基础条件
         wrapper.eq(Device::getIsDeleted, Boolean.FALSE);
         wrapper.orderByDesc(Device::getId);