API/src/dto/site-api.dto.ts

696 lines
19 KiB
TypeScript

import { ApiProperty } from '@midwayjs/swagger';
export class UnifiedPaginationDTO<T> {
// 分页DTO用于承载统一分页信息与列表数据
@ApiProperty({ description: '列表数据' })
items: T[];
@ApiProperty({ description: '总数', example: 100 })
total: number;
@ApiProperty({ description: '当前页', example: 1 })
page: number;
@ApiProperty({ description: '每页数量', example: 20 })
per_page: number;
@ApiProperty({ description: '总页数', example: 5 })
totalPages: number;
}
export class UnifiedTagDTO {
// 标签DTO用于承载统一标签数据
@ApiProperty({ description: '标签ID' })
id: number | string;
@ApiProperty({ description: '标签名称' })
name: string;
}
export class UnifiedCategoryDTO {
// 分类DTO用于承载统一分类数据
@ApiProperty({ description: '分类ID' })
id: number | string;
@ApiProperty({ description: '分类名称' })
name: string;
}
export class UnifiedImageDTO {
// 图片DTO用于承载统一图片数据
@ApiProperty({ description: '图片ID' })
id: number | string;
@ApiProperty({ description: '图片URL' })
src: string;
@ApiProperty({ description: '图片名称', required: false })
name?: string;
@ApiProperty({ description: '替代文本', required: false })
alt?: string;
}
export class UnifiedAddressDTO {
// 地址DTO用于承载统一地址数据
@ApiProperty({ description: '名', required: false })
first_name?: string;
@ApiProperty({ description: '姓', required: false })
last_name?: string;
@ApiProperty({ description: '全名', required: false })
fullname?: string;
@ApiProperty({ description: '公司', required: false })
company?: string;
@ApiProperty({ description: '地址1', required: false })
address_1?: string;
@ApiProperty({ description: '地址2', required: false })
address_2?: string;
@ApiProperty({ description: '城市', required: false })
city?: string;
@ApiProperty({ description: '省/州', required: false })
state?: string;
@ApiProperty({ description: '邮政编码', required: false })
postcode?: string;
@ApiProperty({ description: '国家', required: false })
country?: string;
@ApiProperty({ description: '邮箱', required: false })
email?: string;
@ApiProperty({ description: '电话', required: false })
phone?: string;
}
export class UnifiedOrderLineItemDTO {
// 订单项DTO用于承载统一订单项数据
@ApiProperty({ description: '订单项ID' })
id: number | string;
@ApiProperty({ description: '产品名称' })
name: string;
@ApiProperty({ description: '产品ID' })
product_id: number | string;
@ApiProperty({ description: '变体ID', required: false })
variation_id?: number | string;
@ApiProperty({ description: '数量' })
quantity: number;
@ApiProperty({ description: '总计' })
total: string;
@ApiProperty({ description: 'SKU' })
sku: string;
}
export class UnifiedProductAttributeDTO {
// 产品属性DTO用于承载统一产品属性数据
@ApiProperty({ description: '属性ID', required: false })
id?: number | string;
@ApiProperty({ description: '属性名称' })
name: string;
@ApiProperty({ description: '属性位置', example: 0, required: false })
position?: number;
@ApiProperty({ description: '对变体是否可见', example: true, required: false })
visible?: boolean;
@ApiProperty({ description: '是否为变体属性', example: true, required: false })
variation?: boolean;
@ApiProperty({ description: '属性选项', type: [String] })
options: string[];
}
export class UnifiedProductVariationDTO {
// 产品变体DTO用于承载统一产品变体数据
@ApiProperty({ description: '变体ID' })
id: number | string;
@ApiProperty({ description: '变体SKU' })
sku: string;
@ApiProperty({ description: '常规价格' })
regular_price: string;
@ApiProperty({ description: '销售价格' })
sale_price: string;
@ApiProperty({ description: '当前价格' })
price: string;
@ApiProperty({ description: '库存状态' })
stock_status: string;
@ApiProperty({ description: '库存数量' })
stock_quantity: number;
@ApiProperty({ description: '变体图片', type: () => UnifiedImageDTO, required: false })
image?: UnifiedImageDTO;
}
export class UnifiedProductDTO {
// 产品DTO用于承载统一产品数据
@ApiProperty({ description: '产品ID' })
id: string | number;
@ApiProperty({ description: '产品名称' })
name: string;
@ApiProperty({ description: '产品类型' })
type: string;
@ApiProperty({ description: '产品状态' })
status: string;
@ApiProperty({ description: '产品SKU' })
sku: string;
@ApiProperty({ description: '常规价格' })
regular_price: string;
@ApiProperty({ description: '销售价格' })
sale_price: string;
@ApiProperty({ description: '当前价格' })
price: string;
@ApiProperty({ description: '库存状态' })
stock_status: string;
@ApiProperty({ description: '库存数量' })
stock_quantity: number;
@ApiProperty({ description: '产品图片', type: () => [UnifiedImageDTO] })
images: UnifiedImageDTO[];
@ApiProperty({ description: '产品标签', type: () => [UnifiedTagDTO], required: false })
tags?: UnifiedTagDTO[];
@ApiProperty({ description: '产品分类', type: () => [UnifiedCategoryDTO], required: false })
categories?: UnifiedCategoryDTO[];
@ApiProperty({ description: '产品属性', type: () => [UnifiedProductAttributeDTO] })
attributes: UnifiedProductAttributeDTO[];
@ApiProperty({
description: '产品变体',
type: () => [UnifiedProductVariationDTO],
required: false,
})
variations?: UnifiedProductVariationDTO[];
@ApiProperty({ description: '创建时间' })
date_created: string;
@ApiProperty({ description: '更新时间' })
date_modified: string;
@ApiProperty({ description: '产品链接', required: false })
permalink?: string;
@ApiProperty({
description: '原始数据(保留备用)',
type: 'object',
required: false,
})
raw?: Record<string, any>;
@ApiProperty({
description: 'ERP产品信息',
type: 'object',
required: false,
})
erpProduct?: {
id: number;
sku: string;
name: string;
nameCn?: string;
category?: any;
attributes?: any[];
components?: any[];
price: number;
promotionPrice: number;
};
}
export class UnifiedOrderDTO {
// 订单DTO用于承载统一订单数据
@ApiProperty({ description: '订单ID' })
id: string | number;
@ApiProperty({ description: '订单号' })
number: string;
@ApiProperty({ description: '订单状态' })
status: string;
@ApiProperty({ description: '货币' })
currency: string;
@ApiProperty({ description: '总金额' })
total: string;
@ApiProperty({ description: '客户ID' })
customer_id: number;
@ApiProperty({ description: '客户姓名' })
customer_name: string;
@ApiProperty({ description: '客户邮箱' })
email: string;
@ApiProperty({ description: '订单项(具体的商品)', type: () => [UnifiedOrderLineItemDTO] })
line_items: UnifiedOrderLineItemDTO[];
@ApiProperty({
description: '销售项(兼容前端)',
type: () => [UnifiedOrderLineItemDTO],
required: false,
})
sales?: UnifiedOrderLineItemDTO[];
@ApiProperty({ description: '账单地址', type: () => UnifiedAddressDTO })
billing: UnifiedAddressDTO;
@ApiProperty({ description: '收货地址', type: () => UnifiedAddressDTO })
shipping: UnifiedAddressDTO;
@ApiProperty({ description: '账单地址全称', required: false })
billing_full_address?: string;
@ApiProperty({ description: '收货地址全称', required: false })
shipping_full_address?: string;
@ApiProperty({ description: '支付方式' })
payment_method: string;
refunds: UnifiedOrderRefundDTO[];
@ApiProperty({ description: '创建时间' })
date_created: string;
@ApiProperty({ description: '更新时间', required: false })
date_modified?: string;
@ApiProperty({ description: '原始数据', type: 'object', required: false })
raw?: Record<string, any>;
}
export class UnifiedCustomerDTO {
// 客户DTO用于承载统一客户数据
@ApiProperty({ description: '客户ID' })
id: string | number;
@ApiProperty({ description: '头像URL', required: false })
avatar?: string;
@ApiProperty({ description: '邮箱' })
email: string;
@ApiProperty({ description: '订单总数', required: false })
orders?: number;
@ApiProperty({ description: '总花费', required: false })
total_spend?: number;
@ApiProperty({ description: '创建时间', required: false })
date_created?: string;
@ApiProperty({ description: '更新时间', required: false })
date_modified?: string;
@ApiProperty({ description: '名', required: false })
first_name?: string;
@ApiProperty({ description: '姓', required: false })
last_name?: string;
@ApiProperty({ description: '名字', required: false })
fullname?: string;
@ApiProperty({ description: '用户名', required: false })
username?: string;
@ApiProperty({ description: '电话', required: false })
phone?: string;
@ApiProperty({
description: '账单地址',
type: () => UnifiedAddressDTO,
required: false,
})
billing?: UnifiedAddressDTO;
@ApiProperty({
description: '收货地址',
type: () => UnifiedAddressDTO,
required: false,
})
shipping?: UnifiedAddressDTO;
@ApiProperty({ description: '原始数据', type: 'object', required: false })
raw?: Record<string, any>;
}
export class UnifiedSubscriptionDTO {
// 订阅DTO用于承载统一订阅数据
@ApiProperty({ description: '订阅ID' })
id: string | number;
@ApiProperty({ description: '订阅状态' })
status: string;
@ApiProperty({ description: '客户ID' })
customer_id: number;
@ApiProperty({ description: '计费周期' })
billing_period: string;
@ApiProperty({ description: '计费间隔' })
billing_interval: number;
@ApiProperty({ description: '创建时间', required: false })
date_created?: string;
@ApiProperty({ description: '更新时间', required: false })
date_modified?: string;
@ApiProperty({ description: '开始时间' })
start_date: string;
@ApiProperty({ description: '下次支付时间' })
next_payment_date: string;
@ApiProperty({ description: '订单项', type: () => [UnifiedOrderLineItemDTO] })
line_items: UnifiedOrderLineItemDTO[];
@ApiProperty({ description: '原始数据', type: 'object', required: false })
raw?: Record<string, any>;
}
export class UnifiedMediaDTO {
// 媒体DTO用于承载统一媒体数据
@ApiProperty({ description: '媒体ID' })
id: number;
@ApiProperty({ description: '标题' })
title: string;
@ApiProperty({ description: '媒体类型' })
media_type: string;
@ApiProperty({ description: 'MIME类型' })
mime_type: string;
@ApiProperty({ description: '源URL' })
source_url: string;
@ApiProperty({ description: '创建时间' })
date_created: string;
@ApiProperty({ description: '更新时间', required: false })
date_modified?: string;
}
export class UnifiedProductPaginationDTO extends UnifiedPaginationDTO<UnifiedProductDTO> {
// 产品分页DTO用于承载产品列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedProductDTO] })
items: UnifiedProductDTO[];
}
export class UnifiedOrderPaginationDTO extends UnifiedPaginationDTO<UnifiedOrderDTO> {
// 订单分页DTO用于承载订单列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedOrderDTO] })
items: UnifiedOrderDTO[];
}
export class UnifiedCustomerPaginationDTO extends UnifiedPaginationDTO<UnifiedCustomerDTO> {
// 客户分页DTO用于承载客户列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedCustomerDTO] })
items: UnifiedCustomerDTO[];
}
export class UnifiedSubscriptionPaginationDTO extends UnifiedPaginationDTO<UnifiedSubscriptionDTO> {
// 订阅分页DTO用于承载订阅列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedSubscriptionDTO] })
items: UnifiedSubscriptionDTO[];
}
export class UnifiedMediaPaginationDTO extends UnifiedPaginationDTO<UnifiedMediaDTO> {
// 媒体分页DTO用于承载媒体列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedMediaDTO] })
items: UnifiedMediaDTO[];
}
export class UnifiedReviewDTO {
// 评论DTO用于承载统一评论数据
@ApiProperty({ description: '评论ID' })
id: number | string;
@ApiProperty({ description: '产品ID' })
product_id: number | string;
@ApiProperty({ description: '评论者' })
author: string;
@ApiProperty({ description: '评论者邮箱' })
email: string;
@ApiProperty({ description: '评论内容' })
content: string;
@ApiProperty({ description: '评分' })
rating: number;
@ApiProperty({ description: '状态' })
status: string;
@ApiProperty({ description: '创建时间' })
date_created: string;
@ApiProperty({ description: '更新时间', required: false })
date_modified?: string;
@ApiProperty({ description: '原始数据', type: 'object', required: false })
raw?: Record<string, any>;
}
export class UnifiedReviewPaginationDTO extends UnifiedPaginationDTO<UnifiedReviewDTO> {
// 评论分页DTO用于承载评论列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedReviewDTO] })
items: UnifiedReviewDTO[];
}
export class CreateReviewDTO {
@ApiProperty({ description: '产品ID' })
product_id: number | string;
@ApiProperty({ description: '评论内容' })
review: string;
@ApiProperty({ description: '评论者' })
reviewer: string;
@ApiProperty({ description: '评论者邮箱' })
reviewer_email: string;
@ApiProperty({ description: '评分' })
rating: number;
}
export class UpdateReviewDTO {
@ApiProperty({ description: '评论内容', required: false })
review?: string;
@ApiProperty({ description: '评分', required: false })
rating?: number;
@ApiProperty({ description: '状态', required: false })
status?: string;
}
export class UploadMediaDTO {
@ApiProperty({ description: 'Base64 编码的文件内容' })
file: string;
@ApiProperty({ description: '文件名' })
filename: string;
}
export class UnifiedSearchParamsDTO<Where=Record<string, any>> {
// 统一查询参数DTO用于承载分页与筛选与排序参数
@ApiProperty({ description: '页码', example: 1, required: false })
page?: number;
@ApiProperty({ description: '每页数量', example: 20, required: false })
per_page?: number;
@ApiProperty({ description: '搜索关键词', required: false })
search?: string;
@ApiProperty({ description: '过滤条件对象', type: 'object', required: false })
where?: Where;
@ApiProperty({
description: '排序对象,例如 { "sku": "desc" }',
type: 'object',
required: false,
})
orderBy?: Record<string, 'asc' | 'desc'> | string;
}
export class UnifiedWebhookDTO {
// Webhook DTO用于承载统一webhook数据
@ApiProperty({ description: 'Webhook ID' })
id: number | string;
@ApiProperty({ description: '名称' })
name?: string;
@ApiProperty({ description: '状态' })
status: string;
@ApiProperty({ description: '主题/事件' })
topic: string;
@ApiProperty({ description: '目标URL' })
delivery_url: string;
@ApiProperty({ description: '秘密密钥' })
secret?: string;
@ApiProperty({ description: '创建时间' })
date_created?: string;
@ApiProperty({ description: '更新时间' })
date_modified?: string;
@ApiProperty({ description: '头部信息' })
headers?: Record<string, any>;
@ApiProperty({ description: 'API版本' })
api_version?: string;
}
export class UnifiedWebhookPaginationDTO extends UnifiedPaginationDTO<UnifiedWebhookDTO> {
// Webhook分页DTO用于承载webhook列表分页数据
@ApiProperty({ description: '列表数据', type: () => [UnifiedWebhookDTO] })
items: UnifiedWebhookDTO[];
}
export class CreateWebhookDTO {
// 创建Webhook DTO
@ApiProperty({ description: '名称' })
name?: string;
@ApiProperty({ description: '主题/事件' })
topic: string;
@ApiProperty({ description: '目标URL' })
delivery_url: string;
@ApiProperty({ description: '秘密密钥' })
secret?: string;
@ApiProperty({ description: '头部信息' })
headers?: Record<string, any>;
@ApiProperty({ description: 'API版本' })
api_version?: string;
}
export class UpdateWebhookDTO {
// 更新Webhook DTO
@ApiProperty({ description: '名称', required: false })
name?: string;
@ApiProperty({ description: '状态', required: false })
status?: string;
@ApiProperty({ description: '主题/事件', required: false })
topic?: string;
@ApiProperty({ description: '目标URL', required: false })
delivery_url?: string;
@ApiProperty({ description: '秘密密钥', required: false })
secret?: string;
@ApiProperty({ description: '头部信息', required: false })
headers?: Record<string, any>;
@ApiProperty({ description: 'API版本', required: false })
api_version?: string;
}
export class UnifiedOrderRefundDTO {
@ApiProperty({ description: '退款ID' })
id: number | string;
@ApiProperty({ description: '退款原因' })
reason: string;
@ApiProperty({ description: '退款金额' })
total: string;
}
export class ShipOrderItemDTO {
@ApiProperty({ description: '订单项ID' })
order_item_id: number;
@ApiProperty({ description: '数量' })
quantity: number;
}
export class ShipOrderDTO {
@ApiProperty({ description: '物流单号', required: false })
tracking_number?: string;
@ApiProperty({ description: '物流公司', required: false })
shipping_provider?: string;
@ApiProperty({ description: '发货方式', required: false })
shipping_method?: string;
@ApiProperty({ description: '发货商品项', type: () => [ShipOrderItemDTO], required: false })
items?: ShipOrderItemDTO[];
}
export class CancelShipOrderDTO {
@ApiProperty({ description: '取消原因', required: false })
reason?: string;
@ApiProperty({ description: '发货单ID', required: false })
shipment_id?: string;
}
export class BatchShipOrderItemDTO {
@ApiProperty({ description: '订单ID' })
order_id: string;
@ApiProperty({ description: '物流单号', required: false })
tracking_number?: string;
@ApiProperty({ description: '物流公司', required: false })
shipping_provider?: string;
@ApiProperty({ description: '发货方式', required: false })
shipping_method?: string;
@ApiProperty({ description: '发货商品项', type: () => [ShipOrderItemDTO], required: false })
items?: ShipOrderItemDTO[];
}
export class BatchShipOrdersDTO {
@ApiProperty({ description: '批量发货订单列表', type: () => [BatchShipOrderItemDTO] })
orders: BatchShipOrderItemDTO[];
}