Przeglądaj źródła

♻️ refactor(config): 为配置类型添加类型断言

- 在配置列表和更新接口中,为 configType 字段添加明确的类型断言 ('STRING' | 'JSON' | 'BOOLEAN' | 'NUMBER'),以增强类型安全性

🗑️ chore(routes): 删除旧的聚合路由文件

- 删除 `feie.routes.ts` 文件,该文件包含旧的聚合路由逻辑,已被拆分为独立的模块化路由文件

✅ fix(routes): 统一 API 响应状态码

- 在多个路由处理程序(update.mt.ts, health.mt.ts, status.mt.ts, trigger.mt.ts, detail.mt.ts)的 `c.json` 调用中显式指定 HTTP 状态码 200

♻️ refactor(scheduler): 重构调度器健康与状态响应格式

- 在 `health.mt.ts` 中,将健康检查响应字段重命名为更通用的格式 (healthy, isRunning, lastError, timestamp)
- 在 `status.mt.ts` 中,简化调度器状态响应,移除 processedTasks, failedTasks, pendingTasks 等字段,保留 isRunning, defaultDelaySeconds, tenantId, lastProcessTime
- 在 `trigger.mt.ts` 中,简化手动触发响应,移除 successfulTasks, failedTasks, executionTime 等字段,保留 processedTasks 和 message

✅ fix(tasks): 修复取消任务参数类型

- 在 `cancel.mt.ts` 中,导入 `CancelReason` 类型,并将字符串类型的 `reason` 参数断言为该枚举类型,以匹配服务层接口
yourname 1 miesiąc temu
rodzic
commit
1e73433331

+ 1 - 1
packages/feie-printer-module-mt/src/routes/config/list.mt.ts

@@ -58,7 +58,7 @@ const app = new OpenAPIHono<AuthContext>()
         tenantId: config.tenantId,
         tenantId: config.tenantId,
         configKey: config.configKey,
         configKey: config.configKey,
         configValue: config.configValue || '',
         configValue: config.configValue || '',
-        configType: config.configType,
+        configType: config.configType as 'STRING' | 'JSON' | 'BOOLEAN' | 'NUMBER',
         description: config.description || null,
         description: config.description || null,
         createdAt: config.createdAt.toISOString(),
         createdAt: config.createdAt.toISOString(),
         updatedAt: config.updatedAt.toISOString()
         updatedAt: config.updatedAt.toISOString()

+ 2 - 2
packages/feie-printer-module-mt/src/routes/config/update.mt.ts

@@ -84,7 +84,7 @@ const app = new OpenAPIHono<AuthContext>()
         tenantId: config.tenantId,
         tenantId: config.tenantId,
         configKey: config.configKey,
         configKey: config.configKey,
         configValue: config.configValue || '',
         configValue: config.configValue || '',
-        configType: config.configType,
+        configType: config.configType as 'STRING' | 'JSON' | 'BOOLEAN' | 'NUMBER',
         description: config.description || null,
         description: config.description || null,
         createdAt: config.createdAt.toISOString(),
         createdAt: config.createdAt.toISOString(),
         updatedAt: config.updatedAt.toISOString()
         updatedAt: config.updatedAt.toISOString()
