import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger'; import { IsArray, IsOptional, IsString } from 'class-validator'; import { PagerDto } from '~/common/dto/pager.dto'; import { Storage } from '../tools/storage/storage.entity'; import { IsUnique } from '~/shared/database/constraints/unique.constraint'; import { ProjectEntity } from './project.entity'; export class ProjectDto { @ApiProperty({ description: '项目名称' }) @IsUnique(ProjectEntity, { message: '已存在同名项目' }) @IsString() name: string; @ApiProperty({ description: '附件' }) files: Storage[]; } export class ProjectUpdateDto extends PartialType(ProjectDto) { @ApiProperty({ description: '附件' }) @IsOptional() @IsArray() fileIds: number[]; } export class ComapnyCreateDto extends PartialType(ProjectDto) { @ApiProperty({ description: '附件' }) @IsOptional() @IsArray() fileIds: number[]; } export class ProjectQueryDto extends IntersectionType( PagerDto, PartialType(ProjectDto) ) { @ApiProperty({ description: '项目名称' }) @IsOptional() @IsString() name: string; }