131 lines
3.1 KiB
TypeScript
131 lines
3.1 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
IsArray,
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsObject,
|
|
IsOptional,
|
|
IsString,
|
|
MaxLength,
|
|
ValidateNested,
|
|
} from 'class-validator';
|
|
import { IsBoolean } from 'class-validator';
|
|
import { ArtworkStatus, AuditStatus } 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;
|
|
}
|
|
|
|
export class CreateArtworkDto {
|
|
@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[];
|
|
}
|
|
|
|
export class UpdateArtworkDto {
|
|
@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: '状态', enum: ArtworkStatus })
|
|
@IsOptional()
|
|
@IsEnum(ArtworkStatus)
|
|
status?: ArtworkStatus;
|
|
}
|
|
|
|
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;
|
|
}
|