From 013e765bf053ddd612b007a70ac284994f4c741b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EC=A0=95=EC=99=84?= Date: Sat, 6 Apr 2024 15:02:29 +0900 Subject: [PATCH] =?UTF-8?q?:ambulance:=20[HOTFIX]:=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EB=B0=A9=EC=8B=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weneedbe/domain/user/api/MyPageController.java | 6 ++++-- .../domain/user/dto/request/EditMyInfoRequest.java | 1 - .../weneedbe/domain/user/service/UserService.java | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/example/weneedbe/domain/user/api/MyPageController.java b/src/main/java/org/example/weneedbe/domain/user/api/MyPageController.java index 33fcb24a..3113af5e 100644 --- a/src/main/java/org/example/weneedbe/domain/user/api/MyPageController.java +++ b/src/main/java/org/example/weneedbe/domain/user/api/MyPageController.java @@ -17,6 +17,7 @@ import org.example.weneedbe.global.error.ErrorResponse; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; @Tag(name = "User MyPage Controller", description = "사용자의 마이페이지 관련 API입니다.") @RestController @@ -50,8 +51,9 @@ public ResponseEntity getInfo(@RequestParam int size, @Reques }) @PatchMapping(value = "/my-info") public ResponseEntity editInfo(@RequestHeader("Authorization") String authorizationHeader, - @RequestBody EditMyInfoRequest request) throws IOException { - return ResponseEntity.ok(userService.editInfo(authorizationHeader, request)); + @RequestPart(required = false) MultipartFile profileImage, + @RequestPart EditMyInfoRequest request) throws IOException { + return ResponseEntity.ok(userService.editInfo(authorizationHeader, profileImage, request)); } @Operation(summary = "마이페이지의 관심 크루 조회", description = "사용자가 북마크한 팀원모집 게시물을 조회합니다.") diff --git a/src/main/java/org/example/weneedbe/domain/user/dto/request/EditMyInfoRequest.java b/src/main/java/org/example/weneedbe/domain/user/dto/request/EditMyInfoRequest.java index 08d28704..806759c9 100644 --- a/src/main/java/org/example/weneedbe/domain/user/dto/request/EditMyInfoRequest.java +++ b/src/main/java/org/example/weneedbe/domain/user/dto/request/EditMyInfoRequest.java @@ -15,5 +15,4 @@ public class EditMyInfoRequest { private Fields interestField; private List links; private String selfIntro; - private String profileImageUrl; } diff --git a/src/main/java/org/example/weneedbe/domain/user/service/UserService.java b/src/main/java/org/example/weneedbe/domain/user/service/UserService.java index 742079fd..6a45697b 100644 --- a/src/main/java/org/example/weneedbe/domain/user/service/UserService.java +++ b/src/main/java/org/example/weneedbe/domain/user/service/UserService.java @@ -1,5 +1,6 @@ package org.example.weneedbe.domain.user.service; +import java.io.IOException; import java.util.List; import lombok.RequiredArgsConstructor; @@ -30,6 +31,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; @Service @@ -68,18 +70,16 @@ public ResponseEntity setInfo(UserInfoRequest request, String return new ResponseEntity<>(new UserInfoResponse(true, "상세 정보 입력 성공"), HttpStatus.OK); } - public EditMyInfoResponse editInfo(String authorizationHeader, EditMyInfoRequest request) { + public EditMyInfoResponse editInfo(String authorizationHeader, MultipartFile profileImage, EditMyInfoRequest request) throws IOException { User user = findUser(authorizationHeader); - String profileImageUrl = user.getProfile(); - String requestImageUrl = request.getProfileImageUrl(); try { - if (requestImageUrl != null) { + if (profileImage != null) { if (profileImageUrl != null) { s3Service.deleteFile(profileImageUrl); } - profileImageUrl = requestImageUrl; + profileImageUrl = s3Service.uploadImage(profileImage); } user.editUserInfo(profileImageUrl, request.getNickname(),