diff --git a/src/main/java/com/Nunbody/domain/member/controller/MemberController.java b/src/main/java/com/Nunbody/domain/member/controller/MemberController.java index e6a980d..7a53c70 100644 --- a/src/main/java/com/Nunbody/domain/member/controller/MemberController.java +++ b/src/main/java/com/Nunbody/domain/member/controller/MemberController.java @@ -5,14 +5,15 @@ import com.Nunbody.domain.member.dto.SignInRequestDto; import com.Nunbody.domain.member.dto.SignInResponseDto; import com.Nunbody.domain.member.dto.ValidateRequestDto; +import com.Nunbody.domain.member.dto.res.MemberMailIdResDto; import com.Nunbody.domain.member.service.MemberService; import com.Nunbody.global.common.SuccessResponse; +import com.Nunbody.global.config.auth.MemberId; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @RestController @RequestMapping("/api/member") @@ -21,6 +22,11 @@ public class MemberController { private final MemberService memberService; + @GetMapping("/mailId") + public ResponseEntity> getMemberMailId(@MemberId Long memberId) { + MemberMailIdResDto memberMailId = memberService.getMemberMailId(memberId); + return SuccessResponse.ok(memberMailId); + } @PostMapping("/signup") public ResponseEntity> create(@RequestBody MemberRegisterRequestDto dto) { diff --git a/src/main/java/com/Nunbody/domain/member/dto/res/MemberMailIdResDto.java b/src/main/java/com/Nunbody/domain/member/dto/res/MemberMailIdResDto.java new file mode 100644 index 0000000..6c4c14c --- /dev/null +++ b/src/main/java/com/Nunbody/domain/member/dto/res/MemberMailIdResDto.java @@ -0,0 +1,10 @@ +package com.Nunbody.domain.member.dto.res; + +public record MemberMailIdResDto( + String GOOGLE, + String NAVER +) { + public static MemberMailIdResDto of(String GOOGLE, String NAVER){ + return new MemberMailIdResDto(GOOGLE, NAVER); + } +} diff --git a/src/main/java/com/Nunbody/domain/member/service/MemberService.java b/src/main/java/com/Nunbody/domain/member/service/MemberService.java index 2a0e476..7140c08 100644 --- a/src/main/java/com/Nunbody/domain/member/service/MemberService.java +++ b/src/main/java/com/Nunbody/domain/member/service/MemberService.java @@ -4,6 +4,7 @@ import com.Nunbody.domain.member.domain.Member; import com.Nunbody.domain.member.dto.MemberRegisterRequestDto; import com.Nunbody.domain.member.dto.SignInResponseDto; +import com.Nunbody.domain.member.dto.res.MemberMailIdResDto; import com.Nunbody.domain.member.repository.KeywordRepository; import com.Nunbody.domain.member.repository.MemberRepository; import com.Nunbody.global.common.EncoderDecoder; @@ -35,8 +36,13 @@ public class MemberService { private final JwtTokenProvider jwtTokenProvider; private final PasswordEncoder passwordEncoder; private final OAuthService oAuthService; + private final MemberReader memberReader; + public MemberMailIdResDto getMemberMailId(Long memberId){ + Member member = memberReader.getMemberById(memberId); + return MemberMailIdResDto.of(member.getNaverId(), member.getGmailId()); + } public void register(MemberRegisterRequestDto resource) { Member member;