From 0ea9bfdbd8df9b7f6ca8371e8749e274bff01287 Mon Sep 17 00:00:00 2001 From: jihwankim129 Date: Mon, 27 May 2024 17:04:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MemberEmailDTO.java: email 을 받기 위한 DTO 추가 - MemberRepository.java: findByEmail로 DB 조회하는 코드 추가 - MemberService.java: 이메일로 멤버를 조회하는 서비스단 코드 추가 - UserController.java: 이메일로 멤버를 조회하는 컨트롤러단 코드 추가 --- .../domain/repository/MemberRepository.java | 1 + .../co/ssalon/domain/service/MemberService.java | 7 +++++++ .../ssalon/web/controller/UserController.java | 13 +++++++++++++ .../kr/co/ssalon/web/dto/MemberEmailDTO.java | 17 +++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 back-end/src/main/java/kr/co/ssalon/web/dto/MemberEmailDTO.java diff --git a/back-end/src/main/java/kr/co/ssalon/domain/repository/MemberRepository.java b/back-end/src/main/java/kr/co/ssalon/domain/repository/MemberRepository.java index eb5a1c70..e00ebb81 100644 --- a/back-end/src/main/java/kr/co/ssalon/domain/repository/MemberRepository.java +++ b/back-end/src/main/java/kr/co/ssalon/domain/repository/MemberRepository.java @@ -15,4 +15,5 @@ public interface MemberRepository extends JpaRepository, MemberRepo List findByBlackReasonIsNotNull(); + Optional findByEmail(String email); } diff --git a/back-end/src/main/java/kr/co/ssalon/domain/service/MemberService.java b/back-end/src/main/java/kr/co/ssalon/domain/service/MemberService.java index fa3273f8..9968810f 100644 --- a/back-end/src/main/java/kr/co/ssalon/domain/service/MemberService.java +++ b/back-end/src/main/java/kr/co/ssalon/domain/service/MemberService.java @@ -57,6 +57,13 @@ public Member findMember(Long id) throws BadRequestException { return member; } + public Member findMemberByEmail(String email) throws BadRequestException { + Optional findMember = memberRepository.findByEmail(email); + Member member = ValidationService.validationMember(findMember); + return member; + } + + public List findAllMember() { return memberRepository.findAll(); } diff --git a/back-end/src/main/java/kr/co/ssalon/web/controller/UserController.java b/back-end/src/main/java/kr/co/ssalon/web/controller/UserController.java index 67fc748b..29312b7e 100644 --- a/back-end/src/main/java/kr/co/ssalon/web/controller/UserController.java +++ b/back-end/src/main/java/kr/co/ssalon/web/controller/UserController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import kr.co.ssalon.domain.dto.MemberDomainDTO; import kr.co.ssalon.domain.entity.Member; +import kr.co.ssalon.domain.repository.MemberRepository; import kr.co.ssalon.domain.service.MemberService; import kr.co.ssalon.oauth2.CustomOAuth2Member; import kr.co.ssalon.web.dto.*; @@ -28,6 +29,7 @@ public class UserController { private final MemberService memberService; + private final MemberRepository memberRepository; @Operation(summary = "회원가입") @ApiResponses(value = { @@ -76,6 +78,17 @@ public MemberDomainDTO getUserInfo(@AuthenticationPrincipal CustomOAuth2Member c return new MemberDomainDTO(member); } + @Operation(summary = "이메일로 회원 정보 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "이메일로 회원 정보 조회 성공"), + }) + @GetMapping("/api/users/email/profile") + public MemberDomainDTO getUserInfoByEmail(@AuthenticationPrincipal CustomOAuth2Member customOAuth2Member, @RequestBody MemberEmailDTO memberEmailDTO) throws BadRequestException { + Member member = memberService.findMemberByEmail(memberEmailDTO.getEmail()); + return new MemberDomainDTO(member); + } + + @Operation(summary = "회원 정보 수정") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 정보 수정 성공"), diff --git a/back-end/src/main/java/kr/co/ssalon/web/dto/MemberEmailDTO.java b/back-end/src/main/java/kr/co/ssalon/web/dto/MemberEmailDTO.java new file mode 100644 index 00000000..0704fe45 --- /dev/null +++ b/back-end/src/main/java/kr/co/ssalon/web/dto/MemberEmailDTO.java @@ -0,0 +1,17 @@ +package kr.co.ssalon.web.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MemberEmailDTO { + + private String email; + +} +