Skip to content

Commit

Permalink
Merge pull request #62 from lee1684/feature/get-member-by-email
Browse files Browse the repository at this point in the history
feat: 이메일로 멤버 정보 조회 메소드 추가
  • Loading branch information
jihwankim129 authored May 27, 2024
2 parents 4c2593d + 0ea9bfd commit a78180e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface MemberRepository extends JpaRepository<Member,Long>, MemberRepo

List<Member> findByBlackReasonIsNotNull();

Optional<Member> findByEmail(String email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public Member findMember(Long id) throws BadRequestException {
return member;
}

public Member findMemberByEmail(String email) throws BadRequestException {
Optional<Member> findMember = memberRepository.findByEmail(email);
Member member = ValidationService.validationMember(findMember);
return member;
}


public List<Member> findAllMember() {
return memberRepository.findAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -28,6 +29,7 @@
public class UserController {

private final MemberService memberService;
private final MemberRepository memberRepository;

@Operation(summary = "회원가입")
@ApiResponses(value = {
Expand Down Expand Up @@ -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 = "회원 정보 수정 성공"),
Expand Down
17 changes: 17 additions & 0 deletions back-end/src/main/java/kr/co/ssalon/web/dto/MemberEmailDTO.java
Original file line number Diff line number Diff line change
@@ -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;

}

0 comments on commit a78180e

Please sign in to comment.