diff --git a/src/main/java/umc/th/juinjang/controller/MemberController.java b/src/main/java/umc/th/juinjang/controller/MemberController.java index ff2ee6d..9973cef 100644 --- a/src/main/java/umc/th/juinjang/controller/MemberController.java +++ b/src/main/java/umc/th/juinjang/controller/MemberController.java @@ -1,6 +1,7 @@ package umc.th.juinjang.controller; import io.swagger.v3.oas.annotations.Operation; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.userdetails.UserDetails; @@ -11,6 +12,7 @@ import umc.th.juinjang.apiPayload.ExceptionHandler; import umc.th.juinjang.apiPayload.code.status.ErrorStatus; import umc.th.juinjang.apiPayload.exception.handler.MemberHandler; +import umc.th.juinjang.model.dto.member.MemberAgreeVersionPostRequest; import umc.th.juinjang.model.dto.member.MemberRequestDto; import umc.th.juinjang.model.dto.member.MemberResponseDto; import umc.th.juinjang.model.entity.Member; @@ -54,4 +56,11 @@ public ApiResponse getProfile (@AuthenticationPrin MemberResponseDto.profileDto result = memberService.updateProfileImage(member, multipartFile); return ApiResponse.onSuccess(result); } + + @Operation(summary = "약관 동의 버전 전송") + @PostMapping ("/members/terms") + public ApiResponse createMemberAgreeVersion(@AuthenticationPrincipal Member member, @RequestBody @Valid MemberAgreeVersionPostRequest memberAgreeVersionPostRequest) { + memberService.createMemberAgreeVersion(member, memberAgreeVersionPostRequest); + return ApiResponse.onSuccess(null); + } } diff --git a/src/main/java/umc/th/juinjang/model/dto/member/MemberAgreeVersionPostRequest.java b/src/main/java/umc/th/juinjang/model/dto/member/MemberAgreeVersionPostRequest.java new file mode 100644 index 0000000..599ad67 --- /dev/null +++ b/src/main/java/umc/th/juinjang/model/dto/member/MemberAgreeVersionPostRequest.java @@ -0,0 +1,11 @@ +package umc.th.juinjang.model.dto.member; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; + +public record MemberAgreeVersionPostRequest( + @Pattern(regexp = "\\d+\\.\\d+\\.\\d+", message = "x.x.x(x는 숫자) 형식이 아닙니다. 다시 확인해주세요.") + @NotBlank + String agreeVersion +) { +} diff --git a/src/main/java/umc/th/juinjang/model/entity/Member.java b/src/main/java/umc/th/juinjang/model/entity/Member.java index 128e483..9679249 100644 --- a/src/main/java/umc/th/juinjang/model/entity/Member.java +++ b/src/main/java/umc/th/juinjang/model/entity/Member.java @@ -36,6 +36,9 @@ public class Member extends BaseEntity implements UserDetails { @Column(nullable = false) private MemberProvider provider; + @Column(name = "agree_version") + private String agreeVersion; + // apple client id값을 의미 @Column(name = "apple_sub", unique = true) private String appleSub; @@ -110,4 +113,6 @@ public void updateNickname(String nickname) { public void updateImage(String imageUrl) { this.imageUrl = imageUrl; } + + public void updateAgreeVersion(final String agreeVersion) { this.agreeVersion = agreeVersion; } } \ No newline at end of file diff --git a/src/main/java/umc/th/juinjang/service/MemberService/MemberService.java b/src/main/java/umc/th/juinjang/service/MemberService/MemberService.java index f085c7e..9f55336 100644 --- a/src/main/java/umc/th/juinjang/service/MemberService/MemberService.java +++ b/src/main/java/umc/th/juinjang/service/MemberService/MemberService.java @@ -15,6 +15,7 @@ import umc.th.juinjang.apiPayload.code.status.ErrorStatus; import umc.th.juinjang.apiPayload.exception.handler.MemberHandler; import umc.th.juinjang.converter.record.RecordConverter; +import umc.th.juinjang.model.dto.member.MemberAgreeVersionPostRequest; import umc.th.juinjang.model.dto.member.MemberRequestDto; import umc.th.juinjang.model.dto.member.MemberResponseDto; import umc.th.juinjang.model.entity.Member; @@ -95,4 +96,12 @@ public MemberResponseDto.profileDto updateProfileImage(Member member, MultipartF return new MemberResponseDto.profileDto(member.getNickname(), member.getEmail(), member.getProvider().toString(), member.getImageUrl()); } + + public void createMemberAgreeVersion(final Member member, final MemberAgreeVersionPostRequest memberAgreeVersionPostRequest) { + getMember(member).updateAgreeVersion(memberAgreeVersionPostRequest.agreeVersion()); + } + + private Member getMember(Member member) { + return memberRepository.findById(member.getMemberId()).orElseThrow(() -> new MemberHandler(MEMBER_NOT_FOUND)); + } }