Skip to content

Commit

Permalink
feat: Response 객체에서 Pagination의 공통 로직을 처리하는 PaginationResponse 구현 #92
Browse files Browse the repository at this point in the history
  • Loading branch information
koomchang committed Nov 13, 2024
1 parent d6bb1fd commit 6af91b3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
13 changes: 13 additions & 0 deletions backend/src/common/dto/PaginationResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export abstract class PaginationResponse {
readonly totalPages: number;
readonly currentPage: number;

protected constructor(
totalCount: number,
pageSize: number,
currentPage: number,
) {
this.totalPages = Math.ceil(totalCount / pageSize);
this.currentPage = currentPage;
}
}
9 changes: 0 additions & 9 deletions backend/src/course/dto/OwnCourseListResponse.ts

This file was deleted.

13 changes: 13 additions & 0 deletions backend/src/course/dto/PagedCourseResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CourseListResponse } from './CourseListResponse';
import { PaginationResponse } from '../../common/dto/PaginationResponse';

export class OwnCourseListResponse extends PaginationResponse {
constructor(
readonly courses: CourseListResponse[],
totalCount: number,
currentPage: number,
pageSize: number,
) {
super(totalCount, pageSize, currentPage);
}
}

0 comments on commit 6af91b3

Please sign in to comment.