From 5667ef55256e7f2c7e0767297c92771763a6f45f Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 10 Mar 2023 09:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/xkrs/dao/SysUserDao.java | 10 ++-------- .../java/com/xkrs/service/impl/SysUserServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index 1e8b6e2..87b2028 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -71,20 +71,14 @@ public interface SysUserDao extends JpaRepository, JpaSpeci void updatePassword(Long userId, String newPassword); /** - * 根据id查询用户的信息 - */ - @Query(value = "select * from sys_user where id = ?", nativeQuery = true) - SysUserEntity selectByUserId(Long userId); - - /** - * 记录用户登录次数 + * 修改用户登录次数 */ @Query(value = "update sys_user set login_num = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) void updateLoginNum(Long userId, Integer loginNum); /** - * 修改登陆时间 + * 修改最后登录时间 */ @Query(value = "update sys_user set login_last_time = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 5a26599..95713f3 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -275,7 +275,7 @@ public class SysUserServiceImpl implements SysUserService { if (!newPassword.equals(confirmPassword)) { return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale); } - SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); + SysUserEntity sysUserEntity = sysUserDao.findById(userId).get(); String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt()); sysUserDao.updatePassword(userId, newAfterPassword); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);