提交 345aaf95 编写于 作者: sq3536's avatar sq3536

基础功能角色

上级 8b2279cf
......@@ -30,6 +30,56 @@ public class SysRoleExService extends SysRoleServiceImpl {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
private List<SysRole> allSysRoles;
public synchronized List<SysRole> getAllSysRoles()
{
if(allSysRoles==null) {
List<SysRole> sysRoles = this.list();
Boolean bBaseUsers=false;
for (SysRole role:sysRoles)
if(role.getRoleid().equalsIgnoreCase("ROLE_USERS")) {
bBaseUsers = true;
break;
}
if(!bBaseUsers)
{
SysRole role=new SysRole();
role.setRoleid("ROLE_USERS");
role.setRolename("普通用户(默认基础功能)");
role.setMemo("系统保留基础角色,所有用户均属于此角色,无需手工分配到用户");
this.create(role);
sysRoles.add(role);
}
allSysRoles=sysRoles;
}
return allSysRoles;
}
@Override
public boolean create(SysRole et) {
allSysRoles=null;
return super.create(et);
}
@Override
public void createBatch(List<SysRole> list) {
allSysRoles=null;
super.createBatch(list);
}
@Override
public boolean update(SysRole et) {
allSysRoles=null;
return super.update(et);
}
@Override
public void updateBatch(List<SysRole> list) {
allSysRoles=null;
super.updateBatch(list);
}
/**
* [NoRepeat:角色去重查询] 行为扩展:去除父子关系
* @param et
......
package cn.ibizlab.core.uaa.extensions.service;
import cn.ibizlab.core.extensions.service.SysRoleExService;
import cn.ibizlab.core.uaa.domain.*;
import cn.ibizlab.core.uaa.extensions.domain.PermissionNode;
import cn.ibizlab.core.uaa.extensions.domain.PermissionType;
......@@ -64,7 +65,7 @@ public class UAACoreService {
@Autowired
@Lazy
private ISysRoleService sysRoleService;
private SysRoleExService sysRoleService;
@Autowired
private AuthTokenUtil jwtTokenUtil;
......@@ -159,22 +160,27 @@ public class UAACoreService {
Set<String> roleIds = new HashSet<>();
List<SysUserRole> userRoles =userRoleService.selectByUserid(userId);
if(userRoles.size()==0)
if(userRoles.size()==0) {
roleIds.add("ROLE_USERS");
return roleIds;
}
Map<String,SysRole> roleMap=new HashMap();
List<SysRole> roles=sysRoleService.list();
List<SysRole> roles=sysRoleService.getAllSysRoles();
for(SysRole role: roles){
roleMap.put(role.getRoleid(),role);
}
if(roleMap.size()==0)
if(roleMap.size()==0){
roleIds.add("ROLE_USERS");
return roleIds;
}
for(SysUserRole userRole : userRoles){
String strRoleId=userRole.getRoleid();
setRoles(strRoleId,roleMap,roleIds);
}
roleIds.add("ROLE_USERS");
return roleIds;
}
......
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
<changeSet author="mac (generated)" id="1608806718748-1">
<preConditions onFail="MARK_RAN" >
<not>
<indexExists tableName="IBZUSER_ROLE" columnNames="SYS_USERID" />
</not>
</preConditions>
<createIndex tableName="IBZUSER_ROLE" indexName="IDX_SYSUSER_ROLE_USERID">
<column name="SYS_USERID"></column>
</createIndex>
</changeSet>
<changeSet author="mac (generated)" id="1608806718749-1">
<preConditions onFail="MARK_RAN" >
<not>
<indexExists tableName="IBZROLE_PERMISSION" columnNames="SYS_ROLEID" />
</not>
</preConditions>
<createIndex tableName="IBZROLE_PERMISSION" indexName="IDX_SYSROLE_PERM_ROLEID">
<column name="SYS_ROLEID"></column>
</createIndex>
</changeSet>
</databaseChangeLog>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册