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

export class RecordRecentDto {
  @ApiProperty({ description: '目标类型' })
  @IsString()
  targetType: string;

  @ApiProperty({ description: '目标ID' })
  @IsString()
  targetId: string;

  @ApiProperty({ description: '标题' })
  @IsString()
  title: string;

  @ApiPropertyOptional({ description: '元数据' })
  @IsOptional()
  metadata?: Record<string, any>;
}

export class AddFavoriteDto {
  @ApiProperty({ description: '目标类型' })
  @IsString()
  targetType: string;

  @ApiProperty({ description: '目标ID' })
  @IsString()
  targetId: string;

  @ApiPropertyOptional({ description: '标题' })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiPropertyOptional({ description: '元数据' })
  @IsOptional()
  metadata?: Record<string, any>;
}

export class CreateTagDto {
  @ApiProperty({ description: '标签名' })
  @IsString()
  name: string;

  @ApiPropertyOptional({ description: '颜色' })
  @IsOptional()
  @IsString()
  color?: string;
}

export class UpdateTagDto {
  @ApiPropertyOptional({ description: '标签名' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional({ description: '颜色' })
  @IsOptional()
  @IsString()
  color?: string;
}

export class AttachTagDto {
  @ApiProperty({ description: '目标类型（knowledge_item）' })
  @IsString()
  targetType: string;

  @ApiProperty({ description: '目标ID' })
  @IsString()
  targetId: string;
}

export class SearchDto {
  @ApiProperty({ description: '搜索关键词' })
  @IsString()
  q: string;

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

  @ApiPropertyOptional({ description: '页码', default: 0 })
  @IsOptional()
  @IsInt()
  @Min(0)
  offset?: number;
}
