Skip to content

Commit

Permalink
feat: 내 memberId 조회 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
bflykky committed Aug 12, 2024
1 parent 816dabd commit afcbd12
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -52,6 +53,12 @@ public ResultResponse<MemberInfo> 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<MemberId> 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")
Expand All @@ -68,6 +75,6 @@ public ResultResponse<MemberResponse.MarketingAgreed> getMarketingAgreed(@PathVa
@GetMapping("/samplePhoto")
@Operation(summary = "샘플 사진 업로드 여부 조회", description = "자신이 샘플 사진을 업로드했는지 여부를 확인하는 API입니다.")
public ResultResponse<HasSamplePhoto> hasSamplePhoto(@LoginMember Member member) {
return ResultResponse.of(CHECK_MEMBER_REGISTRATION, memberService.hasSamplePhoto(member));
return ResultResponse.of(CHECK_HAS_SAMPLE_PHOTO, memberService.hasSamplePhoto(member));
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,15 +44,19 @@ 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())
.image(member.getImage())
.build();
}

public MemberId toMemberId(Long memberId) {
return new MemberId(memberId);
}

public CheckMemberRegistration toCheckMemberRegistration(boolean isRegistered) {
return new CheckMemberRegistration(isRegistered);
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit afcbd12

Please sign in to comment.