From 1bce0d9187e5fd2abfb8b1b06ae781110367d4a9 Mon Sep 17 00:00:00 2001 From: IlhamTahir Date: Mon, 18 Nov 2024 20:14:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/article/controller/article.controller.ts | 4 ++++ src/core/controller/user.controller.ts | 10 ++++++++++ src/core/dto/create-token.request.ts | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 src/article/controller/article.controller.ts diff --git a/src/article/controller/article.controller.ts b/src/article/controller/article.controller.ts new file mode 100644 index 0000000..2102be2 --- /dev/null +++ b/src/article/controller/article.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('articles') +export class ArticleController {} diff --git a/src/core/controller/user.controller.ts b/src/core/controller/user.controller.ts index 645632f..a8f8134 100644 --- a/src/core/controller/user.controller.ts +++ b/src/core/controller/user.controller.ts @@ -46,4 +46,14 @@ export class UserController { total, ); } + + @Get('current') + @ApiBearerAuth() + @ApiOkResponse({ + description: '获取当前登录用户信息', + type: UserVo, + }) + async current() { + return UserMapper.toVo(this.userService.getCurrentUser()); + } } diff --git a/src/core/dto/create-token.request.ts b/src/core/dto/create-token.request.ts index 7036de5..33c4a82 100644 --- a/src/core/dto/create-token.request.ts +++ b/src/core/dto/create-token.request.ts @@ -4,6 +4,7 @@ import { IsNotEmpty } from 'class-validator'; export class CreateTokenRequest { @ApiProperty({ required: true, + example: 'admin', }) @IsNotEmpty({ message: '用户名不能为空' }) username: string; @@ -11,6 +12,7 @@ export class CreateTokenRequest { @IsNotEmpty({ message: '密码不能为空' }) @ApiProperty({ required: true, + example: 'admin123', }) password: string; }