用户头像更换后移除旧头像文件

This commit is contained in:
RuoYi
2025-06-06 14:01:45 +08:00
parent 4c74687ca2
commit bcbb4ac994
8 changed files with 91 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
@@ -90,6 +91,15 @@ public interface SysUserMapper
*/
public int updateUser(SysUser user);
/**
* 修改用户头像
*
* @param userId 用户ID
* @param avatar 头像地址
* @return 结果
*/
public int updateUserAvatar(@Param("userId") Long userId, @Param("avatar") String avatar);
/**
* 新增用户信息
*

View File

@@ -124,6 +124,15 @@ public interface ISysUserService
*/
public int updateUserInfo(SysUser user);
/**
* 修改用户头像
*
* @param userId 用户ID
* @param avatar 头像地址
* @return 结果
*/
public boolean updateUserAvatar(Long userId, String avatar);
/**
* 用户授权角色
*

View File

@@ -275,6 +275,18 @@ public class SysUserServiceImpl implements ISysUserService
return userMapper.updateUser(user);
}
/**
* 修改用户头像
*
* @param userId 用户ID
* @param avatar 头像地址
* @return 结果
*/
public boolean updateUserAvatar(Long userId, String avatar)
{
return userMapper.updateUserAvatar(userId, avatar) > 0;
}
/**
* 用户授权角色
*

View File

@@ -166,6 +166,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<update id="updateUserAvatar" parameterType="SysUser">
update sys_user set avatar = #{avatar} where user_id = #{userId}
</update>
<update id="updateUser" parameterType="SysUser">
update sys_user
<set>