完成用户的重置密码、删除、修改状态的对接
This commit is contained in:
@@ -69,7 +69,7 @@ public interface SysPermissionService {
|
||||
void assignRoleDataScope(Long roleId, Integer dataScope, Set<Long> dataScopeDeptIds);
|
||||
|
||||
/**
|
||||
* 处理角色删除时,删除关联授权角色
|
||||
* 处理角色删除时,删除关联授权数据
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
*/
|
||||
@@ -82,4 +82,11 @@ public interface SysPermissionService {
|
||||
*/
|
||||
void processMenuDeleted(Long menuId);
|
||||
|
||||
/**
|
||||
* 处理用户删除是,删除关联授权数据
|
||||
*
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void processUserDeleted(Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -161,4 +161,9 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
||||
// TODO 实现我
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processUserDeleted(Long userId) {
|
||||
// TODO 实现我
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,29 @@ public interface SysUserService {
|
||||
*/
|
||||
void updateUser(SysUserUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param id 用户编号
|
||||
*/
|
||||
void deleteUser(Long id);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @param password 密码
|
||||
*/
|
||||
void updateUserPassword(Long id, String password);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateUserStatus(Long id, Integer status);
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 根据用户ID查询用户所属角色组
|
||||
|
||||
@@ -15,6 +15,7 @@ import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
|
||||
import cn.iocoder.dashboard.modules.system.service.permission.SysPermissionService;
|
||||
import cn.iocoder.dashboard.util.collection.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@@ -45,19 +46,12 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
private SysDeptService deptService;
|
||||
@Resource
|
||||
private SysPostService postService;
|
||||
@Resource
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Resource
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
// @Autowired
|
||||
// private SysUserRoleMapper userRoleMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private SysUserPostMapper userPostMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysConfigService configService;
|
||||
|
||||
// /**
|
||||
// * 根据条件分页查询用户列表
|
||||
// *
|
||||
@@ -117,6 +111,38 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
userMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(Long id) {
|
||||
// 校验用户存在
|
||||
this.checkUserExists(id);
|
||||
// 删除用户
|
||||
userMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserPassword(Long id, String password) {
|
||||
// 校验用户存在
|
||||
this.checkUserExists(id);
|
||||
// 更新密码
|
||||
SysUserDO updateObj = new SysUserDO();
|
||||
updateObj.setId(id);
|
||||
updateObj.setPassword(passwordEncoder.encode(password)); // 加密密码
|
||||
userMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserStatus(Long id, Integer status) {
|
||||
// 校验用户存在
|
||||
this.checkUserExists(id);
|
||||
// 更新状态
|
||||
SysUserDO updateObj = new SysUserDO();
|
||||
updateObj.setId(id);
|
||||
updateObj.setStatus(status);
|
||||
userMapper.updateById(updateObj);
|
||||
// 删除用户关联数据
|
||||
permissionService.processUserDeleted(id);
|
||||
}
|
||||
|
||||
private void checkCreateOrUpdate(Long id, String username, String mobile, String email,
|
||||
Long deptId, Set<Long> postIds) {
|
||||
// 校验用户存在
|
||||
@@ -253,50 +279,6 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增用户岗位信息
|
||||
// *
|
||||
// * @param user 用户对象
|
||||
// */
|
||||
// public void insertUserPost(SysUser user)
|
||||
// {
|
||||
// Long[] posts = user.getPostIds();
|
||||
// if (StringUtils.isNotNull(posts))
|
||||
// {
|
||||
// // 新增用户与岗位管理
|
||||
// List<SysUserPost> list = new ArrayList<SysUserPost>();
|
||||
// for (Long postId : posts)
|
||||
// {
|
||||
// SysUserPost up = new SysUserPost();
|
||||
// up.setUserId(user.getUserId());
|
||||
// up.setPostId(postId);
|
||||
// list.add(up);
|
||||
// }
|
||||
// if (list.size() > 0)
|
||||
// {
|
||||
// userPostMapper.batchUserPost(list);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过用户ID删除用户
|
||||
// *
|
||||
// * @param userId 用户ID
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public int deleteUserById(Long userId)
|
||||
// {
|
||||
// // 删除用户与角色关联
|
||||
// userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// // 删除用户与岗位表
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
// return userMapper.deleteUserById(userId);
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * 导入用户数据
|
||||
|
||||
Reference in New Issue
Block a user