93 lines
3.0 KiB
TypeScript
93 lines
3.0 KiB
TypeScript
import { Router } from "express";
|
|
import { CommonCodeController } from "../controllers/commonCodeController";
|
|
import { authenticateToken } from "../middleware/authMiddleware";
|
|
|
|
const router = Router();
|
|
const commonCodeController = new CommonCodeController();
|
|
|
|
// 모든 공통코드 API는 인증이 필요
|
|
router.use(authenticateToken);
|
|
|
|
// 카테고리 관련 라우트
|
|
router.get("/categories", (req, res) =>
|
|
commonCodeController.getCategories(req, res)
|
|
);
|
|
|
|
// 카테고리 중복 검사 (구체적인 경로를 먼저 배치)
|
|
router.get("/categories/check-duplicate", (req, res) =>
|
|
commonCodeController.checkCategoryDuplicate(req, res)
|
|
);
|
|
|
|
router.post("/categories", (req, res) =>
|
|
commonCodeController.createCategory(req, res)
|
|
);
|
|
router.put("/categories/:categoryCode", (req, res) =>
|
|
commonCodeController.updateCategory(req, res)
|
|
);
|
|
router.delete("/categories/:categoryCode", (req, res) =>
|
|
commonCodeController.deleteCategory(req, res)
|
|
);
|
|
|
|
// 코드 관련 라우트
|
|
router.get("/categories/:categoryCode/codes", (req, res) =>
|
|
commonCodeController.getCodes(req, res)
|
|
);
|
|
router.post("/categories/:categoryCode/codes", (req, res) =>
|
|
commonCodeController.createCode(req, res)
|
|
);
|
|
|
|
// 코드 중복 검사 (구체적인 경로를 먼저 배치)
|
|
router.get("/categories/:categoryCode/codes/check-duplicate", (req, res) =>
|
|
commonCodeController.checkCodeDuplicate(req, res)
|
|
);
|
|
|
|
// 코드 순서 변경 (구체적인 경로를 먼저 배치)
|
|
router.put("/categories/:categoryCode/codes/reorder", (req, res) =>
|
|
commonCodeController.reorderCodes(req, res)
|
|
);
|
|
|
|
// 계층구조 코드 조회 (구체적인 경로를 먼저 배치)
|
|
router.get("/categories/:categoryCode/hierarchy", (req, res) =>
|
|
commonCodeController.getHierarchicalCodes(req, res)
|
|
);
|
|
|
|
// 코드 트리 조회
|
|
router.get("/categories/:categoryCode/tree", (req, res) =>
|
|
commonCodeController.getCodeTree(req, res)
|
|
);
|
|
|
|
// 자식 코드 존재 여부 확인
|
|
router.get("/categories/:categoryCode/codes/:codeValue/has-children", (req, res) =>
|
|
commonCodeController.hasChildren(req, res)
|
|
);
|
|
|
|
router.put("/categories/:categoryCode/codes/:codeValue", (req, res) =>
|
|
commonCodeController.updateCode(req, res)
|
|
);
|
|
router.delete("/categories/:categoryCode/codes/:codeValue", (req, res) =>
|
|
commonCodeController.deleteCode(req, res)
|
|
);
|
|
|
|
// 화면관리용 옵션 조회
|
|
router.get("/categories/:categoryCode/options", (req, res) =>
|
|
commonCodeController.getCodeOptions(req, res)
|
|
);
|
|
|
|
// 계층 구조 코드 조회 (트리 형태)
|
|
router.get("/categories/:categoryCode/hierarchy", (req, res) =>
|
|
commonCodeController.getCodesHierarchy(req, res)
|
|
);
|
|
|
|
// 자식 코드 조회 (연쇄 선택용)
|
|
router.get("/categories/:categoryCode/children", (req, res) =>
|
|
commonCodeController.getChildCodes(req, res)
|
|
);
|
|
|
|
// 카테고리 → 공통코드 호환 API (레거시 지원)
|
|
// 기존 카테고리 타입이 공통코드로 마이그레이션된 후에도 동작
|
|
router.get("/category-options/:tableName/:columnName", (req, res) =>
|
|
commonCodeController.getCategoryOptionsAsCode(req, res)
|
|
);
|
|
|
|
export default router;
|