-
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
Issue/#79 #88
Issue/#79 #88
Conversation
@Transactional | ||
public void updateChallengeGroup(ChallengeGroupCommand.Update command) { | ||
ChallengeGroup challengeGroup = challengeGroupReader.getById(command.getId()); | ||
|
||
List<Challenge> challenges = new ArrayList<>(); | ||
Set<Challenge> existedChallenges = new HashSet<>(); | ||
|
||
for (ChallengeGroupCommand.UpdateChallenge challenge : command.getUpdateChallenges()) { | ||
processChallenge(challenge, challengeGroup, challenges, existedChallenges); | ||
} | ||
|
||
challengeGroup.update(command); | ||
removeChallenges(challengeGroup, existedChallenges); | ||
challengeGroup.addChallenges(challenges); | ||
} | ||
|
||
private void processChallenge(ChallengeGroupCommand.UpdateChallenge updateChallengeCommand, | ||
ChallengeGroup challengeGroup, | ||
List<Challenge> newChallenges, | ||
Set<Challenge> existingChallenges) | ||
{ | ||
if (updateChallengeCommand.getId().equals(-1L)) { | ||
newChallenges.add(Challenge.create(updateChallengeCommand.convertCreate(), challengeGroup)); | ||
} else { | ||
Challenge updateChallenge = challengeReader.getById(updateChallengeCommand.getId()); | ||
existingChallenges.add(updateChallenge); | ||
updateChallenge.update(updateChallengeCommand); | ||
} | ||
} | ||
|
||
private void removeChallenges(ChallengeGroup challengeGroup, Set<Challenge> existingChallenges) { | ||
List<Challenge> removeChallenges = challengeGroup.getChallenges().stream() | ||
.filter(challenge -> !existingChallenges.contains(challenge)) | ||
.toList(); | ||
challengeGroup.removeChallenges(removeChallenges); | ||
} |
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.
이부분 서비스 레이어에 들어갈만한 내용이 아니라 생각이 드는데, challengeGroup에 oneToMany에서 처리하는게 어떤ㄱ요?
변경감지 쓰는게 좋을거같슴다..!
@@ -16,4 +18,6 @@ public interface UserReader { | |||
Optional<User> findByAuthToken(String authToken); | |||
|
|||
Page<User> getUserPagingByRanking(Pageable pageable); | |||
|
|||
List<User> getManagerAndAdmin(); |
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.
infra에 로직을 두는거보다 그냥 인자로 받는건 별로일까요?
role을 결정하는거는 서비스레이어가 하는게 좋다라고 저는 생각이 드네요
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.
다운님이랑 정반대의 리뷰네용
저도 이부분 좀 더 생각해보겠습니다
public void confirm(Long verificationId, ChallengeVerificationStatus status) { | ||
ChallengeVerification verification = challengeVerificationReader.getById(verificationId); // verification 가져올때 user, challenge, userChallenge도 join해서 가져오는게 좋을듯 | ||
if (status == ChallengeVerificationStatus.REJECTED && verification.getStatus() != ChallengeVerificationStatus.REJECTED) { | ||
rejectVerification(verification); | ||
} else if (status == ChallengeVerificationStatus.APPROVED && verification.getStatus() != ChallengeVerificationStatus.APPROVED) { | ||
approveVerification(verification); | ||
} | ||
} |
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.
status 인자로 받지말고 메소드2개로 분할하는 방법은 별로일까요?
랭킹 경험치 롤백도 추가해주세용
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.
엔드포인트를 나누자는 말씀인가요 ??
경험치 롤백은 구현되어있습니다
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.
엔드포인트의 문제보다, 현재 Service에서 함수가 인자로 status를 받아서, if(status== REJECT)이면 reject행위, else status==xx이면 xx행위인데
confirm
이라는 메소드명보다 rejectVerification
, approveVerification
으로 메소드를 분할하자는 의미였습니다 🧐
challenge_group_user_exp롤백이 빠져있어요
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.
컨트롤러에서 함수를 나눠서 호출하게 되는건가요 ...?
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.
api를 2개로 하거나 컨트롤러에서 if else해도 되는데 api2개가 좋겠네요!
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.
혹시 이유가 뭘까요??
앤드포인트를 나누는 거랑 status 인자를 받는 것의 장단점을 잘 모르겠네용
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.
클린코드에서 함수는 하나의 일만 해라인데(status에 대해 내부구현의 노출, if else의 조건분기)
억지클린코드라면 안해도 좋습니다
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.
@Transactional
public void confirm(Long verificationId, ChallengeVerificationStatus status) {
ChallengeVerification verification = challengeVerificationReader.getById(verificationId); // verification 가져올때 user, challenge, userChallenge도 join해서 가져오는게 좋을듯
if (status == ChallengeVerificationStatus.REJECTED) {
rejectVerification(verification);
}
if (status == ChallengeVerificationStatus.APPROVED) {
approveVerification(verification);
}
}
저라면 이런식으로 가독성만 높일것 같아여! 조건문 뒤에 두번째 조건은 필요없을것 같고 처음에 읽을때 가독성이 오히려 떨어지는거 같더라구여!
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.
두번째 조건은 중복 승인을 피하려고 추가한거에요 approve->approve로 변경을 시도하면 경험치가 두번 더해지니까 이거 피하려고 둔겁니다. !
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.
길어서 가독성이 떨어지는 거면 verification.getStatue != status 이렇게 바꿀까요 ?
.../java/org/haedal/zzansuni/userchallenge/domain/application/ChallengeVerificationService.java
Outdated
Show resolved
Hide resolved
...rg/haedal/zzansuni/userchallenge/infrastructure/adapter/ChallengeVerificationReaderImpl.java
Outdated
Show resolved
Hide resolved
이거
이렇게 필드추가하는게 더 좋지 않을까요?> |
아 create는 따로 받자는거네요 확인했습니다! |
🔎 작업 내용
이미지 첨부
To Reviewers 📢
변경감지 코드가 많은데 헥사고날 아키텍쳐에서 이렇게 코드를 쓰는게 괜찮은지 여전히 의문...입니다
main브랜치가 아니라 admin브랜치로 올렸습니당
체크 리스트
➕ 관련 이슈