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

Loading…
Cancel
Save