-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from Quickchive/feat/QA-346/add-category-v2
feat: add auto categories v2
- Loading branch information
Showing
7 changed files
with
144 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Controller, Get, Query, UseGuards } from '@nestjs/common'; | ||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { JwtAuthGuard } from '../../auth/jwt/jwt.guard'; | ||
import { CategoryService } from '../category.service'; | ||
import { AuthUser } from '../../auth/auth-user.decorator'; | ||
import { User } from '../../users/entities/user.entity'; | ||
import { RecommendedCategoryResponseDto } from './dto/recommended-category-response.dto'; | ||
|
||
@Controller('v2/categories') | ||
@ApiTags('Category v2') | ||
@ApiBearerAuth() | ||
@UseGuards(JwtAuthGuard) | ||
export class CategoryV2Controller { | ||
constructor(private readonly categoryService: CategoryService) {} | ||
|
||
@ApiOperation({ | ||
summary: '아티클 카테고리 자동 지정', | ||
description: | ||
'아티클에 적절한 카테고리를 유저의 카테고리 목록에서 찾는 메서드', | ||
}) | ||
@UseGuards(JwtAuthGuard) | ||
@Get('auto-categorize') | ||
async autoCategorize(@AuthUser() user: User, @Query('link') link: string) { | ||
const { category } = await this.categoryService.autoCategorizeWithId( | ||
user, | ||
link, | ||
); | ||
|
||
return new RecommendedCategoryResponseDto(category); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/categories/v2/dto/recommended-category-response.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class RecommendedCategoryResponseDto { | ||
@ApiProperty({ | ||
description: '카테고리 id', | ||
}) | ||
id: number; | ||
|
||
@ApiProperty({ | ||
description: '카테고리 이름', | ||
}) | ||
name: string; | ||
|
||
constructor({ id, name }: { id: number; name: string }) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { ResponseType } from 'axios'; | ||
|
||
export class CreateCompletionBodyDto { | ||
question!: string; | ||
model?: string; | ||
temperature?: number; | ||
responseType?: ResponseType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters