routes_inspections.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Hono } from "hono";
  2. import {
  3. createInspectionTemplate,
  4. getInspectionTemplates,
  5. updateInspectionTemplate,
  6. deleteInspectionTemplate,
  7. createInspectionTask,
  8. createAutoInspectionTask,
  9. runManualInspectionTask,
  10. getInspectionTasks,
  11. runInspectionTask,
  12. getInspectionResults,
  13. exportInspectionReport,
  14. getInspectionReportReceivers,
  15. addInspectionReportReceiver,
  16. removeInspectionReportReceiver,
  17. createNewYearInspection,
  18. updateInspectionProgress,
  19. completeInspection,
  20. } from "./controllers/inspections.ts";
  21. import type { Variables, WithAuth } from "./middlewares.ts";
  22. export function createInspectionsRoutes(withAuth: WithAuth) {
  23. const router = new Hono<{ Variables: Variables }>()
  24. router.get("/templates", withAuth, getInspectionTemplates);
  25. router.post("/templates", withAuth, createInspectionTemplate);
  26. router.put("/templates/:id", withAuth, updateInspectionTemplate);
  27. router.delete("/templates/:id", withAuth, deleteInspectionTemplate);
  28. router.get("/tasks", withAuth, getInspectionTasks);
  29. router.post("/tasks", withAuth, createInspectionTask);
  30. router.post("/tasks/auto", withAuth, createAutoInspectionTask);
  31. router.post("/tasks/manual", withAuth, runManualInspectionTask);
  32. router.post("/tasks/:id/run", withAuth, runInspectionTask);
  33. router.get("/results", withAuth, getInspectionResults);
  34. router.get("/results/:id/export", withAuth, exportInspectionReport);
  35. router.get("/receivers", withAuth, getInspectionReportReceivers);
  36. router.post("/receivers", withAuth, addInspectionReportReceiver);
  37. router.delete("/receivers/:id", withAuth, removeInspectionReportReceiver);
  38. // 新年巡检相关路由
  39. router.post("/tasks/new-year", withAuth, createNewYearInspection);
  40. router.put("/tasks/:id/progress", withAuth, updateInspectionProgress);
  41. router.post("/tasks/:id/complete", withAuth, completeInspection);
  42. return router;
  43. }