diff --git a/backend/src/course/CourseController.ts b/backend/src/course/CourseController.ts index 703b5732..995d7e39 100644 --- a/backend/src/course/CourseController.ts +++ b/backend/src/course/CourseController.ts @@ -37,8 +37,12 @@ export class CourseController { @Get('/my') @UseGuards(JwtAuthGuard) - async getMyCourses(@AuthUser() user: AuthUser) { - return await this.courseService.getMyCourses(user.userId); + async getMyCourses( + @AuthUser() user: AuthUser, + @Query('page', new ParseOptionalNumberPipe(1)) page?: number, + @Query('limit', new ParseOptionalNumberPipe(15)) limit?: number, + ) { + return await this.courseService.getMyCourses(user.userId, page, limit); } @Get('/:id') diff --git a/backend/src/course/CourseService.ts b/backend/src/course/CourseService.ts index 1fcdb3d8..92c36703 100644 --- a/backend/src/course/CourseService.ts +++ b/backend/src/course/CourseService.ts @@ -45,7 +45,7 @@ export class CourseService { return new PagedCourseResponse(courses, totalCount, page, pageSize); } - async getMyCourses(userId: number, page: number = 1, pageSize: number = 10) { + async getMyCourses(userId: number, page: number = 1, pageSize: number = 15) { const [ownCourses, totalCount] = await Promise.all([ this.courseRepository.findByUserId(userId, page, pageSize), this.courseRepository.countByUserId(userId), diff --git a/backend/src/map/MapController.ts b/backend/src/map/MapController.ts index 0fb027e4..0ca468a1 100644 --- a/backend/src/map/MapController.ts +++ b/backend/src/map/MapController.ts @@ -40,8 +40,12 @@ export class MapController { @UseGuards(JwtAuthGuard) @Get('/my') - async getMyMaps(@AuthUser() user: AuthUser) { - return await this.mapService.getMyMaps(user.userId); + async getMyMaps( + @AuthUser() user: AuthUser, + @Query('page', new ParseOptionalNumberPipe(1)) page?: number, + @Query('limit', new ParseOptionalNumberPipe(15)) limit?: number, + ) { + return await this.mapService.getMyMaps(user.userId, page, limit); } @Get('/:id') diff --git a/backend/src/map/MapRepository.ts b/backend/src/map/MapRepository.ts index eec1bd5b..0b8c0266 100644 --- a/backend/src/map/MapRepository.ts +++ b/backend/src/map/MapRepository.ts @@ -39,7 +39,7 @@ export class MapRepository extends SoftDeleteRepository { countByUserId(userId: number) { return this.count({ - where: { id: userId }, + where: { user: { id: userId } }, }); } diff --git a/backend/src/map/MapService.ts b/backend/src/map/MapService.ts index 76b7f4af..b400a907 100644 --- a/backend/src/map/MapService.ts +++ b/backend/src/map/MapService.ts @@ -52,15 +52,13 @@ export class MapService { ); } - async getMyMaps(userId: number, page: number = 1, pageSize: number = 10) { + async getMyMaps(userId: number, page: number = 1, pageSize: number = 15) { const totalCount = await this.mapRepository.countByUserId(userId); - const ownMaps = await this.mapRepository.findByUserId( userId, page, pageSize, ); - return new PagedMapResponse( await Promise.all(ownMaps.map(MapListResponse.from)), totalCount,