배지 목록 조회 및 대표 배지 설정 기능 구현#164
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note
|
| /* 413xx Badge */ | ||
| NOT_FOUND_BADGE(HttpStatus.NOT_FOUND, 41301, "뱃지를 찾을 수 없습니다."), | ||
| ALREADY_ACQUIRED_BADGE(HttpStatus.CONFLICT, 41302, "이미 획득한 뱃지입니다."), | ||
| NOT_OWNED_BADGE(HttpStatus.FORBIDDEN, 41303, "보유하지 않은 뱃지입니다."), |
There was a problem hiding this comment.
p3:
현재 FORBIDDEN(403)으로 되어 있는데, 403은 보통 인가(authorization) 실패를 의미하는 것 같아서요. 이 경우는 "해당 유저-배지 관계가 존재하지 않음"에 가까워서 NOT_FOUND(404)가 더 자연스럽지 않을까 싶은데, 혹시 403으로 설정하신 이유가 있을까요?
| @Transactional | ||
| public void setRepresentativeBadge(final User user, final Long badgeId) { | ||
| Badge badge = badgeRepository.findById(badgeId) | ||
| .orElseThrow(() -> CommonException.from(ExceptionCode.NOT_FOUND_BADGE)); | ||
|
|
||
| UserBadge newRepresentativeBadge = userBadgeRepository.findByUserAndBadge(user, badge) | ||
| .orElseThrow(() -> CommonException.from(ExceptionCode.NOT_OWNED_BADGE)); | ||
|
|
||
| userBadgeRepository.findByUserAndIsRepresentativeTrue(user) | ||
| .ifPresent(oldBadge -> oldBadge.updateRepresentativeStatus(false)); | ||
|
|
||
| newRepresentativeBadge.updateRepresentativeStatus(true); | ||
| } |
There was a problem hiding this comment.
p5: 현재는 "대표 배지를 다른 배지로 변경"만 가능한 것 같은데, 대표 배지를 해제(null로 설정)하는 케이스는 요구사항에 없는 걸까요? 만약 추후에 필요할 수 있다면 badgeId를 nullable로 받아서 해제도 지원하는 것도 고려해볼 수 있을 것 같아서 여쭤봅니다.
✨ 작업 내용
1️⃣ 배지 목록 조회 기능 구현
사용자가 보유한 배지 목록과전체 배지 개수, 그리고현재 설정된 대표 배지 정보를 함께 조회하는 기능 추가2️⃣ 대표 배지 설정 기능 구현