-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
totalCount = mannerRatings.get(0).getMannerRatingKeywordList().stream() | ||
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId()) | ||
.collect(Collectors.toList()).size(); |
There was a problem hiding this comment.
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만 뽑아도 될 것 같아요!
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()); |
There was a problem hiding this comment.
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로 매너평가 리스트를 뽑아 올 수 있을 것 같아요!
List<Long> positiveMannerKeywordIds = mannerRatings.stream() | ||
.filter(MannerRating::getIsPositive) | ||
.flatMap(mannerRating -> mannerRating.getMannerRatingKeywordList().stream()) | ||
.map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId()) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 mannerKeyword의 id가 특별히 필요하지 않다면,
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){ |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 builder로 DTO 생성하는 건 어떠신가요?!
🚀 개요
매너점수 산정 및 매너레벨 결정, 업데이트
내가 받은 매너 평가 조회 API 구현
🔍 변경사항
⏳ 작업 내용
📝 논의사항