From 6ec76dea6ebd050e10336a4bc41525233c2e9ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EC=A0=95=EC=99=84?= Date: Thu, 4 Apr 2024 15:32:18 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:adhesive=5Fbandage:=20[fix]:=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=82=AC=EC=A7=84=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?DTO=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weneedbe/domain/user/api/MyPageController.java | 9 +++------ .../domain/user/dto/request/EditMyInfoRequest.java | 1 + 2 files changed, 4 insertions(+), 6 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 120bb969..33fcb24a 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 @@ -15,10 +15,8 @@ import org.example.weneedbe.domain.user.dto.response.mypage.*; import org.example.weneedbe.domain.user.service.UserService; import org.example.weneedbe.global.error.ErrorResponse; -import org.springframework.http.MediaType; 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,11 +48,10 @@ public ResponseEntity getInfo(@RequestParam int size, @Reques @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - @PatchMapping(value = "/my-info", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PatchMapping(value = "/my-info") public ResponseEntity editInfo(@RequestHeader("Authorization") String authorizationHeader, - @RequestPart(required = false) MultipartFile profileImage, - @RequestPart EditMyInfoRequest request) throws IOException { - return ResponseEntity.ok(userService.editInfo(authorizationHeader, profileImage, request)); + @RequestBody EditMyInfoRequest request) throws IOException { + return ResponseEntity.ok(userService.editInfo(authorizationHeader, 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 806759c9..08d28704 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,4 +15,5 @@ public class EditMyInfoRequest { private Fields interestField; private List links; private String selfIntro; + private String profileImageUrl; } From 3119b4c640b4f3635c2e7e3e049c87e2b0639790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EC=A0=95=EC=99=84?= Date: Thu, 4 Apr 2024 16:20:41 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:adhesive=5Fbandage:=20[fix]:=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/weneedbe/domain/user/service/UserService.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 a8f57216..acddf47c 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 @@ -30,9 +30,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; @Service @Slf4j @@ -70,16 +68,16 @@ public ResponseEntity setInfo(UserInfoRequest request, String return new ResponseEntity<>(new UserInfoResponse(true, "상세 정보 입력 성공"), HttpStatus.OK); } - public EditMyInfoResponse editInfo(String authorizationHeader, MultipartFile profileImage, EditMyInfoRequest request) throws IOException { + public EditMyInfoResponse editInfo(String authorizationHeader, EditMyInfoRequest request) { User user = findUser(authorizationHeader); String profileImageUrl = user.getProfile(); try { - if (profileImage != null) { + if (request.getProfileImageUrl() != null) { if (profileImageUrl != null) { s3Service.deleteFile(user.getProfile()); } - profileImageUrl = s3Service.uploadImage(profileImage); + profileImageUrl = request.getProfileImageUrl(); } user.editUserInfo(profileImageUrl, request.getNickname(), From ad3493af4c13d2924dc9da99f4905632c3aafe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EC=A0=95=EC=99=84?= Date: Thu, 4 Apr 2024 16:36:43 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:adhesive=5Fbandage:=20[fix]:=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=9E=AC=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/weneedbe/domain/user/service/UserService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 acddf47c..742079fd 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 @@ -70,14 +70,16 @@ public ResponseEntity setInfo(UserInfoRequest request, String public EditMyInfoResponse editInfo(String authorizationHeader, EditMyInfoRequest request) { User user = findUser(authorizationHeader); + String profileImageUrl = user.getProfile(); + String requestImageUrl = request.getProfileImageUrl(); try { - if (request.getProfileImageUrl() != null) { + if (requestImageUrl != null) { if (profileImageUrl != null) { - s3Service.deleteFile(user.getProfile()); + s3Service.deleteFile(profileImageUrl); } - profileImageUrl = request.getProfileImageUrl(); + profileImageUrl = requestImageUrl; } user.editUserInfo(profileImageUrl, request.getNickname(),