Skip to content

Commit

Permalink
Merge pull request #273 from Juinjang/feat/#271
Browse files Browse the repository at this point in the history
[feat/#271] 약관 정보 전송 API
  • Loading branch information
PicturePark1101 authored Jan 17, 2025
2 parents ac9ad1a + 77128b6 commit 5cb4cc9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -54,4 +56,11 @@ public ApiResponse<MemberResponseDto.profileDto> getProfile (@AuthenticationPrin
MemberResponseDto.profileDto result = memberService.updateProfileImage(member, multipartFile);
return ApiResponse.onSuccess(result);
}

@Operation(summary = "약관 동의 버전 전송")
@PostMapping ("/members/terms")
public ApiResponse<Void> createMemberAgreeVersion(@AuthenticationPrincipal Member member, @RequestBody @Valid MemberAgreeVersionPostRequest memberAgreeVersionPostRequest) {
memberService.createMemberAgreeVersion(member, memberAgreeVersionPostRequest);
return ApiResponse.onSuccess(null);
}
}
Original file line number Diff line number Diff line change
@@ -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
) {
}
5 changes: 5 additions & 0 deletions src/main/java/umc/th/juinjang/model/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 5cb4cc9

Please sign in to comment.