|
|
@ -105,7 +105,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean deleteUser(String userId) { |
|
|
|
public boolean deleteUser(String userId) { |
|
|
|
//1.删除用户
|
|
|
|
//1.删除用户
|
|
|
@ -116,7 +116,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean deleteBatchUsers(String userIds) { |
|
|
|
public boolean deleteBatchUsers(String userIds) { |
|
|
|
//1.删除用户
|
|
|
|
//1.删除用户
|
|
|
@ -136,7 +136,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public void addUserWithRole(SysUser user, String roles) { |
|
|
|
public void addUserWithRole(SysUser user, String roles) { |
|
|
|
this.save(user); |
|
|
|
this.save(user); |
|
|
|
if(oConvertUtils.isNotEmpty(roles)) { |
|
|
|
if (oConvertUtils.isNotEmpty(roles)) { |
|
|
|
String[] arr = roles.split(","); |
|
|
|
String[] arr = roles.split(","); |
|
|
|
for (String roleId : arr) { |
|
|
|
for (String roleId : arr) { |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
@ -146,13 +146,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public void editUserWithRole(SysUser user, String roles) { |
|
|
|
public void editUserWithRole(SysUser user, String roles) { |
|
|
|
this.updateById(user); |
|
|
|
this.updateById(user); |
|
|
|
//先删后加
|
|
|
|
//先删后加
|
|
|
|
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); |
|
|
|
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); |
|
|
|
if(oConvertUtils.isNotEmpty(roles)) { |
|
|
|
if (oConvertUtils.isNotEmpty(roles)) { |
|
|
|
String[] arr = roles.split(","); |
|
|
|
String[] arr = roles.split(","); |
|
|
|
for (String roleId : arr) { |
|
|
|
for (String roleId : arr) { |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
@ -169,6 +169,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 通过用户名获取用户角色集合 |
|
|
|
* 通过用户名获取用户角色集合 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @return 角色集合 |
|
|
|
* @return 角色集合 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -199,7 +200,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
permissionSet.add(po.getPerms()); |
|
|
|
permissionSet.add(po.getPerms()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("-------通过数据库读取用户拥有的权限Perms------username: "+ username+",Perms size: "+ (permissionSet==null?0:permissionSet.size()) ); |
|
|
|
log.info("-------通过数据库读取用户拥有的权限Perms------username: " + username + ",Perms size: " + (permissionSet == null ? 0 : permissionSet.size())); |
|
|
|
return permissionSet; |
|
|
|
return permissionSet; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -213,7 +214,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoginUser user = sysBaseAPI.getUserByName(username); |
|
|
|
LoginUser user = sysBaseAPI.getUserByName(username); |
|
|
|
if(user!=null) { |
|
|
|
if (user != null) { |
|
|
|
info.setSysUserCode(user.getUsername()); |
|
|
|
info.setSysUserCode(user.getUsername()); |
|
|
|
info.setSysUserName(user.getRealname()); |
|
|
|
info.setSysUserName(user.getRealname()); |
|
|
|
info.setSysOrgCode(user.getOrgCode()); |
|
|
|
info.setSysOrgCode(user.getOrgCode()); |
|
|
@ -222,12 +223,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
//多部门支持in查询
|
|
|
|
//多部门支持in查询
|
|
|
|
List<SysDepart> list = sysDepartMapper.queryUserDeparts(user.getId()); |
|
|
|
List<SysDepart> list = sysDepartMapper.queryUserDeparts(user.getId()); |
|
|
|
List<String> sysMultiOrgCode = new ArrayList<String>(); |
|
|
|
List<String> sysMultiOrgCode = new ArrayList<String>(); |
|
|
|
if(list==null || list.size()==0) { |
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
//当前用户无部门
|
|
|
|
//当前用户无部门
|
|
|
|
//sysMultiOrgCode.add("0");
|
|
|
|
//sysMultiOrgCode.add("0");
|
|
|
|
}else if(list.size()==1) { |
|
|
|
} else if (list.size() == 1) { |
|
|
|
sysMultiOrgCode.add(list.get(0).getOrgCode()); |
|
|
|
sysMultiOrgCode.add(list.get(0).getOrgCode()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
info.setOneDepart(false); |
|
|
|
info.setOneDepart(false); |
|
|
|
for (SysDepart dpt : list) { |
|
|
|
for (SysDepart dpt : list) { |
|
|
|
sysMultiOrgCode.add(dpt.getOrgCode()); |
|
|
|
sysMultiOrgCode.add(dpt.getOrgCode()); |
|
|
@ -240,18 +241,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
// 根据部门Id查询
|
|
|
|
// 根据部门Id查询
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId,String username) { |
|
|
|
public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username) { |
|
|
|
return userMapper.getUserByDepId(page, departId,username); |
|
|
|
return userMapper.getUserByDepId(page, departId, username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) { |
|
|
|
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) { |
|
|
|
return userMapper.getUserByDepIds(page, departIds,username); |
|
|
|
return userMapper.getUserByDepIds(page, departIds, username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<SysUser> getUserByDepIds(List<String> departIds, String username) { |
|
|
|
public List<SysUser> getUserByDepIds(List<String> departIds, String username) { |
|
|
|
return userMapper.getUserByDepIds(departIds,username); |
|
|
|
return userMapper.getUserByDepIds(departIds, username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, String> getDepNamesByUserIds(List<String> userIds) { |
|
|
|
public Map<String, String> getDepNamesByUserIds(List<String> userIds) { |
|
|
|
List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds); |
|
|
|
List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds); |
|
|
@ -292,13 +295,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
// 根据角色Id查询
|
|
|
|
// 根据角色Id查询
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) { |
|
|
|
public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) { |
|
|
|
return userMapper.getUserByRoleId(page,roleId,username); |
|
|
|
return userMapper.getUserByRoleId(page, roleId, username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, key="#username") |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, key = "#username") |
|
|
|
public void updateUserDepart(String username,String orgCode) { |
|
|
|
public void updateUserDepart(String username, String orgCode) { |
|
|
|
baseMapper.updateUserDepart(username, orgCode); |
|
|
|
baseMapper.updateUserDepart(username, orgCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -318,7 +321,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
public void addUserWithDepart(SysUser user, String selectedParts) { |
|
|
|
public void addUserWithDepart(SysUser user, String selectedParts) { |
|
|
|
// this.save(user); //保存角色的时候已经添加过一次了
|
|
|
|
// this.save(user); //保存角色的时候已经添加过一次了
|
|
|
|
if(oConvertUtils.isNotEmpty(selectedParts)) { |
|
|
|
if (oConvertUtils.isNotEmpty(selectedParts)) { |
|
|
|
String[] arr = selectedParts.split(","); |
|
|
|
String[] arr = selectedParts.split(","); |
|
|
|
for (String deaprtId : arr) { |
|
|
|
for (String deaprtId : arr) { |
|
|
|
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId); |
|
|
|
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId); |
|
|
@ -330,32 +333,32 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
|
|
|
public void editUserWithDepart(SysUser user, String departs) { |
|
|
|
public void editUserWithDepart(SysUser user, String departs) { |
|
|
|
this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次
|
|
|
|
this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次
|
|
|
|
String[] arr = {}; |
|
|
|
String[] arr = {}; |
|
|
|
if(oConvertUtils.isNotEmpty(departs)){ |
|
|
|
if (oConvertUtils.isNotEmpty(departs)) { |
|
|
|
arr = departs.split(","); |
|
|
|
arr = departs.split(","); |
|
|
|
} |
|
|
|
} |
|
|
|
//查询已关联部门
|
|
|
|
//查询已关联部门
|
|
|
|
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
if(userDepartList != null && userDepartList.size()>0){ |
|
|
|
if (userDepartList != null && userDepartList.size() > 0) { |
|
|
|
for(SysUserDepart depart : userDepartList ){ |
|
|
|
for (SysUserDepart depart : userDepartList) { |
|
|
|
//修改已关联部门删除部门用户角色关系
|
|
|
|
//修改已关联部门删除部门用户角色关系
|
|
|
|
if(!Arrays.asList(arr).contains(depart.getDepId())){ |
|
|
|
if (!Arrays.asList(arr).contains(depart.getDepId())) { |
|
|
|
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( |
|
|
|
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( |
|
|
|
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId())); |
|
|
|
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId, depart.getDepId())); |
|
|
|
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); |
|
|
|
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); |
|
|
|
if(roleIds != null && roleIds.size()>0){ |
|
|
|
if (roleIds != null && roleIds.size() > 0) { |
|
|
|
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) |
|
|
|
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) |
|
|
|
.in(SysDepartRoleUser::getDroleId,roleIds)); |
|
|
|
.in(SysDepartRoleUser::getDroleId, roleIds)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//先删后加
|
|
|
|
//先删后加
|
|
|
|
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
if(oConvertUtils.isNotEmpty(departs)) { |
|
|
|
if (oConvertUtils.isNotEmpty(departs)) { |
|
|
|
for (String departId : arr) { |
|
|
|
for (String departId : arr) { |
|
|
|
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); |
|
|
|
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); |
|
|
|
sysUserDepartMapper.insert(userDepart); |
|
|
|
sysUserDepartMapper.insert(userDepart); |
|
|
@ -366,6 +369,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 校验用户是否有效 |
|
|
|
* 校验用户是否有效 |
|
|
|
|
|
|
|
* |
|
|
|
* @param sysUser |
|
|
|
* @param sysUser |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -463,51 +467,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<SysUser> queryByDepIds(List<String> departIds, String username) { |
|
|
|
public List<SysUser> queryByDepIds(List<String> departIds, String username) { |
|
|
|
return userMapper.queryByDepIds(departIds,username); |
|
|
|
return userMapper.queryByDepIds(departIds, username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) { |
|
|
|
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) { |
|
|
|
//首先根据id看修改前有没有这个学生,如果有的话,调用edit修改,没有的话直接添加。
|
|
|
|
|
|
|
|
int ans=jxStudentService.cont(user.getId()); |
|
|
|
|
|
|
|
//step.1 保存用户
|
|
|
|
//step.1 保存用户
|
|
|
|
this.save(user); |
|
|
|
this.save(user); |
|
|
|
//step.2 保存角色
|
|
|
|
//step.2 保存角色
|
|
|
|
if(oConvertUtils.isNotEmpty(selectedRoles)) { |
|
|
|
if (oConvertUtils.isNotEmpty(selectedRoles)) { |
|
|
|
String[] arr = selectedRoles.split(","); |
|
|
|
String[] arr = selectedRoles.split(","); |
|
|
|
for (String roleId : arr) { |
|
|
|
for (String roleId : arr) { |
|
|
|
//这串数字是学生角色id
|
|
|
|
|
|
|
|
if(roleId.equals("1296245993988284417")){ |
|
|
|
|
|
|
|
JxStudent jxStudent=new JxStudent(); |
|
|
|
|
|
|
|
jxStudent.setId(user.getId()); |
|
|
|
|
|
|
|
jxStudent.setName(user.getRealname()); |
|
|
|
|
|
|
|
jxStudent.setPhone(user.getPhone()); |
|
|
|
|
|
|
|
jxStudent.setBirthday(user.getBirthday()); |
|
|
|
|
|
|
|
if(user.getSex()==1) |
|
|
|
|
|
|
|
jxStudent.setSex("1"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
jxStudent.setSex("2"); |
|
|
|
|
|
|
|
//这里的判断主要是为了防止学生表新加后再来用户表新加会出现的问题。
|
|
|
|
|
|
|
|
if(ans==0) |
|
|
|
|
|
|
|
jxStudentService.save(jxStudent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
sysUserRoleMapper.insert(userRole); |
|
|
|
sysUserRoleMapper.insert(userRole); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//step.3 保存所属部门
|
|
|
|
//step.3 保存所属部门
|
|
|
|
if(oConvertUtils.isNotEmpty(selectedDeparts)) { |
|
|
|
if (oConvertUtils.isNotEmpty(selectedDeparts)) { |
|
|
|
ans=jxStudentService.cont(user.getId()); |
|
|
|
|
|
|
|
String[] arr = selectedDeparts.split(","); |
|
|
|
String[] arr = selectedDeparts.split(","); |
|
|
|
System.out.println(arr.length); |
|
|
|
|
|
|
|
for (String deaprtId : arr) { |
|
|
|
for (String deaprtId : arr) { |
|
|
|
if(arr.length==1&&ans!=0){ |
|
|
|
|
|
|
|
JxStudent jxStudent=new JxStudent(); |
|
|
|
|
|
|
|
jxStudent.setId(user.getId()); |
|
|
|
|
|
|
|
jxStudent.setFaculty(deaprtId); |
|
|
|
|
|
|
|
jxStudentService.updateById(jxStudent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId); |
|
|
|
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId); |
|
|
|
sysUserDepartMapper.insert(userDeaprt); |
|
|
|
sysUserDepartMapper.insert(userDeaprt); |
|
|
|
} |
|
|
|
} |
|
|
@ -516,84 +495,46 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
|
|
|
public void editUser(SysUser user, String roles, String departs) { |
|
|
|
public void editUser(SysUser user, String roles, String departs) { |
|
|
|
//首先根据id看修改前有没有这个学生,如果有的话,调用edit修改,没有的话直接添加。
|
|
|
|
|
|
|
|
int ans=jxStudentService.cont(user.getId()); |
|
|
|
|
|
|
|
//ans不等于0的话,就是有这条数据,调用edit修改,否则就是添加。
|
|
|
|
|
|
|
|
//判断修改后,对应用户是否还有学生这个角色。
|
|
|
|
|
|
|
|
boolean student=false; |
|
|
|
|
|
|
|
//step.1 修改用户基础信息
|
|
|
|
//step.1 修改用户基础信息
|
|
|
|
this.updateById(user); |
|
|
|
this.updateById(user); |
|
|
|
//step.2 修改角色
|
|
|
|
//step.2 修改角色
|
|
|
|
//处理用户角色 先删后加
|
|
|
|
//处理用户角色 先删后加
|
|
|
|
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); |
|
|
|
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); |
|
|
|
//这里if中判断的是否角色为空,为空直接不执行了,所以说,如果之前有学生的话,要给删掉的。
|
|
|
|
if (oConvertUtils.isNotEmpty(roles)) { |
|
|
|
if(oConvertUtils.isNotEmpty(roles)) { |
|
|
|
|
|
|
|
String[] arr = roles.split(","); |
|
|
|
String[] arr = roles.split(","); |
|
|
|
for (String roleId : arr) { |
|
|
|
for (String roleId : arr) { |
|
|
|
//在修改用户角色时,如果没了学生这个角色,一会就要把对应学生表中的数据给删掉了。
|
|
|
|
|
|
|
|
if(roleId.equals("1296245993988284417")){ |
|
|
|
|
|
|
|
student=true; |
|
|
|
|
|
|
|
JxStudent jxStudent=new JxStudent(); |
|
|
|
|
|
|
|
jxStudent.setId(user.getId()); |
|
|
|
|
|
|
|
jxStudent.setName(user.getRealname()); |
|
|
|
|
|
|
|
jxStudent.setPhone(user.getPhone()); |
|
|
|
|
|
|
|
jxStudent.setBirthday(user.getBirthday()); |
|
|
|
|
|
|
|
if(user.getSex()==1) |
|
|
|
|
|
|
|
jxStudent.setSex("1"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
jxStudent.setSex("2"); |
|
|
|
|
|
|
|
//判断是不是第一次给用户学生这个角色,如果是的话就会调用save新增,如果不是的话,就会在原表中进行修改。
|
|
|
|
|
|
|
|
if(ans==0) |
|
|
|
|
|
|
|
jxStudentService.save(jxStudent); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
jxStudentService.updateById(jxStudent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
SysUserRole userRole = new SysUserRole(user.getId(), roleId); |
|
|
|
sysUserRoleMapper.insert(userRole); |
|
|
|
sysUserRoleMapper.insert(userRole); |
|
|
|
} |
|
|
|
} |
|
|
|
//如果student为false,则证明修改之后,没有学生这个角色了,要把学生表中对应的信息给删除。
|
|
|
|
|
|
|
|
if(!student&&ans!=0){ |
|
|
|
|
|
|
|
jxStudentService.removeById(user.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
|
|
|
|
//修改完一个角色都没有,而且学生表还存在的话,就直接删除。
|
|
|
|
|
|
|
|
if(ans!=0) |
|
|
|
|
|
|
|
jxStudentService.removeById(user.getId());} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//step.3 修改部门
|
|
|
|
//step.3 修改部门
|
|
|
|
String[] arr = {}; |
|
|
|
String[] arr = {}; |
|
|
|
if(oConvertUtils.isNotEmpty(departs)){ |
|
|
|
if (oConvertUtils.isNotEmpty(departs)) { |
|
|
|
arr = departs.split(","); |
|
|
|
arr = departs.split(","); |
|
|
|
} |
|
|
|
} |
|
|
|
//查询已关联部门
|
|
|
|
//查询已关联部门
|
|
|
|
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
if(userDepartList != null && userDepartList.size()>0){ |
|
|
|
if (userDepartList != null && userDepartList.size() > 0) { |
|
|
|
for(SysUserDepart depart : userDepartList ){ |
|
|
|
for (SysUserDepart depart : userDepartList) { |
|
|
|
//修改已关联部门删除部门用户角色关系
|
|
|
|
//修改已关联部门删除部门用户角色关系
|
|
|
|
if(!Arrays.asList(arr).contains(depart.getDepId())){ |
|
|
|
if (!Arrays.asList(arr).contains(depart.getDepId())) { |
|
|
|
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( |
|
|
|
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( |
|
|
|
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId())); |
|
|
|
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId, depart.getDepId())); |
|
|
|
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); |
|
|
|
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); |
|
|
|
if(roleIds != null && roleIds.size()>0){ |
|
|
|
if (roleIds != null && roleIds.size() > 0) { |
|
|
|
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) |
|
|
|
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) |
|
|
|
.in(SysDepartRoleUser::getDroleId,roleIds)); |
|
|
|
.in(SysDepartRoleUser::getDroleId, roleIds)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//先删后加
|
|
|
|
//先删后加
|
|
|
|
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); |
|
|
|
if(oConvertUtils.isNotEmpty(departs)) { |
|
|
|
if (oConvertUtils.isNotEmpty(departs)) { |
|
|
|
//ans=jxStudentService.cont(user.getId());
|
|
|
|
|
|
|
|
for (String departId : arr) { |
|
|
|
for (String departId : arr) { |
|
|
|
if(arr.length==1&&ans!=0){ |
|
|
|
|
|
|
|
JxStudent jxStudent=new JxStudent(); |
|
|
|
|
|
|
|
jxStudent.setId(user.getId()); |
|
|
|
|
|
|
|
jxStudent.setFaculty(departId); |
|
|
|
|
|
|
|
jxStudentService.updateById(jxStudent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); |
|
|
|
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); |
|
|
|
sysUserDepartMapper.insert(userDepart); |
|
|
|
sysUserDepartMapper.insert(userDepart); |
|
|
|
} |
|
|
|
} |
|
|
@ -615,12 +556,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SysUser> selectStudent(Page<SysUser> page, SysUser user) { |
|
|
|
public IPage<SysUser> selectStudent(Page<SysUser> page, SysUser user) { |
|
|
|
return userMapper.selctStudent(page,user); |
|
|
|
return userMapper.selctStudent(page, user); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SysUser> page(Page<SysUser> page, String username, String realname) { |
|
|
|
public IPage<SysUser> page(Page<SysUser> page, String username, String realname) { |
|
|
|
return userMapper.page(page,username,realname); |
|
|
|
return userMapper.page(page, username, realname); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|