diff --git a/backend/services/mining-admin-service/src/api/controllers/auth.controller.ts b/backend/services/mining-admin-service/src/api/controllers/auth.controller.ts index 302988c5..b85e943f 100644 --- a/backend/services/mining-admin-service/src/api/controllers/auth.controller.ts +++ b/backend/services/mining-admin-service/src/api/controllers/auth.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Post, Body, Req, HttpCode, HttpStatus } from '@nestjs/common'; +import { Controller, Post, Get, Body, Req, HttpCode, HttpStatus } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth, ApiProperty } from '@nestjs/swagger'; import { IsString, IsNotEmpty } from 'class-validator'; import { AuthService } from '../../application/services/auth.service'; @@ -29,6 +29,17 @@ export class AuthController { return this.authService.login(dto.username, dto.password, req.ip, req.headers['user-agent']); } + @Get('profile') + @ApiBearerAuth() + @ApiOperation({ summary: '获取当前用户信息' }) + async getProfile(@Req() req: any) { + return { + id: req.admin.id, + username: req.admin.username, + role: req.admin.role, + }; + } + @Post('logout') @ApiBearerAuth() @HttpCode(HttpStatus.OK)