2026-09-19 00:59:39 +08:00
|
|
|
|
// services/api/src/auth/dto.ts —— auth 端点入参 DTO(Task 13;Task 3/P3 增补
|
|
|
|
|
|
// password-change)。Nest 约定用 class-validator + class-transformer(非 zod):
|
|
|
|
|
|
// 装饰器元数据供全局 ValidationPipe(app-cn.module 经 APP_PIPE 注册)校验,
|
|
|
|
|
|
// 失败抛 BadRequestException,由全局过滤器映射 400 VALIDATION_FAILED(契约各
|
|
|
|
|
|
// auth 端点的 '400' 响应)。字段约束对齐契约 LoginRequest:account/password
|
|
|
|
|
|
// 均为非空字符串;契约未定义长度上限(users.account 列宽 64 由入库侧保证,
|
|
|
|
|
|
// 超长账号查无此人不构成枚举面)。PasswordChangeRequest(P3 Task 3 契约增补):
|
|
|
|
|
|
// oldPassword 1-128、newPassword 8-128。
|
|
|
|
|
|
import {
|
|
|
|
|
|
IsNotEmpty,
|
|
|
|
|
|
IsString,
|
|
|
|
|
|
MaxLength,
|
|
|
|
|
|
MinLength,
|
|
|
|
|
|
} from 'class-validator';
|
2026-09-17 21:17:16 +08:00
|
|
|
|
|
|
|
|
|
|
export class LoginRequestDto {
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
@IsNotEmpty()
|
|
|
|
|
|
account!: string;
|
|
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
@IsNotEmpty()
|
|
|
|
|
|
password!: string;
|
|
|
|
|
|
}
|
2026-09-19 00:59:39 +08:00
|
|
|
|
|
|
|
|
|
|
export class PasswordChangeRequestDto {
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
@IsNotEmpty()
|
|
|
|
|
|
@MaxLength(128)
|
|
|
|
|
|
oldPassword!: string;
|
|
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
|
@MinLength(8)
|
|
|
|
|
|
@MaxLength(128)
|
|
|
|
|
|
newPassword!: string;
|
|
|
|
|
|
}
|