Skip to content

Commit

Permalink
fix: 낫투두 7개 제한 종료된 낫투두 제외 카운트 쿼리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sunga08 committed Sep 17, 2023
1 parent 38305cb commit 053a175
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public interface UserNotToDoJpaRepository extends JpaRepository<UserNotToDo, Lon
@Query("select count(n) from UserNotToDo n where n.user.id = :userId and n.useYn = true")
int countUserNotToDoByUserIdAndUseYn(Long userId);

@Query("select count(n) from UserNotToDo n where n.user.id = :userId and n.useYn = true and n.endDate >= current_date")
int countUserNotToDoLimitCheck(Long userId);

@Query("select n from UserNotToDo n " +
"join fetch n.moderationRecords " +
"where n.progressState = :progressState"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public NotToDoCreateResponseDto createNotToDo(String accessToken, NotToDoCreateR
() -> new CustomException(ErrorCode.USER_NOT_FOUND)
);

int cnt = userNotToDoRepository.countUserNotToDoByUserIdAndUseYn(user.getId());
int cnt = userNotToDoRepository.countUserNotToDoLimitCheck(user.getId());
if(cnt >= 7){
throw new CustomException(ErrorCode.REGISTER_NOT_TO_DO_LIMIT);
}
Expand Down

0 comments on commit 053a175

Please sign in to comment.