|
@@ -14,7 +14,7 @@ const PrintTaskListQuerySchema = z.object({
|
|
|
orderId: z.string().optional().transform(val => val ? parseInt(val, 10) : undefined),
|
|
orderId: z.string().optional().transform(val => val ? parseInt(val, 10) : undefined),
|
|
|
printerSn: z.string().optional(),
|
|
printerSn: z.string().optional(),
|
|
|
printType: z.enum(['RECEIPT', 'SHIPPING', 'ORDER', 'ALL']).optional().default('ALL').transform(val => val === 'ALL' ? undefined : val as PrintType),
|
|
printType: z.enum(['RECEIPT', 'SHIPPING', 'ORDER', 'ALL']).optional().default('ALL').transform(val => val === 'ALL' ? undefined : val as PrintType),
|
|
|
- status: z.enum(['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED', 'CANCELLED', 'ALL']).optional().default('ALL').transform(val => val === 'ALL' ? undefined : val as PrintStatus),
|
|
|
|
|
|
|
+ status: z.enum(['PENDING', 'DELAYED', 'PRINTING', 'SUCCESS', 'FAILED', 'CANCELLED', 'ALL']).optional().default('ALL').transform(val => val === 'ALL' ? undefined : val as PrintStatus),
|
|
|
startDate: z.string().optional().transform(val => val ? new Date(val) : undefined),
|
|
startDate: z.string().optional().transform(val => val ? new Date(val) : undefined),
|
|
|
endDate: z.string().optional().transform(val => val ? new Date(val) : undefined),
|
|
endDate: z.string().optional().transform(val => val ? new Date(val) : undefined),
|
|
|
search: z.string().optional()
|
|
search: z.string().optional()
|
|
@@ -25,16 +25,20 @@ const PrintTaskListResponseSchema = z.object({
|
|
|
success: z.boolean(),
|
|
success: z.boolean(),
|
|
|
data: z.object({
|
|
data: z.object({
|
|
|
data: z.array(z.object({
|
|
data: z.array(z.object({
|
|
|
|
|
+ id: z.number(),
|
|
|
taskId: z.string(),
|
|
taskId: z.string(),
|
|
|
tenantId: z.number(),
|
|
tenantId: z.number(),
|
|
|
printerSn: z.string(),
|
|
printerSn: z.string(),
|
|
|
orderId: z.number().nullable(),
|
|
orderId: z.number().nullable(),
|
|
|
printType: z.nativeEnum(PrintType),
|
|
printType: z.nativeEnum(PrintType),
|
|
|
content: z.string(),
|
|
content: z.string(),
|
|
|
- copies: z.number(),
|
|
|
|
|
- priority: z.enum(['HIGH', 'NORMAL', 'LOW']),
|
|
|
|
|
printStatus: z.nativeEnum(PrintStatus),
|
|
printStatus: z.nativeEnum(PrintStatus),
|
|
|
errorMessage: z.string().nullable(),
|
|
errorMessage: z.string().nullable(),
|
|
|
|
|
+ retryCount: z.number(),
|
|
|
|
|
+ maxRetries: z.number(),
|
|
|
|
|
+ scheduledAt: z.string().nullable(),
|
|
|
|
|
+ printedAt: z.string().nullable(),
|
|
|
|
|
+ cancelledAt: z.string().nullable(),
|
|
|
createdAt: z.string(),
|
|
createdAt: z.string(),
|
|
|
updatedAt: z.string()
|
|
updatedAt: z.string()
|
|
|
})),
|
|
})),
|
|
@@ -101,11 +105,21 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
const printTaskService = new PrintTaskService(AppDataSource, feieConfig);
|
|
const printTaskService = new PrintTaskService(AppDataSource, feieConfig);
|
|
|
const result = await printTaskService.getPrintTasks(tenantId, filters, page, limit);
|
|
const result = await printTaskService.getPrintTasks(tenantId, filters, page, limit);
|
|
|
|
|
|
|
|
|
|
+ // 转换Date对象为ISO字符串
|
|
|
|
|
+ const transformedTasks = result.tasks.map(task => ({
|
|
|
|
|
+ ...task,
|
|
|
|
|
+ createdAt: task.createdAt.toISOString(),
|
|
|
|
|
+ updatedAt: task.updatedAt.toISOString(),
|
|
|
|
|
+ scheduledAt: task.scheduledAt ? task.scheduledAt.toISOString() : null,
|
|
|
|
|
+ printedAt: task.printedAt ? task.printedAt.toISOString() : null,
|
|
|
|
|
+ cancelledAt: task.cancelledAt ? task.cancelledAt.toISOString() : null
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
// 验证响应格式
|
|
// 验证响应格式
|
|
|
const response = {
|
|
const response = {
|
|
|
success: true as const,
|
|
success: true as const,
|
|
|
data: {
|
|
data: {
|
|
|
- data: result.tasks,
|
|
|
|
|
|
|
+ data: transformedTasks,
|
|
|
total: result.total,
|
|
total: result.total,
|
|
|
page,
|
|
page,
|
|
|
pageSize: limit
|
|
pageSize: limit
|