mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-24 06:14:32 +08:00
update 添加用户解锁功能
This commit is contained in:
@@ -4,15 +4,12 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||||||
import com.baomidou.lock.annotation.Lock4j;
|
import com.baomidou.lock.annotation.Lock4j;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.constant.CacheConstants;
|
import org.dromara.common.core.domain.PageResult;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
|
||||||
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.log.annotation.Log;
|
||||||
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.core.domain.PageResult;
|
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.system.domain.bo.SysLoginInfoBo;
|
import org.dromara.system.domain.bo.SysLoginInfoBo;
|
||||||
import org.dromara.system.domain.vo.SysLoginInfoVo;
|
import org.dromara.system.domain.vo.SysLoginInfoVo;
|
||||||
@@ -52,7 +49,7 @@ public class SysLoginInfoController extends BaseController {
|
|||||||
* 导出系统访问记录列表。
|
* 导出系统访问记录列表。
|
||||||
*
|
*
|
||||||
* @param loginInfo 查询条件
|
* @param loginInfo 查询条件
|
||||||
* @param response HTTP 响应
|
* @param response HTTP 响应
|
||||||
*/
|
*/
|
||||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@SaCheckPermission("monitor:logininfo:export")
|
@SaCheckPermission("monitor:logininfo:export")
|
||||||
@@ -89,22 +86,4 @@ public class SysLoginInfoController extends BaseController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 清除指定用户的登录失败锁定状态。
|
|
||||||
*
|
|
||||||
* @param userName 用户名
|
|
||||||
* @return 操作结果
|
|
||||||
*/
|
|
||||||
@SaCheckPermission("monitor:logininfo:unlock")
|
|
||||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
|
||||||
@RepeatSubmit()
|
|
||||||
@GetMapping("/unlock/{userName}")
|
|
||||||
public R<Void> unlock(@PathVariable("userName") String userName) {
|
|
||||||
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName;
|
|
||||||
if (RedisUtils.hasKey(loginName)) {
|
|
||||||
RedisUtils.deleteObject(loginName);
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import cn.hutool.crypto.digest.BCrypt;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.constant.CacheConstants;
|
||||||
import org.dromara.common.core.constant.SystemConstants;
|
import org.dromara.common.core.constant.SystemConstants;
|
||||||
|
import org.dromara.common.core.domain.PageResult;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.core.domain.model.LoginUser;
|
import org.dromara.common.core.domain.model.LoginUser;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
@@ -16,12 +18,12 @@ import org.dromara.common.core.utils.StringUtils;
|
|||||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||||
import org.dromara.common.excel.core.ExcelResult;
|
import org.dromara.common.excel.core.ExcelResult;
|
||||||
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
|
||||||
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.log.annotation.Log;
|
||||||
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.core.domain.PageResult;
|
|
||||||
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||||
|
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.system.domain.bo.SysDeptBo;
|
import org.dromara.system.domain.bo.SysDeptBo;
|
||||||
@@ -61,7 +63,7 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 分页查询用户列表。
|
* 分页查询用户列表。
|
||||||
*
|
*
|
||||||
* @param user 用户查询条件
|
* @param user 用户查询条件
|
||||||
* @param pageQuery 分页参数
|
* @param pageQuery 分页参数
|
||||||
* @return 用户分页列表
|
* @return 用户分页列表
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +76,7 @@ public class SysUserController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 导出符合条件的用户列表。
|
* 导出符合条件的用户列表。
|
||||||
*
|
*
|
||||||
* @param user 用户查询条件
|
* @param user 用户查询条件
|
||||||
* @param response HTTP 响应
|
* @param response HTTP 响应
|
||||||
*/
|
*/
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@@ -270,6 +272,28 @@ public class SysUserController extends BaseController {
|
|||||||
return toAjax(userService.updateUserStatus(user.getUserId(), user.getStatus()));
|
return toAjax(userService.updateUserStatus(user.getUserId(), user.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("system:user:unlock")
|
||||||
|
@Log(title = "用户解锁", businessType = BusinessType.OTHER)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@GetMapping("/unlock/{userId}")
|
||||||
|
public R<Void> unlock(@PathVariable Long userId) {
|
||||||
|
SysUserVo user = userService.selectUserById(userId);
|
||||||
|
if (ObjectUtil.isNull(user)) {
|
||||||
|
return R.fail("用户不存在");
|
||||||
|
}
|
||||||
|
String loginName = CacheConstants.PWD_ERR_CNT_KEY + user.getUserName();
|
||||||
|
if (RedisUtils.hasKey(loginName)) {
|
||||||
|
RedisUtils.deleteObject(loginName);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户编号获取授权角色
|
* 根据用户编号获取授权角色
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user