initial
This commit is contained in:
53
apps/backend/src/items/dto/item.dto.ts
Normal file
53
apps/backend/src/items/dto/item.dto.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user