-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Create Week9 Mission #13
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
Conversation
ggamnunq
left a comment
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.
good
| boolean existsById(Long missionId); | ||
|
|
||
| Page<Mission> getStoreMissions(Long storeId, Integer page); | ||
| Page<UserMission> getMyOngoingMissions(Long userId, Integer page); |
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를 메서드의 파라미터로 포함해주면 이후 재사용 가능한 메서드가 됩니다.
| return ReviewResDTO.ReviewPreViewListDTO.builder() | ||
| .reviewList(reviewList) | ||
| .listSize(reviewList.size()) | ||
| .currentPage(reviewPage.getNumber() + 1) // 0-based를 1-based로 변환 |
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.
1-based로 변경하는건 converter로 변경할 때가 아니고 별도로 구조나 로직을 구성해서 만드는게 깔끔합니다.
| .totalPages(reviewPage.getTotalPages()) | ||
| .totalElements(reviewPage.getTotalElements()) | ||
| .isFirst(reviewPage.isFirst()) | ||
| .isLast(reviewPage.isLast()) |
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.
페이징 정보는 페이징 전용 클래스를 만들어 그걸 공통 응답값으로 사용하면 좋습니다.
| @Query("SELECT r FROM Review r " + | ||
| "WHERE r.user.userId = :userId " + | ||
| "ORDER BY r.reviewId DESC") | ||
| Page<Review> findByUserUserId( |
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.
Pageable에 정렬 정보도 넣어줄 수 있어요.
query문으로 정렬해도 되지만, 그러려면 메서드명에 desc 정렬을 헸다는걸 표현해야 할듯합니다.
관련 이슈
closed #12
작업한 내용
1. 커스텀 어노테이션 구현 및 적용
@CheckPage어노테이션: 페이지 번호가 1 이상인지 검증CheckPageValidator: 0 이하의 값에 대해 검증 실패 처리GlobalExceptionHandler의ConstraintViolationException핸들러로 에러 처리page파라미터에 적용2. 구현된 API 목록 (4개)
2.1 내가 작성한 리뷰 목록 조회
GET /api/v1/reviews/myuserId(required): 사용자 IDpage(default: 1): 페이지 번호 (1 이상)reviewList: 리뷰 목록listSize: 현재 페이지 항목 수currentPage: 현재 페이지 번호totalPages: 전체 페이지 수totalElements: 전체 항목 수isFirst: 첫 페이지 여부isLast: 마지막 페이지 여부2.2 특정 가게의 미션 목록 조회
GET /api/v1/missions/stores/{storeId}storeId(path): 가게 IDpage(default: 1): 페이지 번호 (1 이상)2.3 내가 진행중인 미션 목록 조회
GET /api/v1/missions/my-ongoinguserId(required): 사용자 IDpage(default: 1): 페이지 번호 (1 이상)2.4 진행중인 미션 완료 처리
PATCH /api/v1/missions/complete{ "challengeMissionId": Long }IN_PROGRESS→COMPLETED로 변경completedAt필드에 현재 시간 설정challengeMissionId: 도전 미션 IDstatus: 미션 상태 (COMPLETED)completedAt: 완료 시간updatedAt: 수정 시간3. 추가 구현 사항
UserMission.updateStatus(): 미션 상태 변경 메서드 추가MissionErrorCode.MISSION_ALREADY_COMPLETED: 이미 완료된 미션 에러 코드 추가MissionSuccessCode.MISSION_COMPLETED: 미션 완료 성공 코드 추가PR Point 및 참고사항
요구사항
@CheckPage커스텀 어노테이션 구현 및 적용RestControllerAdvice와 연계하여 에러 처리참고사항