import { IsString, IsNumber, IsOptional, IsArray, Min, Max } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

// 创建管理员DTO
export class CreateAdminDto {
  @ApiProperty({ description: '用户账号' })
  @IsString()
  username: string;

  @ApiProperty({ description: '用户密码' })
  @IsString()
  password: string;

  @ApiProperty({ description: '实际姓名' })
  @IsString()
  real_name: string;

  @ApiPropertyOptional({ description: '头像' })
  @IsOptional()
  @IsString()
  head_img?: string;

  @ApiPropertyOptional({ description: '角色ID列表' })
  @IsOptional()
  @IsString()
  role_ids?: string;

  @ApiPropertyOptional({ description: '状态 1有效0无效', default: 1 })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(1)
  status?: number;
}

// 更新管理员DTO
export class UpdateAdminDto {
  @ApiPropertyOptional({ description: '用户账号' })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({ description: '用户密码' })
  @IsOptional()
  @IsString()
  password?: string;

  @ApiPropertyOptional({ description: '实际姓名' })
  @IsOptional()
  @IsString()
  real_name?: string;

  @ApiPropertyOptional({ description: '头像' })
  @IsOptional()
  @IsString()
  head_img?: string;

  @ApiPropertyOptional({ description: '角色ID列表' })
  @IsOptional()
  @IsString()
  role_ids?: string;

  @ApiPropertyOptional({ description: '状态 1有效0无效' })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(1)
  status?: number;
}

// 查询管理员DTO
export class QueryAdminDto {
  @ApiPropertyOptional({ description: '页码', default: 1 })
  @IsOptional()
  @IsNumber()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ description: '每页数量', default: 20 })
  @IsOptional()
  @IsNumber()
  @Min(1)
  @Max(100)
  limit?: number = 20;

  @ApiPropertyOptional({ description: '关键词搜索' })
  @IsOptional()
  @IsString()
  keyword?: string;

  @ApiPropertyOptional({ description: '用户账号' })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({ description: '实际姓名' })
  @IsOptional()
  @IsString()
  real_name?: string;

  @ApiPropertyOptional({ description: '状态 1有效0无效' })
  @IsOptional()
  @IsNumber()
  status?: number;

  @ApiPropertyOptional({ description: '创建时间范围', type: [String] })
  @IsOptional()
  @IsArray()
  create_time?: string[];

  @ApiPropertyOptional({ description: '最后登录时间范围', type: [String] })
  @IsOptional()
  @IsArray()
  last_time?: string[];
}

// 批量更新状态DTO
export class BatchUpdateStatusDto {
  @ApiProperty({ description: '用户ID列表', type: [Number] })
  @IsArray()
  @IsNumber({}, { each: true })
  uids: number[];

  @ApiProperty({ description: '状态 1有效0无效' })
  @IsNumber()
  @Min(0)
  @Max(1)
  status: number;
}

// 批量分配角色DTO
export class BatchAssignRoleDto {
  @ApiProperty({ description: '用户ID列表', type: [Number] })
  @IsArray()
  @IsNumber({}, { each: true })
  uids: number[];

  @ApiProperty({ description: '角色ID列表' })
  @IsString()
  role_ids: string;
}

// 重置密码DTO
export class ResetPasswordDto {
  @ApiProperty({ description: '新密码' })
  @IsString()
  new_password: string;
} 