export const pathMap = {
  //查询接口
  findByPodProductionNo: {
    CN: "factory/podJomallOrderProductCn/getProductCnByFactorySubOrderNumber",
    US: "factory/podJomallOrderProductUs/getProductUsByFactorySubOrderNumber",
    GC: "factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber",
    OP: "factory/podOrderOperation/getByOperationNo"
  },
  //下载素材接口
  downloadBySubOrderNumber: {
    CN: "factory/podJomallOrderProductCn/downloadDesignImages",
    US: "factory/podJomallOrderProductUs/downloadDesignImages",
    GC: "factory/podJomallOrder/downloadByProduction",
    OP: "factory/podOrderOperation/downloadDesignImages",
    USHLC: "factory/podJomallOrderProductUs/downloadCompatibleDesignImages",
    CNHLC: "factory/podJomallOrderProductCn/downloadCompatibleDesignImages",
    OPHLC: "factory/podOrderOperation/downloadCompatibleDesignImages"
  },
  //生产完成接口
  completeDelivery: {
    CN: "factory/podJomallOrderProductCn/completeDelivery",
    US: "factory/podJomallOrderProductUs/completeDelivery",
    GC: "factory/podJomallOrderProduct/completeDelivery",
    OP: "factory/podOrderOperation/printerCompleteDelivery",
    DTF: "factory/podOrderOperation/completeDelivery"
  },
  //惠立彩素材下载接口
  processTransparentBackground: {
    CN: "factory/podJomallOrderProductCn/processTransparentBackground",
    US: "factory/podJomallOrderProductUs/processTransparentBackground"
  },
  //判断 status 操作单状态
  scanProduce: {
    OP: "factory/podOrderOperation/scan-produce"
  },
  checkInventory: {
    OP: "factory/podOrderOperation/check-inventory"
  },
  //烫画
  //获取生产配置
  productionConfig: "factory/production-config/get",
  //更新生产配置
  productionConfigUpdate: "factory/production-config/update",
  //排版列表（分页）
  productionSoftware: "factory/podOrderBatchDownload/page-production-software",
  //查询该批次下的所有素材
  listMaterialsByBatch: "factory/podOrderBatchDownload/list-materials-by-batch",
  //重新合成排版
  psReComposingDesignImages:
    "factory/podOrderBatchDownload/psReComposingDesignImages",
  //根据批次分页查询操作单
  listOperationByBatch: "factory/podOrderBatchDownload/listOperationByBatch",
  //排版
  replenishmentComposingDesignImages:
    "factory/podOrderOperation/replenishmentComposingDesignImages",
  //获取单个批次号信息
  podOrderBatchDownload: "factory/podOrderBatchDownload/get",
  //操作日志
  getPodOrderLog: "factory/podOrderLog/getPodOrderLog"
};
// 操作单状态枚举
export const statusMap = {
  待排单: "PENDING_SCHEDULE",
  待拣胚: "PENDING_PICK",
  待补胚: "PENDING_REPLENISH",
  生产中: "IN_PRODUCTION",
  待配货: "PENDING_PACKING",
  配货完成: "PACKING_COMPLETED",
  已完成: "COMPLETED",
  已取消: "CANCELLED",
  已归档: "ARCHIVE"
};

export function autoRegisterRouter(router, funcKey, handler) {
  const pathConfig = pathMap[funcKey];
  // 根据类型收集所有需要注册的接口路径
  let pathList = [];
  if (typeof pathConfig === "string") {
    // 字符串类型：单一路径（如 productionConfig）
    pathList = [pathConfig];
  } else if (typeof pathConfig === "object" && pathConfig !== null) {
    // 对象类型：多站点路径集合（如 findByPodProductionNo）
    pathList = Object.values(pathConfig);
  }

  // 批量注册路由
  pathList.forEach(path => {
    router.post(`/${path}`, (req, res) => {
      handler(req, res);
    });
  });
}
