Skip to content

Commit

Permalink
fix : member patch api multipart
Browse files Browse the repository at this point in the history
  • Loading branch information
sycuuui committed Jun 9, 2024
1 parent a282665 commit 88748ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Journey.Together.domain.member.controller;

import Journey.Together.domain.dairy.dto.PlanReviewReq;
import Journey.Together.domain.member.dto.InterestDto;
import Journey.Together.domain.member.dto.MemberReq;
import Journey.Together.domain.member.dto.MemberRes;
Expand All @@ -8,9 +9,13 @@
import Journey.Together.global.exception.Success;
import Journey.Together.global.security.PrincipalDetails;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Null;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequiredArgsConstructor
Expand All @@ -20,8 +25,8 @@ public class MemberController {
private final MemberService memberService;

@PatchMapping ("")
public ApiResponse saveMemberInfo(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestBody MemberReq memberReq) {
memberService.saveInfo(principalDetails.getMember(),memberReq);
public ApiResponse saveMemberInfo(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false) MultipartFile profileImage, @RequestPart MemberReq memberReq) {
memberService.saveInfo(principalDetails.getMember(),profileImage,memberReq);
return ApiResponse.success(Success.UPDATE_USER_INFO_SUCCESS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public record MemberReq(
@Null
String phone,
@Null
MultipartFile profileImage,
@Null
String bloodType,
@Null
String birth,
Expand All @@ -27,6 +25,7 @@ public record MemberReq(
@Null
String part1_phone,
@Null
@Null
String part2_rel,
@Null
String part2_phone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.time.Duration;
import java.time.LocalDateTime;
Expand All @@ -34,7 +35,7 @@ public MyPageRes getMypage(Member member){
}

@Transactional
public void saveInfo(Member member,MemberReq memberReq){
public void saveInfo(Member member, MultipartFile profileImage, MemberReq memberReq){
// Validation
memberRepository.findMemberByEmailAndDeletedAtIsNull(member.getEmail()).orElseThrow(()->new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION));
//Business
Expand All @@ -44,8 +45,8 @@ public void saveInfo(Member member,MemberReq memberReq){
if (memberReq.phone() != null) {
member.setPhone(memberReq.phone());
}
if (memberReq.profileImage() != null) {
s3Client.update(member.getProfileUuid()+"/profile",memberReq.profileImage());
if (profileImage != null) {
s3Client.update(member.getProfileUuid()+"/profile",profileImage);
}
if (memberReq.bloodType() != null) {
member.setBloodType(memberReq.bloodType());
Expand Down

0 comments on commit 88748ae

Please sign in to comment.