Skip to content

Commit

Permalink
Merge pull request #23 from KAKAO-TOUR-API-CONTEST/devyj
Browse files Browse the repository at this point in the history
fix : 프로필 이미지 수정 변경
  • Loading branch information
yyujin1231 authored Sep 4, 2024
2 parents 99a6662 + be219a0 commit 18dcb4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/main/java/com/example/ai_jeju/controller/MyPageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,24 @@ public ResponseDto myPage(@RequestHeader("Authorization") String token){

//프로필 이미지 변경
@PutMapping("/mypage/profileimg")
public ResponseEntity<String> updateProfileImage(@RequestParam Long userId, @RequestBody Map<String, String> request) {
String profileimg = request.get("profileimg");
myPageService.updateProfile(userId, profileimg);
return ResponseEntity.ok("success");
}
public ResponseEntity<String> updateProfileImage(@RequestHeader("Authorization") String token,@RequestBody Map<String, String> request) {
String accessToken = token.replace("Bearer ", "");
if (tokenProvider.validToken(accessToken)) {
Long userId = tokenProvider.getUserId(accessToken);
String profileImg = request.get("profileImg");
if (profileImg == null || profileImg.isEmpty()) {
return ResponseEntity.badRequest().body("프로필 이미지가 필요");
}
myPageService.updateProfile(userId, profileImg);
return ResponseEntity.ok("프로필 이미지 업데이트 완료");


} else {
return ResponseEntity.badRequest().body("프로필 이미지가 필요");
}

}


@DeleteMapping("/mypage/profileimg")
public ResponseEntity<String> deleteProfileImage(@RequestParam Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void updateNickname(Long id, String nickname) {
public void updateProfile(Long id, String profileimg) {
User user = userRepository.findById(id)
.orElseThrow(() -> new RuntimeException("User not found"));
user.setProfileImg(profileimg); // S3에 업로드된 이미지의 URL을 프로필 이미지로 설정
user.setProfileImg(profileimg);
userRepository.save(user);
}

Expand Down

0 comments on commit 18dcb4e

Please sign in to comment.