54 lines
784 B
TypeScript
54 lines
784 B
TypeScript
import {
|
|
IsEnum,
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
Length,
|
|
Min,
|
|
} from 'class-validator';
|
|
import { ItemStatus } from '../entities/item.entity';
|
|
|
|
export class ItemListQueryDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
search?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
sort?: 'name' | 'status' | 'createdAt' | 'updatedAt';
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
direction?: 'ASC' | 'DESC';
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
page = 1;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
pageSize = 20;
|
|
}
|
|
|
|
export class CreateItemDto {
|
|
@IsString()
|
|
@Length(1, 160)
|
|
name!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@Length(0, 4000)
|
|
description?: string;
|
|
|
|
@IsEnum(ItemStatus)
|
|
status!: ItemStatus;
|
|
}
|
|
|
|
export class UpdateItemDto extends CreateItemDto {
|
|
@IsInt()
|
|
@Min(1)
|
|
version!: number;
|
|
}
|