Skip to content

Commit

Permalink
[FIX] 회원가입 MultipartFile 받기
Browse files Browse the repository at this point in the history
  • Loading branch information
walesmin committed Aug 13, 2024
1 parent d7cc4e0 commit 332d776
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.stepperbackend.apiPayload.ApiResponse;
import com.example.stepperbackend.jwt.JWTUtil;
import com.example.stepperbackend.service.MemberService.MemberService;
import com.example.stepperbackend.service.S3Service;
import com.example.stepperbackend.web.dto.MemberDto;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -15,6 +16,7 @@
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@Slf4j
Expand All @@ -31,11 +33,25 @@ public class MemberController {

private final JWTUtil jwtUtil;

private final S3Service s3Service;

@Operation(summary = "회원가입 API",description = "사용자 회원가입")
// @Operation(summary = "회원가입 API",description = "사용자 회원가입")
// @PostMapping("/signup")
// public ApiResponse<MemberDto.MemberResponseDto> signup(@RequestBody MemberDto.MemberSignupRequestDto dto) {
// System.out.println("MemberController.signup");
// MemberDto.MemberResponseDto response = memberService.signup(dto);
// return ApiResponse.onSuccess(response);
// }

@Operation(summary = "회원가입 API", description = "사용자 회원가입")
@PostMapping("/signup")
public ApiResponse<MemberDto.MemberResponseDto> signup(@RequestBody MemberDto.MemberSignupRequestDto dto) {
System.out.println("MemberController.signup");
public ApiResponse<MemberDto.MemberResponseDto> signup(@RequestPart("data") MemberDto.MemberSignupRequestDto dto,
@RequestPart(value = "profileImage", required = false) MultipartFile profileImage) {
if (profileImage != null && !profileImage.isEmpty()) {
String profileImageUrl = s3Service.saveFile(profileImage); // 프로필 이미지를 S3에 업로드하고 URL을 반환
dto.setProfileImage(profileImageUrl); // DTO에 프로필 이미지 URL 설정
}

MemberDto.MemberResponseDto response = memberService.signup(dto);
return ApiResponse.onSuccess(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;

Expand Down

0 comments on commit 332d776

Please sign in to comment.