Skip to content

Commit

Permalink
fix: 전체 대출반납 기록 조회 시 정렬 순서가 최신 순이 아님 (#438)
Browse files Browse the repository at this point in the history
* bug(history): 정렬 조건을 수정 시간 내림차순으로 변경

기록 조회 시, 정렬 조건을 수정 시간 내림차순으로 변경

* bug(history): 반납 시, updatedAt 값 갱신하도록 수정

반납 시, updatedAt의 값도 갱신하도록 수정
  • Loading branch information
nyj001012 authored Jun 21, 2023
1 parent 22b3a7f commit a3dd80f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions backend/src/entity/entities/VHistories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DataSource, ViewColumn, ViewEntity } from 'typeorm';
.addSelect('bi.image', 'image')
.addSelect('DATE_FORMAT(l.createdAt, "%Y-%m-%d")', 'createdAt')
.addSelect('DATE_FORMAT(l.returnedAt, "%Y-%m-%d")', 'returnedAt')
.addSelect('DATE_FORMAT(l.updatedAt, "%Y-%m-%d")', 'updatedAt')
.addSelect("DATE_FORMAT(DATE_ADD(l.createdAt, interval 14 day), '%Y-%m-%d')", 'dueDate')
.addSelect('(SELECT nickname FROM user WHERE user.id = lendingLibrarianId)', 'lendingLibrarianNickName')
.addSelect('(SELECT nickname FROM user WHERE user.id = returningLibrarianId)', 'returningLibrarianNickname')
Expand Down Expand Up @@ -59,6 +60,9 @@ export default class VHistories {
@ViewColumn()
returnedAt: Date;

@ViewColumn()
updatedAt: Date;

@ViewColumn()
dueDate: Date;

Expand Down
3 changes: 1 addition & 2 deletions backend/src/histories/histories.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class HistoriesRepository extends Repository<VHistories> {
take: limit,
skip: page * limit,
order: {
createdAt: 'DESC',
login: 'DESC',
updatedAt: 'DESC',
},
});
return [histories, count];
Expand Down
1 change: 1 addition & 0 deletions backend/src/lendings/lendings.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class LendingRepository extends Repository<Lending> {
returningLibrarianId,
returningCondition,
returnedAt: (new Date()),
updatedAt: (new Date()),
};
await this.update(lendingId, updateObject);
}
Expand Down

0 comments on commit a3dd80f

Please sign in to comment.