|
|
@@ -5,6 +5,7 @@ import { authMiddleware } from '@d8d/auth-module-mt';
|
|
|
import { AuthContext } from '@d8d/shared-types';
|
|
|
import { PrintTaskService } from '../../services/print-task.service';
|
|
|
import { getFeieApiConfig } from '../utils/feie-config.util';
|
|
|
+import { PrintType, PrintStatus } from '../../types/feie.types';
|
|
|
|
|
|
// 打印任务列表查询参数Schema
|
|
|
const PrintTaskListQuerySchema = z.object({
|
|
|
@@ -12,8 +13,8 @@ const PrintTaskListQuerySchema = z.object({
|
|
|
pageSize: z.string().optional().transform(val => val ? parseInt(val, 10) : 20),
|
|
|
orderId: z.string().optional().transform(val => val ? parseInt(val, 10) : undefined),
|
|
|
printerSn: z.string().optional(),
|
|
|
- printType: z.enum(['RECEIPT', 'LABEL', 'ALL']).optional().default('ALL'),
|
|
|
- status: z.enum(['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED', 'CANCELLED', 'ALL']).optional().default('ALL'),
|
|
|
+ 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),
|
|
|
startDate: 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()
|
|
|
@@ -28,11 +29,11 @@ const PrintTaskListResponseSchema = z.object({
|
|
|
tenantId: z.number(),
|
|
|
printerSn: z.string(),
|
|
|
orderId: z.number().nullable(),
|
|
|
- printType: z.enum(['RECEIPT', 'LABEL']),
|
|
|
+ printType: z.nativeEnum(PrintType),
|
|
|
content: z.string(),
|
|
|
copies: z.number(),
|
|
|
priority: z.enum(['HIGH', 'NORMAL', 'LOW']),
|
|
|
- printStatus: z.enum(['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED', 'CANCELLED']),
|
|
|
+ printStatus: z.nativeEnum(PrintStatus),
|
|
|
errorMessage: z.string().nullable(),
|
|
|
createdAt: z.string(),
|
|
|
updatedAt: z.string()
|
|
|
@@ -112,7 +113,7 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
};
|
|
|
const validatedResponse = await parseWithAwait(PrintTaskListResponseSchema, response);
|
|
|
|
|
|
- return c.json(validatedResponse);
|
|
|
+ return c.json(validatedResponse, 200);
|
|
|
} catch (error) {
|
|
|
console.error(`[租户${tenantId}] 获取打印任务列表失败:`, error);
|
|
|
const errorMessage = error instanceof Error ? error.message : '获取打印任务列表失败';
|