|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
@ -276,4 +277,24 @@ public class AccessConfigServiceImpl implements AccessConfigService { |
|
|
|
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void addOpeAndScopes4RoleByDefaultConf(String roleKey, String operationKey) { |
|
|
|
// 1.先判断该角色是否已经为该操作配做了默认配置
|
|
|
|
LambdaQueryWrapper<RoleOperationDefaultEntity> rodw = new LambdaQueryWrapper<>(); |
|
|
|
rodw.eq(RoleOperationDefaultEntity::getRoleKey, roleKey); |
|
|
|
rodw.eq(RoleOperationDefaultEntity::getOperationKey, operationKey); |
|
|
|
rodw.eq(RoleOperationDefaultEntity::getDelFlag, 0); |
|
|
|
Integer roleOperationCount = roleOperationDefaultDao.selectCount(rodw); |
|
|
|
List<OperationScopeDefaultEntity> scopes = operationScopeDefaultDao.listOpeDefaultScopesByRoleAndOpeKey(roleKey, operationKey); |
|
|
|
if (roleOperationCount == 0 || CollectionUtils.isEmpty(scopes)) { |
|
|
|
throw new RenException(EpmetErrorCode.ACCESS_CONFIG_ERROR.getCode(), String.format("为所有客户同步%s的%s配置权限默认失败,请先保存默认权限配置再重试", roleKey, operationKey)); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.开始执行同步
|
|
|
|
List<String> scopeKeys = scopes.stream().map(s -> s.getScopeKey()).collect(Collectors.toList()); |
|
|
|
logger.info(String.format("为所有客户同步%s的%s配置权限,范围列表:" + scopeKeys, roleKey, operationKey)); |
|
|
|
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys); |
|
|
|
logger.info("同步完成"); |
|
|
|
} |
|
|
|
} |
|
|
|