301 lines
7.7 KiB
TypeScript
301 lines
7.7 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
ArrayMaxSize,
|
|
IsArray,
|
|
IsDateString,
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsObject,
|
|
IsOptional,
|
|
IsString,
|
|
MaxLength,
|
|
ValidateNested,
|
|
} from 'class-validator';
|
|
import { IsBoolean } from 'class-validator';
|
|
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, CertType, NodeType } from '@artveris/shared';
|
|
import { PaginationDto } from '../../common/dto/pagination.dto';
|
|
|
|
export class MediaItemDto {
|
|
@ApiProperty({ description: '存储 key(上传接口返回)' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
key!: string;
|
|
|
|
@ApiPropertyOptional({ description: '原始文件名' })
|
|
@IsOptional()
|
|
@IsString()
|
|
name?: string;
|
|
|
|
@ApiPropertyOptional({ description: '类型:image | video' })
|
|
@IsOptional()
|
|
@IsString()
|
|
type?: string;
|
|
|
|
@ApiPropertyOptional({ description: '展示说明' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(1000)
|
|
description?: string;
|
|
}
|
|
|
|
export class CreateArtworkDto {
|
|
@ApiPropertyOptional({ description: '是否在客户端时间轴显示本件出库记录', default: false })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
showOutboundTimeline?: boolean;
|
|
|
|
@ApiProperty({ description: '模板 ID' })
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
templateId!: number;
|
|
|
|
@ApiProperty({ description: '作品名称' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(120)
|
|
title!: string;
|
|
|
|
@ApiPropertyOptional({ description: '艺术家 / 创作者' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
artist?: string;
|
|
|
|
@ApiPropertyOptional({ description: '动态字段数据(按模板字段键存储)' })
|
|
@IsOptional()
|
|
@IsObject()
|
|
dynamicFields?: Record<string, unknown>;
|
|
|
|
@ApiPropertyOptional({ description: '作品图片', type: [MediaItemDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => MediaItemDto)
|
|
images?: MediaItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: '客户端作品展示图片', type: [MediaItemDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ArrayMaxSize(30)
|
|
@ValidateNested({ each: true })
|
|
@Type(() => MediaItemDto)
|
|
showcaseImages?: MediaItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
|
@IsOptional()
|
|
@IsEnum(ArtworkStatus)
|
|
status?: ArtworkStatus;
|
|
|
|
@ApiPropertyOptional({ description: '创建时一并保存的溯源时间轴草稿', type: () => [CreateArtworkTraceNodeDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateArtworkTraceNodeDto)
|
|
traceNodes?: CreateArtworkTraceNodeDto[];
|
|
|
|
@ApiPropertyOptional({ description: '创建时一并保存的认证文件草稿', type: () => [CreateArtworkCertificateDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateArtworkCertificateDto)
|
|
certificates?: CreateArtworkCertificateDto[];
|
|
}
|
|
|
|
export class CreateArtworkTraceNodeDto {
|
|
@ApiProperty({ description: '节点类型', enum: NodeType })
|
|
@IsEnum(NodeType)
|
|
nodeType!: NodeType;
|
|
|
|
@ApiProperty({ description: '节点标题' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(80)
|
|
title!: string;
|
|
|
|
@ApiPropertyOptional({ description: '发生时间' })
|
|
@IsOptional()
|
|
@IsDateString()
|
|
occurredAt?: string;
|
|
|
|
@ApiPropertyOptional({ description: '地点' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
location?: string;
|
|
|
|
@ApiPropertyOptional({ description: '说明' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(2000)
|
|
description?: string;
|
|
|
|
@ApiPropertyOptional({ description: '图片/视频', type: [MediaItemDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => MediaItemDto)
|
|
mediaFiles?: MediaItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: '排序' })
|
|
@IsOptional()
|
|
@IsInt()
|
|
sortOrder?: number;
|
|
}
|
|
|
|
export class CreateArtworkCertificateDto {
|
|
@ApiProperty({ description: '证书名称' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(120)
|
|
name!: string;
|
|
|
|
@ApiPropertyOptional({ description: '颁发机构' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
issuer?: string;
|
|
|
|
@ApiPropertyOptional({ description: '颁发时间' })
|
|
@IsOptional()
|
|
@IsDateString()
|
|
issuedAt?: string;
|
|
|
|
@ApiProperty({ description: '类型', enum: CertType })
|
|
@IsEnum(CertType)
|
|
type!: CertType;
|
|
|
|
@ApiProperty({ description: '原始文件存储 key(上传接口返回)' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
originKey!: string;
|
|
|
|
@ApiPropertyOptional({ description: '已有水印文件 key' })
|
|
@IsOptional()
|
|
@IsString()
|
|
watermarkKey?: string;
|
|
}
|
|
|
|
export class UpdateArtworkDto {
|
|
@ApiPropertyOptional({ description: '是否在客户端时间轴显示本件出库记录' })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
showOutboundTimeline?: boolean;
|
|
|
|
@ApiPropertyOptional({ description: '作品名称' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
title?: string;
|
|
|
|
@ApiPropertyOptional({ description: '艺术家 / 创作者' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
artist?: string;
|
|
|
|
@ApiPropertyOptional({ description: '动态字段数据' })
|
|
@IsOptional()
|
|
@IsObject()
|
|
dynamicFields?: Record<string, unknown>;
|
|
|
|
@ApiPropertyOptional({ description: '作品图片', type: [MediaItemDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => MediaItemDto)
|
|
images?: MediaItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: '客户端作品展示图片', type: [MediaItemDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ArrayMaxSize(30)
|
|
@ValidateNested({ each: true })
|
|
@Type(() => MediaItemDto)
|
|
showcaseImages?: MediaItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
|
@IsOptional()
|
|
@IsEnum(ArtworkStatus)
|
|
status?: ArtworkStatus;
|
|
|
|
@ApiPropertyOptional({ description: '变更标题' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
revisionTitle?: string;
|
|
|
|
@ApiPropertyOptional({ description: '变更原因 / 修改说明' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(1000)
|
|
revisionReason?: string;
|
|
|
|
@ApiPropertyOptional({ description: '保存时一并提交的溯源时间轴', type: () => [CreateArtworkTraceNodeDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateArtworkTraceNodeDto)
|
|
traceNodes?: CreateArtworkTraceNodeDto[];
|
|
|
|
@ApiPropertyOptional({ description: '保存时一并提交的认证文件', type: () => [CreateArtworkCertificateDto] })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateArtworkCertificateDto)
|
|
certificates?: CreateArtworkCertificateDto[];
|
|
}
|
|
|
|
export class QueryArtworkDto extends PaginationDto {
|
|
@ApiPropertyOptional({ description: '关键词(名称/艺术家)' })
|
|
@IsOptional()
|
|
@IsString()
|
|
keyword?: string;
|
|
|
|
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
|
@IsOptional()
|
|
@IsEnum(ArtworkStatus)
|
|
status?: ArtworkStatus;
|
|
|
|
@ApiPropertyOptional({ description: '审核状态', enum: AuditStatus })
|
|
@IsOptional()
|
|
@IsEnum(AuditStatus)
|
|
auditStatus?: AuditStatus;
|
|
|
|
@ApiPropertyOptional({ description: '模板 ID' })
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
templateId?: number;
|
|
}
|
|
|
|
export class AuditArtworkDto {
|
|
@ApiProperty({ description: '是否通过' })
|
|
@IsBoolean()
|
|
approved!: boolean;
|
|
|
|
@ApiPropertyOptional({ description: '审核意见(驳回建议填写)' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(255)
|
|
remark?: string;
|
|
|
|
@ApiPropertyOptional({ description: '审核变更稿 ID;为空时审核作品当前版本' })
|
|
@IsOptional()
|
|
@IsString()
|
|
revisionId?: string;
|
|
}
|
|
|
|
export class QueryArtworkRevisionDto extends PaginationDto {
|
|
@ApiPropertyOptional({ description: '关键词(作品名称 / 档案编号 / 变更标题)' })
|
|
@IsOptional()
|
|
@IsString()
|
|
keyword?: string;
|
|
|
|
@ApiPropertyOptional({ description: '审核状态', enum: ArtworkRevisionStatus })
|
|
@IsOptional()
|
|
@IsEnum(ArtworkRevisionStatus)
|
|
status?: ArtworkRevisionStatus;
|
|
}
|