Skip to content

Commit

Permalink
🚑 [HOTFIX]: 이미지 업로드 방식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnnoh committed Apr 6, 2024
1 parent 12eef56 commit 013e765
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,8 +51,9 @@ public ResponseEntity<BasicInfoResponse> getInfo(@RequestParam int size, @Reques
})
@PatchMapping(value = "/my-info")
public ResponseEntity<EditMyInfoResponse> 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 = "사용자가 북마크한 팀원모집 게시물을 조회합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ public class EditMyInfoRequest {
private Fields interestField;
private List<String> links;
private String selfIntro;
private String profileImageUrl;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.example.weneedbe.domain.user.service;

import java.io.IOException;
import java.util.List;

import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -68,18 +70,16 @@ public ResponseEntity<UserInfoResponse> 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(),
Expand Down

0 comments on commit 013e765

Please sign in to comment.