113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
import { Router } from "express";
|
|
import reportController from "../controllers/reportController";
|
|
import { authenticateToken } from "../middleware/authMiddleware";
|
|
import multer from "multer";
|
|
|
|
const router = Router();
|
|
|
|
// Multer 설정 (메모리 저장)
|
|
const upload = multer({
|
|
storage: multer.memoryStorage(),
|
|
limits: {
|
|
fileSize: 10 * 1024 * 1024, // 10MB 제한
|
|
},
|
|
fileFilter: (req, file, cb) => {
|
|
// 이미지 파일만 허용
|
|
const allowedTypes = [
|
|
"image/jpeg",
|
|
"image/jpg",
|
|
"image/png",
|
|
"image/gif",
|
|
"image/webp",
|
|
];
|
|
if (allowedTypes.includes(file.mimetype)) {
|
|
cb(null, true);
|
|
} else {
|
|
cb(new Error("이미지 파일만 업로드 가능합니다. (jpg, png, gif, webp)"));
|
|
}
|
|
},
|
|
});
|
|
|
|
// 모든 리포트 API는 인증이 필요
|
|
router.use(authenticateToken);
|
|
|
|
// 외부 DB 연결 목록 (구체적인 경로를 먼저 배치)
|
|
router.get("/external-connections", (req, res, next) =>
|
|
reportController.getExternalConnections(req, res, next)
|
|
);
|
|
|
|
// 템플릿 관련 라우트
|
|
router.get("/templates", (req, res, next) =>
|
|
reportController.getTemplates(req, res, next)
|
|
);
|
|
router.post("/templates", (req, res, next) =>
|
|
reportController.createTemplate(req, res, next)
|
|
);
|
|
// 레이아웃 데이터로 직접 템플릿 생성 (리포트 저장 불필요)
|
|
router.post("/templates/create-from-layout", (req, res, next) =>
|
|
reportController.createTemplateFromLayout(req, res, next)
|
|
);
|
|
router.delete("/templates/:templateId", (req, res, next) =>
|
|
reportController.deleteTemplate(req, res, next)
|
|
);
|
|
|
|
// 이미지 업로드 (구체적인 경로를 먼저 배치)
|
|
router.post("/upload-image", upload.single("image"), (req, res, next) =>
|
|
reportController.uploadImage(req, res, next)
|
|
);
|
|
|
|
// WORD(DOCX) 내보내기
|
|
router.post("/export-word", (req, res, next) =>
|
|
reportController.exportToWord(req, res, next)
|
|
);
|
|
|
|
// 리포트 목록
|
|
router.get("/", (req, res, next) =>
|
|
reportController.getReports(req, res, next)
|
|
);
|
|
|
|
// 리포트 생성
|
|
router.post("/", (req, res, next) =>
|
|
reportController.createReport(req, res, next)
|
|
);
|
|
|
|
// 리포트 복사 (구체적인 경로를 먼저 배치)
|
|
router.post("/:reportId/copy", (req, res, next) =>
|
|
reportController.copyReport(req, res, next)
|
|
);
|
|
|
|
// 템플릿으로 저장
|
|
router.post("/:reportId/save-as-template", (req, res, next) =>
|
|
reportController.saveAsTemplate(req, res, next)
|
|
);
|
|
|
|
// 레이아웃 관련 라우트
|
|
router.get("/:reportId/layout", (req, res, next) =>
|
|
reportController.getLayout(req, res, next)
|
|
);
|
|
router.put("/:reportId/layout", (req, res, next) =>
|
|
reportController.saveLayout(req, res, next)
|
|
);
|
|
|
|
// 쿼리 실행
|
|
router.post("/:reportId/queries/:queryId/execute", (req, res, next) =>
|
|
reportController.executeQuery(req, res, next)
|
|
);
|
|
|
|
// 리포트 상세
|
|
router.get("/:reportId", (req, res, next) =>
|
|
reportController.getReportById(req, res, next)
|
|
);
|
|
|
|
// 리포트 수정
|
|
router.put("/:reportId", (req, res, next) =>
|
|
reportController.updateReport(req, res, next)
|
|
);
|
|
|
|
// 리포트 삭제
|
|
router.delete("/:reportId", (req, res, next) =>
|
|
reportController.deleteReport(req, res, next)
|
|
);
|
|
|
|
export default router;
|