角色切换
This commit is contained in:
+16
-14
@@ -54,9 +54,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
|
|
||||||
// 去除 listSysRoles 中重复的数据
|
// 去除 listSysRoles 中重复的数据
|
||||||
for (int i = 0; i < listSysRoles.size(); i++) {
|
for (int i = 0; i < listSysRoles.size(); i++) {
|
||||||
String roleCodeI =((SysRole)listSysRoles.get(i)).getRoleCode();
|
String roleCodeI = ((SysRole) listSysRoles.get(i)).getRoleCode();
|
||||||
for (int j = i + 1; j < listSysRoles.size(); j++) {
|
for (int j = i + 1; j < listSysRoles.size(); j++) {
|
||||||
String roleCodeJ =((SysRole)listSysRoles.get(j)).getRoleCode();
|
String roleCodeJ = ((SysRole) listSysRoles.get(j)).getRoleCode();
|
||||||
// 发现重复数据
|
// 发现重复数据
|
||||||
if (roleCodeI.equals(roleCodeJ)) {
|
if (roleCodeI.equals(roleCodeJ)) {
|
||||||
errorStrs.add("第 " + (j + 1) + " 行的 roleCode 值:" + roleCodeI + " 已存在,忽略导入");
|
errorStrs.add("第 " + (j + 1) + " 行的 roleCode 值:" + roleCodeI + " 已存在,忽略导入");
|
||||||
@@ -66,12 +66,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 去掉 sql 中的重复数据
|
// 去掉 sql 中的重复数据
|
||||||
Integer errorLines=0;
|
Integer errorLines = 0;
|
||||||
Integer successLines=0;
|
Integer successLines = 0;
|
||||||
List<String> list = ImportExcelUtil.importDateSave(listSysRoles, ISysRoleService.class, errorStrs, CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE);
|
List<String> list = ImportExcelUtil.importDateSave(listSysRoles, ISysRoleService.class, errorStrs, CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE);
|
||||||
errorLines+=list.size();
|
errorLines += list.size();
|
||||||
successLines+=(listSysRoles.size()-errorLines);
|
successLines += (listSysRoles.size() - errorLines);
|
||||||
return ImportExcelUtil.imporReturnRes(errorLines,successLines,list);
|
return ImportExcelUtil.imporReturnRes(errorLines, successLines, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,36 +110,38 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
List<SysRole> roleList = sysRoleMapper.getRoleByUserId(loginUser.getId());
|
List<SysRole> roleList = sysRoleMapper.getRoleByUserId(loginUser.getId());
|
||||||
List<String> roleCodeList = new ArrayList<>();
|
List<String> roleCodeList = new ArrayList<>();
|
||||||
if(roleList.size() != 0){
|
if (roleList.size() != 0) {
|
||||||
roleCodeList = roleList.stream().map(SysRole::getRoleCode).collect(Collectors.toList());
|
roleCodeList = roleList.stream().map(SysRole::getRoleCode).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
List<SysRole> sysRoleNew = new ArrayList<>();
|
List<SysRole> sysRoleNew = new ArrayList<>();
|
||||||
if(roleCodeList.size() != 0 && (roleCodeList.contains(ProjectRoleEnum.REGULATI_ENGINEER.getCode()) || roleCodeList.contains(ProjectRoleEnum.HOMOLOGATION_ENGINEER.getCode()))){
|
if (roleCodeList.size() != 0 && (roleCodeList.contains(ProjectRoleEnum.REGULATI_ENGINEER.getCode()) || roleCodeList.contains(ProjectRoleEnum.HOMOLOGATION_ENGINEER.getCode()))) {
|
||||||
sysRoleNew = roleList.stream().filter(e -> !ProjectRoleEnum.REGULATI_ENGINEER.getCode().equals(e.getRoleCode()) && !ProjectRoleEnum.HOMOLOGATION_ENGINEER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
sysRoleNew = roleList.stream().filter(e -> !ProjectRoleEnum.REGULATI_ENGINEER.getCode().equals(e.getRoleCode()) && !ProjectRoleEnum.HOMOLOGATION_ENGINEER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
||||||
SysRole sysRole = new SysRole();
|
SysRole sysRole = new SysRole();
|
||||||
sysRole.setRoleName(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getName());
|
sysRole.setRoleName(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getName());
|
||||||
sysRole.setRoleCode(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue());
|
sysRole.setRoleCode(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue());
|
||||||
sysRoleNew.add(sysRole);
|
sysRoleNew.add(sysRole);
|
||||||
|
} else {
|
||||||
|
sysRoleNew = roleList;
|
||||||
}
|
}
|
||||||
//studio角色,法规工程师/认证工程师,领导角色,管理员角色
|
//studio角色,法规工程师/认证工程师,领导角色,管理员角色
|
||||||
List<SysRole> sysRoles = new LinkedList<>();
|
List<SysRole> sysRoles = new LinkedList<>();
|
||||||
if(sysRoleNew.size() != 0){
|
if (sysRoleNew.size() != 0) {
|
||||||
List<SysRole> studio = sysRoleNew.stream().filter(e -> ProjectRoleEnum.STUDIO_ENGINEER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
List<SysRole> studio = sysRoleNew.stream().filter(e -> ProjectRoleEnum.STUDIO_ENGINEER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
||||||
List<SysRole> regulatiAndHomo = sysRoleNew.stream().filter(e -> ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue().equals(e.getRoleCode())).collect(Collectors.toList());
|
List<SysRole> regulatiAndHomo = sysRoleNew.stream().filter(e -> ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue().equals(e.getRoleCode())).collect(Collectors.toList());
|
||||||
List<SysRole> manager = sysRoleNew.stream().filter(e -> ProjectRoleEnum.MANAGER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
List<SysRole> manager = sysRoleNew.stream().filter(e -> ProjectRoleEnum.MANAGER.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
||||||
List<SysRole> admin = sysRoleNew.stream().filter(e -> ProjectRoleEnum.ADMIN.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
List<SysRole> admin = sysRoleNew.stream().filter(e -> ProjectRoleEnum.ADMIN.getCode().equals(e.getRoleCode())).collect(Collectors.toList());
|
||||||
if(studio.size() != 0){
|
if (studio.size() != 0) {
|
||||||
studio.get(0).setRoleCode(ProjectRoleEnum.STUDIO_ENGINEER.getValue());
|
studio.get(0).setRoleCode(ProjectRoleEnum.STUDIO_ENGINEER.getValue());
|
||||||
sysRoles.addAll(studio);
|
sysRoles.addAll(studio);
|
||||||
}
|
}
|
||||||
if(regulatiAndHomo.size() != 0){
|
if (regulatiAndHomo.size() != 0) {
|
||||||
sysRoles.addAll(regulatiAndHomo);
|
sysRoles.addAll(regulatiAndHomo);
|
||||||
}
|
}
|
||||||
if(manager.size() != 0){
|
if (manager.size() != 0) {
|
||||||
manager.get(0).setRoleCode(ProjectRoleEnum.MANAGER.getValue());
|
manager.get(0).setRoleCode(ProjectRoleEnum.MANAGER.getValue());
|
||||||
sysRoles.addAll(manager);
|
sysRoles.addAll(manager);
|
||||||
}
|
}
|
||||||
if(admin.size() != 0){
|
if (admin.size() != 0) {
|
||||||
admin.get(0).setRoleCode(ProjectRoleEnum.ADMIN.getValue());
|
admin.get(0).setRoleCode(ProjectRoleEnum.ADMIN.getValue());
|
||||||
sysRoles.addAll(admin);
|
sysRoles.addAll(admin);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user