Przeglądaj źródła

feat: 用户登录信息接口

IlhamTahir 1 rok temu
rodzic
commit
1bce0d9187

+ 4 - 0
src/article/controller/article.controller.ts

@@ -0,0 +1,4 @@
+import { Controller } from '@nestjs/common';
+
+@Controller('articles')
+export class ArticleController {}

+ 10 - 0
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());
+  }
 }

+ 2 - 0
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;
 }