From 86f2c85f8daf690904e90f3ae67b9def84acfdfe Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 11 Jan 2026 00:54:37 -0800 Subject: [PATCH] =?UTF-8?q?fix(mining-admin-service):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?LoginDto=E9=AA=8C=E8=AF=81=E8=A3=85=E9=A5=B0=E5=99=A8=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 @IsString() 和 @IsNotEmpty() 装饰器到 LoginDto, 修复 ValidationPipe forbidNonWhitelisted 导致的400错误 Co-Authored-By: Claude Opus 4.5 --- .../src/api/controllers/auth.controller.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 5f9a089a..302988c5 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,9 +1,20 @@ import { Controller, Post, Body, Req, HttpCode, HttpStatus } from '@nestjs/common'; -import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; +import { ApiTags, ApiOperation, ApiBearerAuth, ApiProperty } from '@nestjs/swagger'; +import { IsString, IsNotEmpty } from 'class-validator'; import { AuthService } from '../../application/services/auth.service'; import { Public } from '../../shared/guards/admin-auth.guard'; -class LoginDto { username: string; password: string; } +class LoginDto { + @ApiProperty({ description: '用户名' }) + @IsString() + @IsNotEmpty() + username: string; + + @ApiProperty({ description: '密码' }) + @IsString() + @IsNotEmpty() + password: string; +} @ApiTags('Auth') @Controller('auth')