@Transactional(readOnly = false) public int deleteSysRole(SysRoleView sysrole) { // 判断是否有用户使用该角色 int count = sysroleMapper.findUserCount(sysrole); if (count > 0) return -1; // 有用户使用该角色,代表不能删除该角色 sysrole.setModifyuser(ShiroDbRealm.getCurrentLoginName()); sysroleMapper.deleteRoleFunction(sysrole); sysroleMapper.delete(sysrole); return 1; }
@Transactional(readOnly = false) public void updatePower(SysRoleView sysrole) { sysrole.setCreateuser(ShiroDbRealm.getCurrentLoginName()); for (SysFunctionView sysFunction : sysrole.getFunctions()) { sysFunction.setRole_function_id(IdUtils.uuid2()); } SysRole sys = sysroleMapper.findOne(sysrole.getId()); if (sys != null && !sys.getRoleName().equals(sysrole.getRoleName())) { sys.setRoleName(sysrole.getRoleName()); sys.setModifyuser(ShiroDbRealm.getCurrentLoginName()); sysroleMapper.update(sys); } sysroleMapper.deleteRoleFunction(sysrole); sysroleMapper.insertRoleFunction(sysrole); }