|
|
@@ -546,18 +546,20 @@ public class SysStudentServiceImpl implements ISysStudentService {
|
|
|
public void insertUserRole(SysUser user) {
|
|
|
SysRole checkGentle = roleMapper.checkRoleKeyUnique(checkGentleStr);
|
|
|
SysRole rectifyGentle = roleMapper.checkRoleKeyUnique(rectifyGentleStr);
|
|
|
- Long[] roles = Arrays.asList(user.getRoleIds()).stream().filter(a->a.longValue()!=checkGentle.getRoleId() && a.longValue()!=rectifyGentle.getRoleId()).toArray(Long[]::new);
|
|
|
- if (StringUtils.isNotNull(roles)) {
|
|
|
- // 新增用户与角色管理
|
|
|
- List<SysUserRole> list = new ArrayList<>();
|
|
|
- for (Long roleId : roles) {
|
|
|
- SysUserRole ur = new SysUserRole();
|
|
|
- ur.setUserId(user.getUserId());
|
|
|
- ur.setRoleId(roleId);
|
|
|
- list.add(ur);
|
|
|
- }
|
|
|
- if (list!=null && !list.isEmpty()) {
|
|
|
- userRoleMapper.batchUserRole(list);
|
|
|
+ if(user.getRoleIds()!=null && user.getRoleIds().length>0){
|
|
|
+ Long[] roles = Arrays.asList(user.getRoleIds()).stream().filter(a->a.longValue()!=checkGentle.getRoleId() && a.longValue()!=rectifyGentle.getRoleId()).toArray(Long[]::new);
|
|
|
+ if (StringUtils.isNotNull(roles)) {
|
|
|
+ // 新增用户与角色管理
|
|
|
+ List<SysUserRole> list = new ArrayList<>();
|
|
|
+ for (Long roleId : roles) {
|
|
|
+ SysUserRole ur = new SysUserRole();
|
|
|
+ ur.setUserId(user.getUserId());
|
|
|
+ ur.setRoleId(roleId);
|
|
|
+ list.add(ur);
|
|
|
+ }
|
|
|
+ if (list!=null && !list.isEmpty()) {
|
|
|
+ userRoleMapper.batchUserRole(list);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1112,6 +1114,15 @@ public class SysStudentServiceImpl implements ISysStudentService {
|
|
|
newSysUser.setUserId(checkUser.getUserId());
|
|
|
this.updateUser(newSysUser);
|
|
|
}else{
|
|
|
+ SysPost post = new SysPost();
|
|
|
+ post.setPostCode("user");
|
|
|
+ List<SysPost> sysPostList = postMapper.selectPostList(post);
|
|
|
+ if(!sysPostList.isEmpty()){
|
|
|
+ if(sysPostList.get(0).getRoleIds()!=null && !"".equals(sysPostList.get(0).getRoleIds())){
|
|
|
+ Long[] roleIds = Arrays.asList(sysPostList.get(0).getRoleIds().split(",")).stream().toArray((Long[]::new));
|
|
|
+ newSysUser.setRoleIds(roleIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
this.insertUser(newSysUser);
|
|
|
}
|
|
|
}
|