mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-13 01:31:53 +08:00
文件表建加原文件名称字段name,相关代码修改
This commit is contained in:
@@ -47,7 +47,7 @@ public class AppUserController {
|
||||
if (file.isEmpty()) {
|
||||
throw exception(FILE_IS_EMPTY);
|
||||
}
|
||||
String avatar = userService.updateUserAvatar(getLoginUserId(), file.getOriginalFilename(), file.getInputStream());
|
||||
String avatar = userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
|
||||
return success(avatar);
|
||||
}
|
||||
|
||||
|
@@ -57,11 +57,10 @@ public interface MemberUserService {
|
||||
/**
|
||||
* 修改用户头像
|
||||
* @param userId 用户id
|
||||
* @param originalName 原文件名
|
||||
* @param inputStream 头像文件
|
||||
* @return 头像url
|
||||
*/
|
||||
String updateUserAvatar(Long userId, String originalName, InputStream inputStream) throws Exception;
|
||||
String updateUserAvatar(Long userId, InputStream inputStream) throws Exception;
|
||||
|
||||
/**
|
||||
* 修改手机
|
||||
|
@@ -100,10 +100,10 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateUserAvatar(Long userId, String originalName, InputStream avatarFile) throws Exception {
|
||||
public String updateUserAvatar(Long userId, InputStream avatarFile) throws Exception {
|
||||
this.checkUserExists(userId);
|
||||
// 创建文件
|
||||
String avatar = fileApi.createFile(originalName,IoUtil.readBytes(avatarFile));
|
||||
String avatar = fileApi.createFile(IoUtil.readBytes(avatarFile));
|
||||
// 更新头像路径
|
||||
memberUserMapper.updateById(MemberUserDO.builder().id(userId).avatar(avatar).build());
|
||||
return avatar;
|
||||
|
@@ -86,10 +86,9 @@ public class MemberUserServiceImplTest extends BaseDbAndRedisUnitTest {
|
||||
ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes);
|
||||
// mock 方法
|
||||
String avatar = randomString();
|
||||
String originalName = "单测文件名";
|
||||
when(fileApi.createFile(originalName, eq(avatarFileBytes))).thenReturn(avatar);
|
||||
when(fileApi.createFile(eq(avatarFileBytes))).thenReturn(avatar);
|
||||
// 调用
|
||||
String str = memberUserService.updateUserAvatar(userId, originalName, avatarFile);
|
||||
String str = memberUserService.updateUserAvatar(userId, avatarFile);
|
||||
// 断言
|
||||
assertEquals(avatar, str);
|
||||
}
|
||||
|
Reference in New Issue
Block a user