Skip to content

Commit

Permalink
Feat: Member 단일 조회 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gytjd committed Nov 25, 2024
1 parent fb63ba7 commit 2de7fd8
Showing 1 changed file with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,42 @@ public ListResult<MemberResponseDto> getAllMembers() {
return responseService.getListResult(memberResponseDtoList);
}

// 특정 회원 조회
@GetMapping("/{email}/{companyName}")
public SingleResult<MemberCredentialDto> getMemberKey(
public SingleResult<MemberResponseDto> getMemberAndKeyByEmailAndCompany(
@PathVariable String email,
@PathVariable String companyName) {

Member findMember = memberService.getMemberByEmail(email);
if (findMember == null) {
return (SingleResult<MemberCredentialDto>) responseService.getFailResult("Member not found");
// 서비스에서 멤버 조회
Member member = memberService.getMemberByEmail(email);

if (member == null) {
throw new IllegalArgumentException("Member not found");
}

Optional<AiwaKey> matchingKey = findMember.getAiwaKeys().stream()
// AiwaKey 조회
Optional<AiwaKey> optionalKey = member.getAiwaKeys().stream()
.filter(key -> companyName.equalsIgnoreCase(key.getCompanyName()))
.findFirst();

if (matchingKey.isPresent()) {
AiwaKey aiwaKey = matchingKey.get();
MemberCredentialDto memberCredentialDto = new MemberCredentialDto(
findMember.getEmail(),
aiwaKey.getAccessKey(),
aiwaKey.getSecretKey()
);
return responseService.getSingleResult(memberCredentialDto);
if (optionalKey.isPresent()) {
AiwaKey aiwaKey = optionalKey.get();

// MemberResponseDto 생성
MemberResponseDto memberResponseDto = MemberResponseDto.toDto(member);

// AiwaKeyResponseDto 추가 (해당 회사 키만 추가)
List<AiwaKeyResponseDto> filteredKeys = List.of(AiwaKeyResponseDto.toDto(aiwaKey));
memberResponseDto.setAiwaKeys(filteredKeys);

return responseService.getSingleResult(memberResponseDto);
} else {
return (SingleResult<MemberCredentialDto>) responseService.getFailResult("No key found for company: " + companyName);
throw new IllegalArgumentException("Key for company '" + companyName + "' not found");
}
}




// AWS 및 GCP 키 추가/업데이트
@PostMapping("/add-aws-gcp-key")
public SingleResult<String> addAwsAndGcpKey(
Expand Down

0 comments on commit 2de7fd8

Please sign in to comment.