- 登录连续失败 5 次锁定 15 分钟(Redis 计数) - 密码字段 @MinLength(6) - refresh 校验 tokenHash Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
112 lines
2.6 KiB
TypeScript
112 lines
2.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||
import { IsArray, IsIn, IsNotEmpty, IsOptional, IsString, MinLength } from 'class-validator';
|
||
import { PageQuery } from '../common/page.dto.js';
|
||
import { UserStatus } from '../common/enums.js';
|
||
|
||
export class CreateUserDto {
|
||
@ApiProperty({ description: '用户名' })
|
||
@IsString()
|
||
@IsNotEmpty()
|
||
username!: string;
|
||
|
||
@ApiProperty({ description: '初始密码' })
|
||
@IsString()
|
||
@IsNotEmpty()
|
||
@MinLength(6, { message: '密码长度不能少于 6 位' })
|
||
password!: string;
|
||
|
||
@ApiPropertyOptional({ description: '昵称' })
|
||
@IsOptional()
|
||
@IsString()
|
||
nickname?: string;
|
||
|
||
@ApiPropertyOptional({ description: '邮箱' })
|
||
@IsOptional()
|
||
@IsString()
|
||
email?: string;
|
||
|
||
@ApiPropertyOptional({ description: '手机号' })
|
||
@IsOptional()
|
||
@IsString()
|
||
phone?: string;
|
||
|
||
@ApiPropertyOptional({ description: '头像' })
|
||
@IsOptional()
|
||
@IsString()
|
||
avatar?: string;
|
||
|
||
@ApiPropertyOptional({ description: '所属部门 code' })
|
||
@IsOptional()
|
||
@IsString()
|
||
orgCode?: string;
|
||
}
|
||
|
||
export class UpdateUserDto {
|
||
@ApiPropertyOptional({ description: '昵称' })
|
||
@IsOptional()
|
||
@IsString()
|
||
nickname?: string;
|
||
|
||
@ApiPropertyOptional({ description: '邮箱' })
|
||
@IsOptional()
|
||
@IsString()
|
||
email?: string;
|
||
|
||
@ApiPropertyOptional({ description: '手机号' })
|
||
@IsOptional()
|
||
@IsString()
|
||
phone?: string;
|
||
|
||
@ApiPropertyOptional({ description: '头像' })
|
||
@IsOptional()
|
||
@IsString()
|
||
avatar?: string;
|
||
|
||
@ApiPropertyOptional({ description: '所属部门 code' })
|
||
@IsOptional()
|
||
@IsString()
|
||
orgCode?: string;
|
||
|
||
@ApiPropertyOptional({ description: '状态:enabled/disabled/locked' })
|
||
@IsOptional()
|
||
@IsIn(Object.values(UserStatus))
|
||
status?: string;
|
||
}
|
||
|
||
export class ResetPasswordDto {
|
||
@ApiProperty({ description: '新密码' })
|
||
@IsString()
|
||
@IsNotEmpty()
|
||
@MinLength(6, { message: '密码长度不能少于 6 位' })
|
||
password!: string;
|
||
}
|
||
|
||
export class AssignRolesDto {
|
||
@ApiProperty({ description: '角色 code 列表', type: [String] })
|
||
@IsArray()
|
||
@IsString({ each: true })
|
||
roleCodes!: string[];
|
||
}
|
||
|
||
export class ListUserQuery extends PageQuery {
|
||
@ApiPropertyOptional({ description: '用户名(模糊)' })
|
||
@IsOptional()
|
||
@IsString()
|
||
username?: string;
|
||
|
||
@ApiPropertyOptional({ description: '昵称(模糊)' })
|
||
@IsOptional()
|
||
@IsString()
|
||
nickname?: string;
|
||
|
||
@ApiPropertyOptional({ description: '手机号(模糊)' })
|
||
@IsOptional()
|
||
@IsString()
|
||
phone?: string;
|
||
|
||
@ApiPropertyOptional({ description: '状态:enabled/disabled/locked' })
|
||
@IsOptional()
|
||
@IsIn(Object.values(UserStatus))
|
||
status?: string;
|
||
}
|