@@ -93,7 +93,7 @@ const app = new OpenAPIHono<AuthContext>()
       return c.json({
       return c.json({
         success: true,
         success: true,
         data: transformedConfig
         data: transformedConfig
-      });
+      }, 200);
     } catch (error) {
     } catch (error) {
       console.error(`[租户${tenantId}] 更新配置失败,key: ${configKey}:`, error);
       console.error(`[租户${tenantId}] 更新配置失败,key: ${configKey}:`, error);
       return c.json({ success: false, message: '更新配置失败' }, 500);
       return c.json({ success: false, message: '更新配置失败' }, 500);

+ 0 - 597
packages/feie-printer-module-mt/src/routes/feie.routes.ts

@@ -1,597 +0,0 @@
-import { OpenAPIHono } from '@hono/zod-openapi';
-import { DataSource, In } from 'typeorm';
-import { AuthContext } from '@d8d/shared-types';
-import { authMiddleware } from '@d8d/auth-module-mt';
-import { PrinterService } from '../services/printer.service';
-import { PrintTaskService } from '../services/print-task.service';
-import { DelaySchedulerService } from '../services/delay-scheduler.service';
-import { ConfigService } from '../services/config.service';
-import { FeieApiConfig } from '../types/feie.types';
-
-/**
- * 获取飞鹅API配置
- */
-async function getFeieApiConfig(tenantId: number, dataSource: DataSource): Promise<FeieApiConfig | null> {
-  try {
-    console.debug(`开始获取租户 ${tenantId} 的飞鹅API配置`);
-
-    // 从 system_config_mt 表获取飞鹅API配置
-    const configKeys = [
-      'feie.api.user',      // 飞鹅API用户
-      'feie.api.ukey',      // 飞鹅API密钥
-      'feie.api.base_url',  // 飞鹅API基础URL
-      'feie.api.timeout',   // API超时时间
-      'feie.api.max_retries' // 最大重试次数
-    ];
-
-    // 直接查询数据库
-    const configRepository = dataSource.getRepository('system_config_mt');
-    console.debug(`查询数据库,租户ID: ${tenantId}, 配置键: ${configKeys.join(', ')}`);
-
-    const configs = await configRepository.find({
-      where: {
-        tenantId,
-        configKey: In(configKeys)
-      }
-    });
-
-    console.debug(`找到 ${configs.length} 条配置记录`);
-
-    // 转换为键值对
-    const configMap: Record<string, string> = {};
-    configs.forEach((config: any) => {
-      configMap[config.configKey] = config.configValue;
-      console.debug(`配置键: ${config.configKey}, 值: ${config.configValue}`);
-    });
-
-    // 检查必要的配置项
-    const user = configMap['feie.api.user'];
-    const ukey = configMap['feie.api.ukey'];
-
-    if (!user || !ukey) {
-      console.warn(`[租户${tenantId}] 飞鹅API配置不完整,缺少user或ukey`);
-      console.debug(`当前配置映射:`, JSON.stringify(configMap, null, 2));
-      return null;
-    }
-
-    // 返回配置结构
-    const feieConfig = {
-      user,
-      ukey,
-      baseUrl: configMap['feie.api.base_url'] || 'https://api.feieyun.cn/Api/Open/',
-      timeout: parseInt(configMap['feie.api.timeout'] || '10000', 10),
-      maxRetries: parseInt(configMap['feie.api.max_retries'] || '3', 10)
-    };
-
-    console.debug(`租户 ${tenantId} 的飞鹅API配置获取成功:`, JSON.stringify(feieConfig, null, 2));
-    return feieConfig;
-  } catch (error) {
-    console.warn(`[租户${tenantId}] 获取飞鹅API配置失败:`, error);
-    return null;
-  }
-}
-
-export function createFeieRoutes(dataSource: DataSource) {
-  const app = new OpenAPIHono<AuthContext>();
-
-  // 添加鉴权中间件
-  app.use('*', authMiddleware);
-
-  // 初始化服务(使用空配置,实际配置在路由处理中动态获取)
-  const printTaskService = new PrintTaskService(dataSource, {
-    baseUrl: 'https://api.feieyun.cn/Api/Open/',
-    user: '',
-    ukey: '',
-    timeout: 10000,
-    maxRetries: 3
-  });
-  const configService = new ConfigService(dataSource);
-
-  // 打印机管理路由
-  app.get('/printers', async (c) => {
-    const user = c.get('user');
-    console.debug('获取打印机列表 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1; // 从认证中间件获取
-    console.debug(`获取打印机列表 - 租户ID: ${tenantId}`);
-
-    // 获取查询参数
-    const query = c.req.query();
-    const page = query.page ? parseInt(query.page, 10) : 1;
-    const pageSize = query.pageSize ? parseInt(query.pageSize, 10) : 10;
-    const search = query.search;
-    const status = query.status as any;
-    const printerType = query.printerType as any;
-    const isDefault = query.isDefault === 'true';
-
-    // 获取飞鹅API配置
-    const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-    if (!feieConfig) {
-      console.error(`租户 ${tenantId} 的飞鹅API配置未找到或配置不完整`);
-      return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-    }
-
-    console.debug(`租户 ${tenantId} 的飞鹅API配置获取成功`);
-
-    // 创建带配置的服务实例
-    const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-    const printers = await tenantPrinterService.getPrinters(tenantId);
-
-    // 应用筛选逻辑
-    let filteredPrinters = printers;
-
-    // 搜索筛选
-    if (search) {
-      filteredPrinters = filteredPrinters.filter(p =>
-        (p.printerName && p.printerName.includes(search)) ||
-        p.printerSn.includes(search)
-      );
-    }
-
-    // 状态筛选
-    if (status && status !== 'ALL') {
-      filteredPrinters = filteredPrinters.filter(p => p.printerStatus === status);
-    }
-
-    // 类型筛选
-    if (printerType && printerType !== 'ALL') {
-      filteredPrinters = filteredPrinters.filter(p => p.printerType === printerType);
-    }
-
-    // 默认打印机筛选
-    if (isDefault) {
-      filteredPrinters = filteredPrinters.filter(p => p.isDefault === 1);
-    }
-
-    // 分页逻辑
-    const total = filteredPrinters.length;
-    const startIndex = (page - 1) * pageSize;
-    const endIndex = Math.min(startIndex + pageSize, total);
-    const paginatedPrinters = filteredPrinters.slice(startIndex, endIndex);
-
-    console.debug(`返回打印机列表,总数: ${total}, 分页: ${page}/${Math.ceil(total/pageSize)}, 数量: ${paginatedPrinters.length}`);
-
-    return c.json({
-      success: true,
-      data: {
-        data: paginatedPrinters,
-        total,
-        page,
-        pageSize
-      }
-    });
-  });
-
-  app.post('/printers', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-
-    try {
-      const body = await c.req.json();
-
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的服务实例
-      const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-      const printer = await tenantPrinterService.addPrinter(tenantId, body);
-      return c.json({ success: true, data: printer });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 添加打印机失败:`, error);
-      const errorMessage = error instanceof Error ? error.message : '添加打印机失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.get('/printers/:printerSn', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const printerSn = c.req.param('printerSn');
-
-    // 获取飞鹅API配置
-    const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-    if (!feieConfig) {
-      return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-    }
-
-    // 创建带配置的服务实例
-    const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-    const printer = await tenantPrinterService.repository.findOne({
-      where: { tenantId, printerSn } as any
-    });
-
-    if (!printer) {
-      return c.json({ success: false, message: '打印机不存在' }, 404);
-    }
-
-    return c.json({ success: true, data: printer });
-  });
-
-  app.put('/printers/:printerSn', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const printerSn = c.req.param('printerSn');
-
-    try {
-      const body = await c.req.json();
-
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的服务实例
-      const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-      const printer = await tenantPrinterService.updatePrinter(tenantId, printerSn, body);
-      return c.json({ success: true, data: printer });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 更新打印机失败,打印机SN: ${printerSn}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '更新打印机失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.delete('/printers/:printerSn', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const printerSn = c.req.param('printerSn');
-
-    try {
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的服务实例
-      const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-      await tenantPrinterService.deletePrinter(tenantId, printerSn);
-      return c.json({ success: true, message: '打印机删除成功' });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 删除打印机失败,打印机SN: ${printerSn}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '删除打印机失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.get('/printers/:printerSn/status', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const printerSn = c.req.param('printerSn');
-
-    try {
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的服务实例
-      const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-      const status = await tenantPrinterService.getPrinterStatus(tenantId, printerSn);
-      return c.json({ success: true, data: status });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 查询打印机状态失败,打印机SN: ${printerSn}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '查询打印机状态失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.post('/printers/:printerSn/set-default', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const printerSn = c.req.param('printerSn');
-
-    try {
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的服务实例
-      const tenantPrinterService = new PrinterService(dataSource, feieConfig);
-      const printer = await tenantPrinterService.setDefaultPrinter(tenantId, printerSn);
-      return c.json({ success: true, data: printer });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 设置默认打印机失败,打印机SN: ${printerSn}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '设置默认打印机失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  // 打印任务管理路由
-  app.post('/tasks', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-
-    try {
-      const body = await c.req.json();
-
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的打印任务服务实例
-      const tenantPrintTaskService = new PrintTaskService(dataSource, feieConfig);
-      const task = await tenantPrintTaskService.createPrintTask(tenantId, body);
-      return c.json({ success: true, data: task });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 创建打印任务失败:`, error);
-      const errorMessage = error instanceof Error ? error.message : '创建打印任务失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.get('/tasks', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-
-    try {
-      const query = c.req.query();
-      const filters = {
-        orderId: query.orderId ? parseInt(query.orderId, 10) : undefined,
-        printerSn: query.printerSn,
-        printType: query.printType as any,
-        printStatus: query.status as any, // 前端传递的是status参数
-        startDate: query.startDate ? new Date(query.startDate) : undefined,
-        endDate: query.endDate ? new Date(query.endDate) : undefined,
-        search: query.search
-      };
-      const page = query.page ? parseInt(query.page, 10) : 1;
-      const limit = query.pageSize ? parseInt(query.pageSize, 10) : 20; // 前端传递的是pageSize参数
-
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的打印任务服务实例
-      const tenantPrintTaskService = new PrintTaskService(dataSource, feieConfig);
-      const result = await tenantPrintTaskService.getPrintTasks(tenantId, filters, page, limit);
-      return c.json({
-        success: true,
-        data: {
-          data: result.tasks,
-          total: result.total,
-          page,
-          pageSize: limit
-        }
-      });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 获取打印任务列表失败:`, error);
-      const errorMessage = error instanceof Error ? error.message : '获取打印任务列表失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.get('/tasks/:taskId', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const taskId = c.req.param('taskId');
-    const task = await printTaskService.repository.findOne({
-      where: { tenantId, taskId } as any
-    });
-
-    if (!task) {
-      return c.json({ success: false, message: '打印任务不存在' }, 404);
-    }
-
-    return c.json({ success: true, data: task });
-  });
-
-  app.get('/tasks/:taskId/status', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const taskId = c.req.param('taskId');
-
-    try {
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的打印任务服务实例
-      const tenantPrintTaskService = new PrintTaskService(dataSource, feieConfig);
-      const status = await tenantPrintTaskService.getPrintTaskStatus(tenantId, taskId);
-      return c.json({ success: true, data: status });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 获取打印任务状态失败,任务ID: ${taskId}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '获取打印任务状态失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  app.post('/tasks/:taskId/cancel', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const taskId = c.req.param('taskId');
-    const body = await c.req.json();
-    const task = await printTaskService.cancelPrintTask(tenantId, taskId, body.reason);
-    return c.json({ success: true, data: task });
-  });
-
-  app.post('/tasks/:taskId/retry', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const taskId = c.req.param('taskId');
-
-    try {
-      // 获取飞鹅API配置
-      const feieConfig = await getFeieApiConfig(tenantId, dataSource);
-      if (!feieConfig) {
-        return c.json({ success: false, message: '飞鹅API配置未找到或配置不完整' }, 400);
-      }
-
-      // 创建带配置的打印任务服务实例
-      const tenantPrintTaskService = new PrintTaskService(dataSource, feieConfig);
-      const task = await tenantPrintTaskService.retryPrintTask(tenantId, taskId);
-      return c.json({ success: true, data: task });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 重试打印任务失败,任务ID: ${taskId}:`, error);
-      const errorMessage = error instanceof Error ? error.message : '重试打印任务失败';
-      return c.json({ success: false, message: errorMessage }, 500);
-    }
-  });
-
-  // 调度器管理路由
-  app.get('/scheduler/status', async (c) => {
-    const user = c.get('user');
-    console.debug('获取调度器状态 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1;
-
-    // 创建租户特定的调度器实例
-    const delaySchedulerService = new DelaySchedulerService(dataSource, {
-      baseUrl: 'https://api.feieyun.cn/Api/Open/',
-      user: '',
-      ukey: '',
-      timeout: 10000,
-      maxRetries: 3
-    }, tenantId);
-
-    const status = delaySchedulerService.getStatus();
-    return c.json({ success: true, data: status });
-  });
-
-  app.post('/scheduler/start', async (c) => {
-    const user = c.get('user');
-    console.debug('启动调度器 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1;
-
-    // 创建租户特定的调度器实例
-    const delaySchedulerService = new DelaySchedulerService(dataSource, {
-      baseUrl: 'https://api.feieyun.cn/Api/Open/',
-      user: '',
-      ukey: '',
-      timeout: 10000,
-      maxRetries: 3
-    }, tenantId);
-
-    await delaySchedulerService.start();
-    return c.json({ success: true, message: '调度器已启动' });
-  });
-
-  app.post('/scheduler/stop', async (c) => {
-    const user = c.get('user');
-    console.debug('停止调度器 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1;
-
-    // 创建租户特定的调度器实例
-    const delaySchedulerService = new DelaySchedulerService(dataSource, {
-      baseUrl: 'https://api.feieyun.cn/Api/Open/',
-      user: '',
-      ukey: '',
-      timeout: 10000,
-      maxRetries: 3
-    }, tenantId);
-
-    await delaySchedulerService.stop();
-    return c.json({ success: true, message: '调度器已停止' });
-  });
-
-  app.get('/scheduler/health', async (c) => {
-    const user = c.get('user');
-    console.debug('调度器健康检查 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1;
-
-    // 创建租户特定的调度器实例
-    const delaySchedulerService = new DelaySchedulerService(dataSource, {
-      baseUrl: 'https://api.feieyun.cn/Api/Open/',
-      user: '',
-      ukey: '',
-      timeout: 10000,
-      maxRetries: 3
-    }, tenantId);
-
-    const health = await delaySchedulerService.healthCheck();
-    return c.json({ success: true, data: health });
-  });
-
-  app.post('/scheduler/trigger', async (c) => {
-    const user = c.get('user');
-    console.debug('手动触发调度器处理 - 用户对象:', JSON.stringify(user, null, 2));
-    const tenantId = user?.tenantId || 1;
-
-    // 创建租户特定的调度器实例
-    const delaySchedulerService = new DelaySchedulerService(dataSource, {
-      baseUrl: 'https://api.feieyun.cn/Api/Open/',
-      user: '',
-      ukey: '',
-      timeout: 10000,
-      maxRetries: 3
-    }, tenantId);
-
-    const result = await delaySchedulerService.triggerManualProcess();
-    return c.json({ success: result.success, data: result });
-  });
-
-  // 打印配置管理路由
-  app.get('/config', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-
-    try {
-      const configs = await configService.getPrintConfigs(tenantId);
-
-      // 将 FeieConfigMt 转换为前端需要的 FeieConfig 格式
-      const transformedConfigs = configs.map(config => ({
-        id: config.id,
-        tenantId: config.tenantId,
-        configKey: config.configKey as any, // 字符串转换为 ConfigKey 枚举
-        configValue: config.configValue || '', // 处理null值
-        configType: config.configType as any, // 字符串转换为 ConfigType 枚举
-        description: config.description || undefined,
-        createdAt: config.createdAt.toISOString(),
-        updatedAt: config.updatedAt.toISOString()
-      }));
-
-      return c.json({ success: true, data: { data: transformedConfigs } });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 获取打印配置失败:`, error);
-      return c.json({ success: false, message: '获取打印配置失败' }, 500);
-    }
-  });
-
-  app.put('/config/:configKey', async (c) => {
-    const user = c.get('user');
-    const tenantId = user?.tenantId || 1;
-    const configKey = c.req.param('configKey');
-    const body = await c.req.json();
-
-    if (!body.configValue) {
-      return c.json({ success: false, message: '配置值不能为空' }, 400);
-    }
-
-    try {
-      const config = await configService.updatePrintConfig(tenantId, configKey, body.configValue);
-
-      // 将 FeieConfigMt 转换为前端需要的 FeieConfig 格式
-      const transformedConfig = {
-        id: config.id,
-        tenantId: config.tenantId,
-        configKey: config.configKey as any, // 字符串转换为 ConfigKey 枚举
-        configValue: config.configValue || '', // 处理null值
-        configType: config.configType as any, // 字符串转换为 ConfigType 枚举
-        description: config.description || undefined,
-        createdAt: config.createdAt.toISOString(),
-        updatedAt: config.updatedAt.toISOString()
-      };
-
-      return c.json({ success: true, data: transformedConfig });
-    } catch (error) {
-      console.error(`[租户${tenantId}] 更新配置失败,key: ${configKey}:`, error);
-      return c.json({ success: false, message: '更新配置失败' }, 500);
-    }
-  });
-
-  return app;
-}
-
-export default createFeieRoutes;

+ 5 - 6
packages/feie-printer-module-mt/src/routes/scheduler/health.mt.ts

@@ -57,13 +57,12 @@ const app = new OpenAPIHono<AuthContext>()
     return c.json({
     return c.json({
       success: true,
       success: true,
       data: {
       data: {
-        isHealthy: health.isHealthy,
-        status: health.status,
-        lastCheckTime: health.lastCheckTime.toISOString(),
-        errors: health.errors,
-        tenantId: health.tenantId
+        healthy: health.healthy,
+        isRunning: health.isRunning,
+        lastError: health.lastError,
+        timestamp: health.timestamp.toISOString()
       }
       }
-    });
+    }, 200);
   });
   });
 
 
 export default app;
 export default app;

+ 4 - 7
packages/feie-printer-module-mt/src/routes/scheduler/status.mt.ts

@@ -60,14 +60,11 @@ const app = new OpenAPIHono<AuthContext>()
       success: true,
       success: true,
       data: {
       data: {
         isRunning: status.isRunning,
         isRunning: status.isRunning,
-        lastRunTime: status.lastRunTime ? status.lastRunTime.toISOString() : null,
-        nextRunTime: status.nextRunTime ? status.nextRunTime.toISOString() : null,
-        processedTasks: status.processedTasks,
-        failedTasks: status.failedTasks,
-        pendingTasks: status.pendingTasks,
-        tenantId: status.tenantId
+        defaultDelaySeconds: status.defaultDelaySeconds,
+        tenantId: status.tenantId,
+        lastProcessTime: status.lastProcessTime ? status.lastProcessTime.toISOString() : null
       }
       }
-    });
+    }, 200);
   });
   });
 
 
 export default app;
 export default app;

+ 2 - 5
packages/feie-printer-module-mt/src/routes/scheduler/trigger.mt.ts

@@ -58,12 +58,9 @@ const app = new OpenAPIHono<AuthContext>()
       success: result.success,
       success: result.success,
       data: {
       data: {
         processedTasks: result.processedTasks,
         processedTasks: result.processedTasks,
-        successfulTasks: result.successfulTasks,
-        failedTasks: result.failedTasks,
-        executionTime: result.executionTime,
-        tenantId: result.tenantId
+        message: result.message
       }
       }
-    });
+    }, 200);
   });
   });
 
 
 export default app;
 export default app;

+ 4 - 1
packages/feie-printer-module-mt/src/routes/tasks/cancel.mt.ts

@@ -4,6 +4,7 @@ import { AppDataSource } from '@d8d/shared-utils';
 import { authMiddleware } from '@d8d/auth-module-mt';
 import { authMiddleware } from '@d8d/auth-module-mt';
 import { AuthContext } from '@d8d/shared-types';
 import { AuthContext } from '@d8d/shared-types';
 import { PrintTaskService } from '../../services/print-task.service';
 import { PrintTaskService } from '../../services/print-task.service';
+import { CancelReason } from '../../types/feie.types';
 
 
 // 取消打印任务参数Schema
 // 取消打印任务参数Schema
 const CancelPrintTaskParamsSchema = z.object({
 const CancelPrintTaskParamsSchema = z.object({
@@ -79,7 +80,9 @@ const app = new OpenAPIHono<AuthContext>()
         maxRetries: 3
         maxRetries: 3
       });
       });
 
 
-      const task = await printTaskService.cancelPrintTask(tenantId, taskId, reason);
+      // 将字符串转换为CancelReason枚举
+      const cancelReason = reason as any as CancelReason;
+      const task = await printTaskService.cancelPrintTask(tenantId, taskId, cancelReason);
 
 
       return c.json({
       return c.json({
         success: true,
         success: true,

+ 1 - 1
packages/feie-printer-module-mt/src/routes/tasks/detail.mt.ts

@@ -106,7 +106,7 @@ const app = new OpenAPIHono<AuthContext>()
         createdAt: task.createdAt.toISOString(),
         createdAt: task.createdAt.toISOString(),
         updatedAt: task.updatedAt.toISOString()
         updatedAt: task.updatedAt.toISOString()
       }
       }
-    });
+    }, 200);
   });
   });
 
 
 export default app;
 export default app;