import { IsString, IsEmail, IsOptional, IsMobilePhone, MinLength, MaxLength } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateMemberDto {
  @ApiProperty({ description: '用户名', example: 'testuser' })
  @IsString()
  @MinLength(3)
  @MaxLength(20)
  username: string;

  @ApiProperty({ description: '密码', example: '123456' })
  @IsString()
  @MinLength(6)
  @MaxLength(20)
  password: string;

  @ApiProperty({ description: '手机号', example: '13800138000' })
  @IsMobilePhone('zh-CN')
  mobile: string;

  @ApiProperty({ description: '邮箱', example: 'test@example.com', required: false })
  @IsOptional()
  @IsEmail()
  email?: string;

  @ApiProperty({ description: '昵称', example: '测试用户', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(50)
  nickname?: string;

  @ApiProperty({ description: '真实姓名', example: '张三', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(100)
  real_name?: string;

  @ApiProperty({ description: '性别', example: 1, required: false })
  @IsOptional()
  sex?: number;
}

export class LoginDto {
  @ApiProperty({ description: '用户名', example: 'testuser' })
  @IsString()
  username: string;

  @ApiProperty({ description: '密码', example: '123456' })
  @IsString()
  password: string;

  @ApiProperty({ description: 'IP地址', required: false })
  @IsOptional()
  @IsString()
  ip?: string;

  @ApiProperty({ description: '登录地址', required: false })
  @IsOptional()
  @IsString()
  address?: string;

  @ApiProperty({ description: '登录设备', required: false })
  @IsOptional()
  @IsString()
  device?: string;
}

export class UpdateProfileDto {
  @ApiProperty({ description: '昵称', example: '新昵称', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(50)
  nickname?: string;

  @ApiProperty({ description: '邮箱', example: 'new@example.com', required: false })
  @IsOptional()
  @IsEmail()
  email?: string;

  @ApiProperty({ description: '真实姓名', example: '李四', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(100)
  real_name?: string;

  @ApiProperty({ description: '性别', example: 1, required: false })
  @IsOptional()
  sex?: number;

  @ApiProperty({ description: '生日', example: '1990-01-01', required: false })
  @IsOptional()
  birthday?: Date;

  @ApiProperty({ description: '身份证号', example: '110101199001011234', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(18)
  id_card?: string;
}

export class ChangePasswordDto {
  @ApiProperty({ description: '原密码', example: '123456' })
  @IsString()
  oldPassword: string;

  @ApiProperty({ description: '新密码', example: '654321' })
  @IsString()
  @MinLength(6)
  @MaxLength(20)
  newPassword: string;
}

export class ResetPasswordDto {
  @ApiProperty({ description: '手机号', example: '13800138000' })
  @IsMobilePhone('zh-CN')
  mobile: string;

  @ApiProperty({ description: '验证码', example: '123456' })
  @IsString()
  verifyCode: string;

  @ApiProperty({ description: '新密码', example: '654321' })
  @IsString()
  @MinLength(6)
  @MaxLength(20)
  newPassword: string;
}

export class SignDto {
  @ApiProperty({ description: '签到备注', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(255)
  remark?: string;

  @ApiProperty({ description: 'IP地址', required: false })
  @IsOptional()
  @IsString()
  ip?: string;

  @ApiProperty({ description: '签到地址', required: false })
  @IsOptional()
  @IsString()
  address?: string;

  @ApiProperty({ description: '签到设备', required: false })
  @IsOptional()
  @IsString()
  device?: string;
} 