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

// 创建菜单DTO
export class CreateMenuDto {
  @ApiProperty({ description: '应用类型' })
  @IsString()
  app_type: string;

  @ApiProperty({ description: '菜单名称' })
  @IsString()
  menu_name: string;

  @ApiPropertyOptional({ description: '菜单短标题' })
  @IsOptional()
  @IsString()
  menu_short_name?: string;

  @ApiProperty({ description: '菜单标识' })
  @IsString()
  menu_key: string;

  @ApiPropertyOptional({ description: '父级key' })
  @IsOptional()
  @IsString()
  parent_key?: string;

  @ApiPropertyOptional({ description: '菜单类型 0目录 1菜单 2按钮', default: 1 })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(2)
  menu_type?: number;

  @ApiPropertyOptional({ description: '图标' })
  @IsOptional()
  @IsString()
  icon?: string;

  @ApiPropertyOptional({ description: 'api接口地址' })
  @IsOptional()
  @IsString()
  api_url?: string;

  @ApiPropertyOptional({ description: '菜单路由地址' })
  @IsOptional()
  @IsString()
  router_path?: string;

  @ApiPropertyOptional({ description: '菜单文件地址' })
  @IsOptional()
  @IsString()
  view_path?: string;

  @ApiPropertyOptional({ description: '提交方式' })
  @IsOptional()
  @IsString()
  methods?: string;

  @ApiPropertyOptional({ description: '排序', default: 1 })
  @IsOptional()
  @IsNumber()
  sort?: number;

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

  @ApiPropertyOptional({ description: '是否显示', default: 1 })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(1)
  is_show?: number;

  @ApiPropertyOptional({ description: '所属插件' })
  @IsOptional()
  @IsString()
  addon?: string;

  @ApiPropertyOptional({ description: '菜单来源', default: 'system' })
  @IsOptional()
  @IsString()
  source?: string;

  @ApiPropertyOptional({ description: '菜单属性' })
  @IsOptional()
  @IsString()
  menu_attr?: string;

  @ApiPropertyOptional({ description: '上级key' })
  @IsOptional()
  @IsString()
  parent_select_key?: string;
}

// 更新菜单DTO
export class UpdateMenuDto {
  @ApiPropertyOptional({ description: '应用类型' })
  @IsOptional()
  @IsString()
  app_type?: string;

  @ApiPropertyOptional({ description: '菜单名称' })
  @IsOptional()
  @IsString()
  menu_name?: string;

  @ApiPropertyOptional({ description: '菜单短标题' })
  @IsOptional()
  @IsString()
  menu_short_name?: string;

  @ApiPropertyOptional({ description: '菜单标识' })
  @IsOptional()
  @IsString()
  menu_key?: string;

  @ApiPropertyOptional({ description: '父级key' })
  @IsOptional()
  @IsString()
  parent_key?: string;

  @ApiPropertyOptional({ description: '菜单类型 0目录 1菜单 2按钮' })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(2)
  menu_type?: number;

  @ApiPropertyOptional({ description: '图标' })
  @IsOptional()
  @IsString()
  icon?: string;

  @ApiPropertyOptional({ description: 'api接口地址' })
  @IsOptional()
  @IsString()
  api_url?: string;

  @ApiPropertyOptional({ description: '菜单路由地址' })
  @IsOptional()
  @IsString()
  router_path?: string;

  @ApiPropertyOptional({ description: '菜单文件地址' })
  @IsOptional()
  @IsString()
  view_path?: string;

  @ApiPropertyOptional({ description: '提交方式' })
  @IsOptional()
  @IsString()
  methods?: string;

  @ApiPropertyOptional({ description: '排序' })
  @IsOptional()
  @IsNumber()
  sort?: number;

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

  @ApiPropertyOptional({ description: '是否显示' })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(1)
  is_show?: number;

  @ApiPropertyOptional({ description: '所属插件' })
  @IsOptional()
  @IsString()
  addon?: string;

  @ApiPropertyOptional({ description: '菜单来源' })
  @IsOptional()
  @IsString()
  source?: string;

  @ApiPropertyOptional({ description: '菜单属性' })
  @IsOptional()
  @IsString()
  menu_attr?: string;

  @ApiPropertyOptional({ description: '上级key' })
  @IsOptional()
  @IsString()
  parent_select_key?: string;
}

// 查询菜单DTO
export class QueryMenuDto {
  @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()
  app_type?: string;

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

  @ApiPropertyOptional({ description: '菜单名称' })
  @IsOptional()
  @IsString()
  menu_name?: string;

  @ApiPropertyOptional({ description: '菜单类型' })
  @IsOptional()
  @IsNumber()
  menu_type?: number;

  @ApiPropertyOptional({ description: '父级key' })
  @IsOptional()
  @IsString()
  parent_key?: string;

  @ApiPropertyOptional({ description: '状态' })
  @IsOptional()
  @IsNumber()
  status?: number;
}

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

  @ApiProperty({ description: '菜单ID列表', type: [Number] })
  @IsArray()
  @IsNumber({}, { each: true })
  menuIds: number[];

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