优化代码

This commit is contained in:
RuoYi
2025-08-28 12:43:02 +08:00
parent c0e1402409
commit 8fd2adbd95
3 changed files with 31 additions and 3 deletions

View File

@@ -101,6 +101,25 @@ public interface UserMapper
*/
public int updateUserAvatar(@Param("userId") Long userId, @Param("avatar") String avatar);
/**
* 修改用户状态
*
* @param userId 用户ID
* @param status 状态
* @return 结果
*/
public int updateUserStatus(@Param("userId") Long userId, @Param("status") String status);
/**
* 重置用户密码
*
* @param userId 用户ID
* @param password 密码
* @param salt 盐
* @return 结果
*/
public int resetUserPwd(@Param("userId") Long userId, @Param("password") String password, @Param("salt") String salt);
/**
* 更新用户登录信息IP和登录时间
*

View File

@@ -337,8 +337,8 @@ public class UserServiceImpl implements IUserService
public int resetUserPwd(User user)
{
user.randomSalt();
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
return updateUserInfo(user);
String password = passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt());
return userMapper.resetUserPwd(user.getUserId(), password, user.getSalt());
}
/**
@@ -558,6 +558,7 @@ public class UserServiceImpl implements IUserService
checkUserDataScope(u.getUserId());
deptService.checkDeptDataScope(user.getDeptId());
user.setUserId(u.getUserId());
user.setDeptId(u.getDeptId());
user.setUpdateBy(operName);
userMapper.updateUser(user);
successNum++;
@@ -603,6 +604,6 @@ public class UserServiceImpl implements IUserService
@Override
public int changeStatus(User user)
{
return userMapper.updateUser(user);
return userMapper.updateUserStatus(user.getUserId(), user.getStatus());
}
}

View File

@@ -170,6 +170,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_user set avatar = #{avatar} where user_id = #{userId}
</update>
<update id="resetUserPwd" parameterType="User">
update sys_user SET password = #{password}, salt = #{salt}, update_time = sysdate() where user_id = #{userId}
</update>
<update id="updateUserStatus" parameterType="User">
update sys_user SET status = #{status}, update_time = sysdate() where user_id = #{userId}
</update>
<update id="updateLoginInfo" parameterType="User">
update sys_user set login_ip = #{loginIp}, login_date = #{loginDate} where user_id = #{userId}
</update>