Skip to content

Commit 5b3511b

Browse files
committed
Revert "feat(user): 重构 uploadAvatar 方法,使用 userID 代替 accessToken"
This reverts commit 7b9596f.
1 parent 60ea865 commit 5b3511b

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

flow-client/src/main/java/com/ligg/flowclient/controller/FlowUserController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.ligg.flowclient.module.dto.UpdateUserDto;
1313
import com.ligg.flowclient.module.vo.FlowUserVo;
1414
import com.ligg.common.vo.bangumi.UserCollectionsVo;
15-
import com.ligg.flowclient.service.JwtTokenService;
1615
import com.ligg.flowclient.service.UserBgmCollectionService;
1716
import com.ligg.flowclient.service.UserService;
1817
import jakarta.validation.Valid;
@@ -26,7 +25,7 @@
2625
public class FlowUserController {
2726

2827
private final UserService userService;
29-
private final JwtTokenService jwtTokenService;
28+
3029
private final UserBgmCollectionService userBgmCollectionService;
3130

3231
/**
@@ -58,8 +57,7 @@ public Result<FlowUserVo> updateUserInfo(
5857
public Result<FlowUserVo> uploadAvatar(
5958
@RequestAttribute(AuthorizationInterceptor.ACCESS_TOKEN_REQUEST_ATTRIBUTE) String accessToken,
6059
@RequestParam("file") MultipartFile file) {
61-
Long userId = jwtTokenService.validateAccessToken(accessToken);
62-
FlowUserVo userVo = userService.uploadAvatar(userId, file);
60+
FlowUserVo userVo = userService.uploadAvatar(accessToken, file);
6361
return Result.success(ResponseCode.SUCCESS, userVo);
6462
}
6563

flow-client/src/main/java/com/ligg/flowclient/service/UserService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public interface UserService {
3434
/**
3535
* 上传用户头像,将图片存储到对象存储并更新用户头像 URL。
3636
*
37-
* @param userId 登录用户的 id
38-
* @param file 图片文件(支持 JPEG / PNG / WebP / GIF)
37+
* @param accessToken 当前登录用户的 access_token
38+
* @param file 图片文件(支持 JPEG / PNG / WebP / GIF)
3939
* @return 更新后的用户信息
4040
*/
41-
FlowUserVo uploadAvatar(Long userId, MultipartFile file);
41+
FlowUserVo uploadAvatar(String accessToken, MultipartFile file);
4242

4343
/**
4444
* 为当前账号绑定邮箱并设置登录密码。

flow-client/src/main/java/com/ligg/flowclient/service/impl/UserServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public FlowUserVo updateUserInfo(String accessToken, UpdateUserDto updateUserDto
127127

128128
@Override
129129
@Transactional(rollbackFor = Exception.class)
130-
public FlowUserVo uploadAvatar(Long userId, MultipartFile file) {
130+
public FlowUserVo uploadAvatar(String accessToken, MultipartFile file) {
131131
if (file == null || file.isEmpty()) {
132132
throw new IllegalArgumentException("头像文件不能为空");
133133
}
@@ -159,6 +159,7 @@ public FlowUserVo uploadAvatar(Long userId, MultipartFile file) {
159159
throw new IllegalArgumentException("文件内容不是合法的图片格式");
160160
}
161161

162+
Long userId = jwtTokenService.validateAccessToken(accessToken);
162163
checkAvatarUploadLimit(userId);
163164
UserEntity user = userMapper.selectById(userId);
164165
if (user == null) {

0 commit comments

Comments
 (0)