From 25ad627377eb4f40e8dd8a6e0b89620d5ec2e836 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 11 Jan 2026 01:01:49 -0800 Subject: [PATCH] =?UTF-8?q?feat(mining-admin-service):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0/auth/profile=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端dashboard layout需要获取当前用户信息,添加GET /auth/profile接口 Co-Authored-By: Claude Opus 4.5 --- .../src/api/controllers/auth.controller.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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)