diff --git a/src/contents/contents.controller.ts b/src/contents/contents.controller.ts index b4d12df..2f8f271 100644 --- a/src/contents/contents.controller.ts +++ b/src/contents/contents.controller.ts @@ -58,6 +58,7 @@ import { LoadFavoritesOutput, LoadPersonalContentsOutput, } from './dtos/load-personal-contents.dto'; +import { LoadReminderCountOutput } from './dtos/load-personal-remider-count.dto'; @Controller('contents') @ApiTags('Contents') @@ -260,6 +261,23 @@ export class ContentsController { return await this.contentsService.loadFavorites(user); } + @ApiOperation({ + summary: '자신의 리마인더 개수 조회', + description: '자신의 리마인더 개수를 조회하는 메서드', + }) + @ApiOkResponse({ + description: '설정되어있는 리마인더 개수를 반환한다.', + type: LoadReminderCountOutput, + }) + @ApiBearerAuth('Authorization') + @UseGuards(JwtAuthGuard) + @Get('load-reminder-count') + async loadReminderCount( + @AuthUser() user: User, + ): Promise { + return await this.contentsService.loadReminderCount(user); + } + @ApiOperation({ summary: '콘텐츠 문서 요약', description: '콘텐츠의 문서를 요약하는 메서드', diff --git a/src/contents/contents.service.ts b/src/contents/contents.service.ts index 3b5a980..8933311 100644 --- a/src/contents/contents.service.ts +++ b/src/contents/contents.service.ts @@ -43,6 +43,7 @@ import { User } from '../users/entities/user.entity'; import { Category } from './entities/category.entity'; import { Content } from './entities/content.entity'; import { CategoryRepository } from './repository/category.repository'; +import { LoadReminderCountOutput } from './dtos/load-personal-remider-count.dto'; @Injectable() export class ContentsService { @@ -449,6 +450,22 @@ export class ContentsService { } } + async loadReminderCount(user: User): Promise { + try { + const reminderCount = await this.contents + .createQueryBuilder('content') + .where('content.userId = :userId', { userId: user.id }) + .andWhere('content.reminder IS NULL') + .getCount(); + + return { + count: reminderCount, + }; + } catch (e) { + throw e; + } + } + async summarizeContent( user: User, contentId: number, diff --git a/src/contents/dtos/load-personal-remider-count.dto.ts b/src/contents/dtos/load-personal-remider-count.dto.ts new file mode 100644 index 0000000..d6c518c --- /dev/null +++ b/src/contents/dtos/load-personal-remider-count.dto.ts @@ -0,0 +1,9 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { CoreOutput } from '../../common/dtos/output.dto'; + +export class LoadReminderCountOutput extends CoreOutput { + @ApiProperty({ + description: '설정된 리마인더 개수', + }) + count!: number; +}