提交 6f1ab99c 编写于 作者: sq3536's avatar sq3536

基础功能角色

上级 345aaf95
...@@ -7,6 +7,8 @@ import liquibase.util.StringUtils; ...@@ -7,6 +7,8 @@ import liquibase.util.StringUtils;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.uaa.domain.SysRole; import cn.ibizlab.core.uaa.domain.SysRole;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -30,53 +32,50 @@ public class SysRoleExService extends SysRoleServiceImpl { ...@@ -30,53 +32,50 @@ public class SysRoleExService extends SysRoleServiceImpl {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1); return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
} }
private List<SysRole> allSysRoles;
@Cacheable(value ="sysrole", key = "'alls'")
public synchronized List<SysRole> getAllSysRoles() public synchronized List<SysRole> getAllSysRoles()
{ {
if(allSysRoles==null) { List<SysRole> sysRoles = this.list();
List<SysRole> sysRoles = this.list(); Boolean bBaseUsers=false;
Boolean bBaseUsers=false; for (SysRole role:sysRoles)
for (SysRole role:sysRoles) if(role.getRoleid().equalsIgnoreCase("ROLE_USERS")) {
if(role.getRoleid().equalsIgnoreCase("ROLE_USERS")) { bBaseUsers = true;
bBaseUsers = true; break;
break;
}
if(!bBaseUsers)
{
SysRole role=new SysRole();
role.setRoleid("ROLE_USERS");
role.setRolename("普通用户(默认基础功能)");
role.setMemo("系统保留基础角色,所有用户均属于此角色,无需手工分配到用户");
this.create(role);
sysRoles.add(role);
} }
allSysRoles=sysRoles; if(!bBaseUsers)
{
SysRole role=new SysRole();
role.setRoleid("ROLE_USERS");
role.setRolename("普通用户(默认基础功能)");
role.setMemo("系统保留基础角色,所有用户均属于此角色,无需手工分配到用户");
this.create(role);
sysRoles.add(role);
} }
return allSysRoles; return sysRoles;
} }
@Override @Override
@CacheEvict(value ="sysrole", key = "'alls'")
public boolean create(SysRole et) { public boolean create(SysRole et) {
allSysRoles=null;
return super.create(et); return super.create(et);
} }
@Override @Override
@CacheEvict(value ="sysrole", key = "'alls'")
public void createBatch(List<SysRole> list) { public void createBatch(List<SysRole> list) {
allSysRoles=null;
super.createBatch(list); super.createBatch(list);
} }
@Override @Override
@CacheEvict(value ="sysrole", key = "'alls'")
public boolean update(SysRole et) { public boolean update(SysRole et) {
allSysRoles=null;
return super.update(et); return super.update(et);
} }
@Override @Override
@CacheEvict(value ="sysrole", key = "'alls'")
public void updateBatch(List<SysRole> list) { public void updateBatch(List<SysRole> list) {
allSysRoles=null;
super.updateBatch(list); super.updateBatch(list);
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册