Skip to content

Commit

Permalink
Merge pull request #158 from 05AM/fix/incomplete-customs-order [REFAC…
Browse files Browse the repository at this point in the history
…TOR] 커스텀 도안, 커스텀 임시 도안 정렬 순서 변경: 최근 등록순

[REFACTOR] 커스텀 도안, 커스텀 임시 도안 정렬 순서 변경: 최근 등록순
  • Loading branch information
05AM authored Feb 21, 2024
2 parents 42e3ed9 + 7a48035 commit 74f3d8d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public List<Custom> getCustomByUserIdAfterDate(int userId, String date) {

@Override
public List<Custom> getAllByUserIdAndIsCompleted(Integer userId) {
return customRepository.findAllByUserIdAndIsCompleted(userId);
return customRepository.findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(userId);
}

@Override
public List<Custom> getAllByUserIdAndIsCompletedFalse(Integer userId) {
return customRepository.findAllByUserIdAndIsCompletedFalse(userId);
return customRepository.findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public interface CustomRepositoryCustom {

List<Custom> findAllByUserIdAndIsCompleted(Integer userId);
List<Custom> findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(Integer userId);

List<Custom> findAllByUserIdAndIsCompletedFalse(Integer userId);
List<Custom> findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(Integer userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ public class CustomRepositoryImpl implements CustomRepositoryCustom {
private final JPAQueryFactory queryFactory;

@Override
public List<Custom> findAllByUserIdAndIsCompleted(Integer userId) {
public List<Custom> findAllByUserIdAndIsCompletedOrderByLastUpdatedAt(Integer userId) {
return queryFactory
.select(custom)
.from(custom)
.where(custom.user.id.eq(userId), custom.isCompleted.eq(true))
.orderBy(custom.lastUpdatedAt.desc())
.fetch();
}

@Override
public List<Custom> findAllByUserIdAndIsCompletedFalse(Integer userId) {
public List<Custom> findAllByUserIdAndIsCompletedFalseOrderByLastUpdatedAt(Integer userId) {
return queryFactory
.select(custom)
.from(custom)
.where(custom.user.id.eq(userId), custom.isCompleted.eq(false))
.orderBy(custom.lastUpdatedAt.desc())
.fetch();
}
}

0 comments on commit 74f3d8d

Please sign in to comment.