import { IsString, IsNotEmpty, IsOptional, IsEmail, Length, Matches, IsEnum } from 'class-validator';
import { Type } from 'class-transformer';

export class UpdateProfileDto {
  @IsOptional()
  @IsString()
  @Length(1, 50, { message: '昵称长度为1-50位' })
  nickname?: string;

  @IsOptional()
  @IsString()
  avatar?: string;

  @IsOptional()
  gender?: number;
}

export class ChangePasswordDto {
  @IsString()
  @IsNotEmpty({ message: '旧密码不能为空' })
  oldPassword: string;

  @IsString()
  @IsNotEmpty({ message: '新密码不能为空' })
  @Length(6, 20, { message: '密码长度为6-20位' })
  newPassword: string;
}

export class QueryUserDto {
  @IsOptional()
  @Type(() => Number)
  page?: number = 1;

  @IsOptional()
  @Type(() => Number)
  pageSize?: number = 10;

  @IsOptional()
  @IsString()
  keyword?: string;

  @IsOptional()
  @IsString()
  status?: string;

  @IsOptional()
  @IsString()
  role?: string;
}

export class VerifyIdentityDto {
  @IsString()
  @IsNotEmpty({ message: '真实姓名不能为空' })
  @Length(2, 50, { message: '姓名长度为2-50位' })
  realName: string;

  @IsString()
  @IsNotEmpty({ message: '身份证号不能为空' })
  @Matches(/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/, {
    message: '身份证号格式不正确',
  })
  idCard: string;
}
