API/src/dto/wp_product.dto.ts

137 lines
4.3 KiB
TypeScript

import { ApiProperty } from '@midwayjs/swagger';
import { Variation } from '../entity/variation.entity';
import { WpProduct } from '../entity/wp_product.entity';
import { Rule, RuleType } from '@midwayjs/validate';
import { ProductStatus } from '../enums/base.enum';
export class VariationDTO extends Variation {}
export class WpProductDTO extends WpProduct {
@ApiProperty({ description: '变体列表', type: VariationDTO, isArray: true })
variations?: VariationDTO[];
}
export class UpdateVariationDTO {
@ApiProperty({ description: '产品名称' })
@Rule(RuleType.string().optional())
name?: string;
@ApiProperty({ description: 'SKU' })
@Rule(RuleType.string().allow('').optional())
sku?: string;
@ApiProperty({ description: '常规价格', type: Number })
@Rule(RuleType.number().optional())
regular_price?: number; // 常规价格
@ApiProperty({ description: '销售价格', type: Number })
@Rule(RuleType.number().optional())
sale_price?: number; // 销售价格
@ApiProperty({ description: '是否促销中', type: Boolean })
@Rule(RuleType.boolean().optional())
on_sale?: boolean; // 是否促销中
}
export class UpdateWpProductDTO {
@ApiProperty({ description: '变体名称' })
@Rule(RuleType.string().optional())
name?: string;
@ApiProperty({ description: 'SKU' })
@Rule(RuleType.string().allow('').optional())
sku?: string;
@ApiProperty({ description: '常规价格', type: Number })
@Rule(RuleType.number().optional())
regular_price?: number; // 常规价格
@ApiProperty({ description: '销售价格', type: Number })
@Rule(RuleType.number().optional())
sale_price?: number; // 销售价格
@ApiProperty({ description: '是否促销中', type: Boolean })
@Rule(RuleType.boolean().optional())
on_sale?: boolean; // 是否促销中
@ApiProperty({ description: '分类列表', type: [String] })
@Rule(RuleType.array().items(RuleType.string()).optional())
categories?: string[];
@ApiProperty({ description: '标签列表', type: [String] })
@Rule(RuleType.array().items(RuleType.string()).optional())
tags?: string[];
@ApiProperty({ description: '站点ID', required: false })
@Rule(RuleType.number().optional())
siteId?: number;
}
export class QueryWpProductDTO {
@ApiProperty({ example: '1', description: '页码' })
@Rule(RuleType.number())
current: number;
@ApiProperty({ example: '10', description: '每页大小' })
@Rule(RuleType.number())
pageSize: number;
@ApiProperty({ example: 'ZYN', description: '产品名' })
@Rule(RuleType.string())
name?: string;
@ApiProperty({ example: '1', description: '站点ID' })
@Rule(RuleType.string())
siteId?: string;
@ApiProperty({ description: '产品状态', enum: ProductStatus })
@Rule(RuleType.string().valid(...Object.values(ProductStatus)))
status?: ProductStatus;
@ApiProperty({ description: 'SKU列表', type: Array })
@Rule(RuleType.array().items(RuleType.string()).single())
skus?: string[];
}
export class BatchSyncProductsDTO {
@ApiProperty({ description: '产品ID列表', type: [Number] })
@Rule(RuleType.array().items(RuleType.number()).required())
productIds: number[];
}
export class BatchUpdateTagsDTO {
@ApiProperty({ description: '产品ID列表', type: [Number] })
@Rule(RuleType.array().items(RuleType.number()).required())
ids: number[];
@ApiProperty({ description: '标签列表', type: [String] })
@Rule(RuleType.array().items(RuleType.string()).required())
tags: string[];
}
export class BatchUpdateProductsDTO {
@ApiProperty({ description: '产品ID列表', type: [Number] })
@Rule(RuleType.array().items(RuleType.number()).required())
ids: number[];
@ApiProperty({ description: '常规价格', type: Number })
@Rule(RuleType.number())
regular_price?: number;
@ApiProperty({ description: '销售价格', type: Number })
@Rule(RuleType.number())
sale_price?: number;
@ApiProperty({ description: '分类列表', type: [String] })
@Rule(RuleType.array().items(RuleType.string()))
categories?: string[];
@ApiProperty({ description: '标签列表', type: [String] })
@Rule(RuleType.array().items(RuleType.string()))
tags?: string[];
@ApiProperty({ description: '状态', enum: ProductStatus })
@Rule(RuleType.string().valid(...Object.values(ProductStatus)))
status?: ProductStatus;
}