|
|
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jzg.commons.entity.dto.SysUserAddParam;
|
|
|
+import com.jzg.commons.entity.dto.SysUserEditParam;
|
|
|
+import com.jzg.commons.entity.dto.SysUserParam;
|
|
|
import com.jzg.commons.entity.enums.YesNoEnum;
|
|
|
import com.jzg.commons.entity.po.SysRole;
|
|
|
-import com.jzg.commons.entity.po.SysSystem;
|
|
|
import com.jzg.commons.entity.po.SysUser;
|
|
|
import com.jzg.commons.entity.po.SysUserRole;
|
|
|
import com.jzg.commons.entity.vo.SysUserVo;
|
|
|
@@ -19,7 +21,6 @@ import com.jzg.mapper.SysUserMapper;
|
|
|
import com.jzg.mapper.SysUserRoleMapper;
|
|
|
import com.jzg.service.SysUserService;
|
|
|
import com.jzg.commons.util.PasswordUtils;
|
|
|
-import jakarta.validation.constraints.NotEmpty;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -45,9 +46,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
|
|
|
private SysUserRoleMapper sysUserRoleMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Page<SysUser> queryPage(Page page, SysUserVo sysUserVo) {
|
|
|
- Page<SysUser> userPage = baseMapper.queryPage(page, sysUserVo);
|
|
|
- List<SysUser> userList = userPage.getRecords();
|
|
|
+ public Page<SysUserVo> queryPage(Page page, SysUserParam param) {
|
|
|
+ Page<SysUserVo> userPage = baseMapper.queryPage(page, param);
|
|
|
+ List<SysUserVo> userList = userPage.getRecords();
|
|
|
if (!userList.isEmpty()) {
|
|
|
List<String> userIdList = userList.stream().map(user -> user.getId()).collect(Collectors.toList());
|
|
|
// 批量查询 角色信息
|
|
|
@@ -65,10 +66,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SysUser queryById(String id) {
|
|
|
+ public SysUserVo queryById(String id) {
|
|
|
SysUser user = this.baseMapper.selectById(id);
|
|
|
-
|
|
|
- return user;
|
|
|
+ SysUserVo vo = new SysUserVo();
|
|
|
+ BeanUtils.copyProperties(user, vo);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -82,17 +84,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void userAdd(SysUserVo sysUserVo) {
|
|
|
+ public void userAdd(SysUserAddParam param) {
|
|
|
SysUser user = new SysUser();
|
|
|
- BeanUtils.copyProperties(sysUserVo, user);
|
|
|
+ BeanUtils.copyProperties(param, user);
|
|
|
user.setAccountStatus(1);
|
|
|
String salt = PasswordUtils.getSalt();
|
|
|
- String encryptedPassword = PasswordUtils.encode(sysUserVo.getPassword(),salt);
|
|
|
+ String encryptedPassword = PasswordUtils.encode(param.getPassword(),salt);
|
|
|
user.setSalt(salt);
|
|
|
user.setPassword(encryptedPassword);
|
|
|
this.save(user);
|
|
|
// 角色信息关联
|
|
|
- List<SysUserVo.SysRoleVo> roleList = sysUserVo.getRoleVoList();
|
|
|
+ List<SysUserVo.SysRoleVo> roleList = param.getRoleVoList();
|
|
|
List<SysUserRole> userRoles = new ArrayList<>();
|
|
|
roleList.forEach(role -> {
|
|
|
SysUserRole sysUserRole = new SysUserRole();
|
|
|
@@ -105,11 +107,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void userEdit(SysUserVo sysUserVo) {
|
|
|
+ public void userEdit(SysUserEditParam param) {
|
|
|
SysUser user = new SysUser();
|
|
|
- BeanUtils.copyProperties(sysUserVo, user);
|
|
|
+ BeanUtils.copyProperties(param, user);
|
|
|
SysUser sysUser = this.getById(user.getId());
|
|
|
- String encryptedPassword = PasswordUtils.encode(sysUserVo.getPassword(),sysUser.getSalt());
|
|
|
+ String encryptedPassword = PasswordUtils.encode(param.getPassword(),sysUser.getSalt());
|
|
|
user.setPassword(encryptedPassword);
|
|
|
this.updateById(user);
|
|
|
|
|
|
@@ -119,7 +121,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
|
|
|
sysUserRoleMapper.delete(updateWrapper);
|
|
|
|
|
|
// 角色信息关联
|
|
|
- List<SysUserVo.SysRoleVo> roleList = sysUserVo.getRoleVoList();
|
|
|
+ List<SysUserVo.SysRoleVo> roleList = param.getRoleVoList();
|
|
|
List<SysUserRole> userRoles = new ArrayList<>();
|
|
|
roleList.forEach(role -> {
|
|
|
SysUserRole sysUserRole = new SysUserRole();
|