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"
  },
  //惠立彩素材下载接口
  processTransparentBackground: {
    CN: "factory/podJomallOrderProductCn/processTransparentBackground",
    US: "factory/podJomallOrderProductUs/processTransparentBackground"
  },
  //判断 status 操作单状态
  scanProduce: {
    OP: "factory/podOrderOperation/scan-produce"
  },
  checkInventory: {
    OP: "factory/podOrderOperation/check-inventory"
  }
};

export function autoRegisterRouter(router, funcKey, handler) {
  const configGroup = pathMap[funcKey];
  // 遍历配置自动注册路由
  Object.values(configGroup).forEach(el => {
    router.post(`/${el}`, (req, res) => {
      handler(req, res);
    });
  });
}
