Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/149] 내가 받은 매너 평가 조회 API 구현 #154

Merged
merged 4 commits into from
Aug 11, 2024
Merged

Conversation

hzee97
Copy link
Contributor

@hzee97 hzee97 commented Aug 11, 2024

🚀 개요

매너점수 산정 및 매너레벨 결정, 업데이트
내가 받은 매너 평가 조회 API 구현

🔍 변경사항

  • 매너점수 산정 및 매너레벨 결정, 업데이트
  • 내가 받은 매너 평가 조회 API 구현
  • 코드 리팩토링

⏳ 작업 내용

  • 매너점수 산정 및 매너레벨 결정, 업데이트.
  • 내가 받은 매너 평가 조회 API 구현.
  • Swagger 명세.
  • 코드 리팩토링

📝 논의사항

@hzee97 hzee97 requested review from rimi3226 and Eunjin3395 August 11, 2024 09:31
@hzee97 hzee97 self-assigned this Aug 11, 2024
@hzee97 hzee97 linked an issue Aug 11, 2024 that may be closed by this pull request
3 tasks
Copy link
Member

@Eunjin3395 Eunjin3395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

Comment on lines 323 to 325
totalCount = mannerRatings.get(0).getMannerRatingKeywordList().stream()
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId())
.collect(Collectors.toList()).size();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에서 어차피 mannerRatingKeyword 개수만 필요한 거라면, 굳이 map으로 id 변환시키지 않고 바로 list의 size만 뽑아도 될 것 같아요!

Suggested change
totalCount = mannerRatings.get(0).getMannerRatingKeywordList().stream()
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId())
.collect(Collectors.toList()).size();
totalCount = mannerRatings.get(0).getMannerRatingKeywordList().size();

public int updateMannerScore(Member targetMember){

// 매너평가 ID 조회
List<MannerRating> mannerRatings = mannerRatingRepository.findByToMemberId(targetMember.getId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

member 엔티티가 mannerRatingList를 양방향 매핑으로 가지고 있어서, repository로 조회 안하고 그냥 member.getMannerRatingList로 매너평가 리스트를 뽑아 올 수 있을 것 같아요!

Comment on lines 332 to 336
List<Long> positiveMannerKeywordIds = mannerRatings.stream()
.filter(MannerRating::getIsPositive)
.flatMap(mannerRating -> mannerRating.getMannerRatingKeywordList().stream())
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId())
.collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 mannerKeyword의 id가 특별히 필요하지 않다면,

Suggested change
List<Long> positiveMannerKeywordIds = mannerRatings.stream()
.filter(MannerRating::getIsPositive)
.flatMap(mannerRating -> mannerRating.getMannerRatingKeywordList().stream())
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId())
.collect(Collectors.toList());
int positiveCount = mannerRatings.stream()
.filter(MannerRating::getIsPositive)
.flatMap(mannerRating -> mannerRating.getMannerRatingKeywordList().stream())
.collect(Collectors.toList())
.size();

이렇게 수정해도 될 것 같습니다!

}

// 매너점수를 산정하고 업데이트.
public int updateMannerScore(Member targetMember){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 MannerService 내에서만 사용되는 메소드인 것 같은데, 그럼 private으로 선언하는게 좋을 것 같습니다!

}

// 매너레벨 결정
public int mannerLevel(int mannerCount){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 private으로 하는게 좋을 것 같아요!

Member member = memberRepository.findById(memberId).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND));

// 매너평가 ID 조회
List<MannerRating> mannerRatings = mannerRatingRepository.findByToMemberId(member.getId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 member.getMannerRatingList()로 가능합니다!

}

Integer mannerLevel = member.getMannerLevel();
return new MannerResponse.myMannerResponseDTO(mannerLevel, mannerKeywordDTOs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 builder로 DTO 생성하는 건 어떠신가요?!

@hzee97 hzee97 merged commit c96a1df into develop Aug 11, 2024
@hzee97 hzee97 deleted the feat/149 branch August 11, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ [Feat] 내가 받은 매너 평가 조회 API 구현
2 participants