localhost_oa_based/src/modules/project/project.dto.ts

41 lines
1.1 KiB
TypeScript

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<ProjectDto>,
PartialType(ProjectDto)
) {
@ApiProperty({ description: '项目名称' })
@IsOptional()
@IsString()
name: string;
}