Skip to content
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

Feature/#261 feature/fix_sort->dev: 주유기록 정렬 수정 #263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
@Repository
public interface UserGasRecordDao extends CrudRepository<UserGasRecord, Long> {
@Query("select charge_date,gas_station_no, record_gas_type ,record_gas_amount ,refueling_price ,saving_price from user_gas_record ugr " +
"where user_no = :userNo;")
"where user_no = :userNo \n" +
"order by ugr.user_gas_record_no DESC")
List<UserGasRecord> findGasRecordListByUserId(@Param("userNo") Long userNo);
Comment on lines +20 to 22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같이 해결했으니 가볍게 리뷰합니다~

@Query("select * from user_gas_record where user_no = :userNo and month(charge_date) = month(:date) and year(charge_date) = year(:date)")
Optional<List<UserGasRecord>> findByMonthOfNow(@Param("user_no") Long userNo, @Param("date") LocalDate date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public List<UserGasRecordResDto> getUserRecords() {
User user = httpSessionService.getUserFromSession();
List<UserGasRecord> matchingUserGasRecords = userGasRecordDao.findGasRecordListByUserId(user.getUserNo());
List<UserGasRecordResDto> userGasRecordResDtos = toUserGasRecordResDtos(matchingUserGasRecords);
//날짜 최신순 정렬
Collections.sort(userGasRecordResDtos);
return userGasRecordResDtos;
}

Expand Down
15 changes: 15 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,19 @@ management:
exposure:
include: health, info, prometheus

logging:
level:
org:
springframework:
jdbc:
core:
JdbcTemplate: DEBUG
converter:
JdbcConverter: TRACE
repository:
support:
SimpleJdbcRepository: DEBUG




Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ void getUserRecords() {
assertEquals(2, result.size());
UserGasRecordResDto record1 = result.get(0);
UserGasRecordResDto record2 = result.get(1);
int compareDate = record1.getChargeDate().compareTo(record2.getChargeDate());
assertTrue(compareDate > 0); //날짜 정렬 확인
assertEquals(gasStation2.getName(), record1.getGasStationName());
assertEquals(gasStation1.getName(), record2.getGasStationName());
}
Expand Down