From afcbd1258db213732ece0c36a37a8d5242fe2bcf Mon Sep 17 00:00:00 2001 From: bflykky Date: Mon, 12 Aug 2024 14:58:18 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=82=B4=20memberId=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 11 +++++++++-- .../domain/member/converter/MemberConverter.java | 16 +++++++++++----- .../domain/member/service/MemberService.java | 2 ++ .../domain/member/service/MemberServiceImpl.java | 6 ++++++ .../global/result/code/MemberResultCode.java | 4 +++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java index b1b6d34..4dbf64b 100644 --- a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java +++ b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java @@ -3,6 +3,7 @@ import com.umc.naoman.domain.member.converter.MemberConverter; import com.umc.naoman.domain.member.dto.MemberResponse; import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.service.MemberService; @@ -22,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import static com.umc.naoman.global.result.code.MemberResultCode.CHECK_MEMBER_REGISTRATION; +import static com.umc.naoman.global.result.code.MemberResultCode.*; @RestController @RequestMapping("/members") @@ -52,6 +53,12 @@ public ResultResponse getMyInfo(@LoginMember Member member) { return ResultResponse.of(CHECK_MEMBER_REGISTRATION, memberService.getMyInfo(member)); } + @GetMapping("/my-memberId") + @Operation(summary = "내 memberId 조회 API", description = "자신의 memberId를 조회하는 API입니다.") + public ResultResponse getMyMemberId(@LoginMember Member member) { + return ResultResponse.of(GET_MY_MEMBERID, memberService.getMyMemberId(member)); + } + @GetMapping("/terms/{memberId}") @Operation(summary = "마케팅 약관 동의 여부 조회 API", description = "[PathVariable]\n memberId\n[request]\n" + "[response]\n 마케팅 동의 여부 -> 동의 => true, 비동의 => false") @@ -68,6 +75,6 @@ public ResultResponse getMarketingAgreed(@PathVa @GetMapping("/samplePhoto") @Operation(summary = "샘플 사진 업로드 여부 조회", description = "자신이 샘플 사진을 업로드했는지 여부를 확인하는 API입니다.") public ResultResponse hasSamplePhoto(@LoginMember Member member) { - return ResultResponse.of(CHECK_MEMBER_REGISTRATION, memberService.hasSamplePhoto(member)); + return ResultResponse.of(CHECK_HAS_SAMPLE_PHOTO, memberService.hasSamplePhoto(member)); } } diff --git a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java index 31c3a12..e1fece0 100644 --- a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java +++ b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java @@ -1,10 +1,12 @@ package com.umc.naoman.domain.member.converter; import com.umc.naoman.domain.member.dto.MemberRequest.SignupRequest; -import com.umc.naoman.domain.member.dto.MemberResponse; import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MarketingAgreed; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; import io.jsonwebtoken.Claims; @@ -42,8 +44,8 @@ public SignupRequest toSignupRequest(Claims payload, boolean marketingAgreed) { .build(); } - public MemberResponse.MemberInfo toMemberInfo(Member member) { - return MemberResponse.MemberInfo.builder() + public MemberInfo toMemberInfo(Member member) { + return MemberInfo.builder() .memberId(member.getId()) .name(member.getName()) .email(member.getEmail()) @@ -51,6 +53,10 @@ public MemberResponse.MemberInfo toMemberInfo(Member member) { .build(); } + public MemberId toMemberId(Long memberId) { + return new MemberId(memberId); + } + public CheckMemberRegistration toCheckMemberRegistration(boolean isRegistered) { return new CheckMemberRegistration(isRegistered); } @@ -59,8 +65,8 @@ public HasSamplePhoto toHasSamplePhoto(boolean hasSamplePhoto) { return new HasSamplePhoto(hasSamplePhoto); } - public MemberResponse.MarketingAgreed toMarketingAgreed(Member member) { - return MemberResponse.MarketingAgreed.builder() + public MarketingAgreed toMarketingAgreed(Member member) { + return MarketingAgreed.builder() .marketingAgreed(member.getMarketingAgreed()) .build(); } diff --git a/src/main/java/com/umc/naoman/domain/member/service/MemberService.java b/src/main/java/com/umc/naoman/domain/member/service/MemberService.java index 1009b58..6526b89 100644 --- a/src/main/java/com/umc/naoman/domain/member/service/MemberService.java +++ b/src/main/java/com/umc/naoman/domain/member/service/MemberService.java @@ -6,6 +6,7 @@ import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; @@ -17,6 +18,7 @@ public interface MemberService { CheckMemberRegistration checkRegistration(LoginRequest request); HasSamplePhoto hasSamplePhoto(Member member); MemberInfo getMyInfo(Member member); + MemberId getMyMemberId(Member member); Member findMember(Long memberId); Member findMember(SocialType socialType, String authId); diff --git a/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java b/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java index 60de5f2..5af55be 100644 --- a/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java @@ -7,6 +7,7 @@ import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; @@ -99,6 +100,11 @@ public MemberInfo getMyInfo(Member member) { return memberConverter.toMemberInfo(member); } + @Override + public MemberId getMyMemberId(Member member) { + return memberConverter.toMemberId(member.getId()); + } + @Override public Member findMember(Long memberId) { return memberRepository.findById(memberId) diff --git a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java index 4d31ec5..3ab97ab 100644 --- a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java +++ b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java @@ -13,7 +13,9 @@ public enum MemberResultCode implements ResultCode { EDIT_MYPAGE_INFO(200, "SM002", "내 정보를 성공적으로 수정하였습니다."), CHECK_MEMBER_REGISTRATION(200, "SM000", "해당 정보에 대응하는 회원의 가입 여부를 성공적으로 조회하였습니다."), MEMBER_INFO (200,"SM005","회원 정보를 성공적으로 조회하였습니다."), - CHECK_MARKETING_AGREED(200,"SM006","마케팅동의여부를 성공적으로 조회하였습니다."), + CHECK_MARKETING_AGREED(200,"SM006","마케팅 동의 여부를 성공적으로 조회하였습니다."), + GET_MY_MEMBERID(200,"SM000","자신의 memberId를 성공적으로 조회하였습니다."), + CHECK_HAS_SAMPLE_PHOTO(200,"SM000","자신의 샘플 사진 업로드 여부를 성공적으로 조회하였습니다."), ; private final int status; private final String code;