mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 19:15:06 +08:00
修复头像的 bug
This commit is contained in:
@ -89,14 +89,14 @@ public class SysUserProfileController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/upload-avatar")
|
||||
@PutMapping("/update-avatar")
|
||||
@ApiOperation("上传用户个人头像")
|
||||
public CommonResult<Boolean> updateUserAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException {
|
||||
public CommonResult<String> updateUserAvatar(@RequestParam("avatarFile") MultipartFile file) throws IOException {
|
||||
if (file.isEmpty()) {
|
||||
throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
|
||||
}
|
||||
userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
|
||||
return success(true);
|
||||
String avatar = userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
|
||||
return success(avatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public interface SysUserService {
|
||||
* @param id 用户 id
|
||||
* @param avatarFile 头像文件
|
||||
*/
|
||||
void updateUserAvatar(Long id, InputStream avatarFile);
|
||||
String updateUserAvatar(Long id, InputStream avatarFile);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
|
@ -105,7 +105,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserAvatar(Long id, InputStream avatarFile) {
|
||||
public String updateUserAvatar(Long id, InputStream avatarFile) {
|
||||
this.checkUserExists(id);
|
||||
// 存储文件
|
||||
String avatar = fileService.createFile(IdUtil.fastUUID(), IoUtil.readBytes(avatarFile));
|
||||
@ -114,6 +114,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
sysUserDO.setId(id);
|
||||
sysUserDO.setAvatar(avatar);
|
||||
userMapper.updateById(sysUserDO);
|
||||
return avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user