bug fix: sync functions clear all records

master
yixian 4 years ago
parent 4931efd039
commit f1a2e77676

@ -28,7 +28,9 @@ public class PermissionManagerImpl implements PermissionManager {
private PermissionModuleMapper permissionModuleMapper;
@Resource
private PermissionReader permissionReader;
@Override
@Transactional
public void synchronizeFunctions() {
List<JSONObject> functions = permissionFunctionMapper.listAll();
Map<String, JSONObject> funcMapFromDB = new HashMap<>();
@ -40,7 +42,7 @@ public class PermissionManagerImpl implements PermissionManager {
for (PermissionNode node : nodes) {
String funcId = node.getFuncId();
if (funcMapFromDB.containsKey(funcId.toLowerCase())) {
funcMapFromDB.remove(funcId);
funcMapFromDB.remove(funcId.toLowerCase());
JSONObject func = node.initFuncObject();
func.remove("role");
permissionFunctionMapper.update(func);
@ -142,7 +144,7 @@ public class PermissionManagerImpl implements PermissionManager {
}
@Override
@CacheEvict(value = ":login:managers:",allEntries = true)
@CacheEvict(value = ":login:managers:", allEntries = true)
public void setFunctionModule(String funcId, String moduleName) {
if (moduleName == null) {
throw new BadRequestException("module name not provided");
@ -169,7 +171,7 @@ public class PermissionManagerImpl implements PermissionManager {
@Override
@Transactional
@CacheEvict(value = ":login:managers:",allEntries = true)
@CacheEvict(value = ":login:managers:", allEntries = true)
public void authorizeRole(ManagerRole role, List<String> functions) {
permissionFunctionMapper.clearRolePermission(role.getInverseMask());
permissionFunctionMapper.authorizeRole(role.getMask(), functions);
@ -181,5 +183,4 @@ public class PermissionManagerImpl implements PermissionManager {
}
}

Loading…
Cancel
Save