import { Router } from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import { searchEntity, getEntityOptions, getDistinctColumnValues } from "../controllers/entitySearchController";

const router = Router();

/**
 * 엔티티 검색 API
 * GET /api/entity-search/:tableName
 */
router.get("/:tableName", authenticateToken, searchEntity);

export default router;

// 엔티티 옵션 라우터 (V2Select용)
export const entityOptionsRouter = Router();

/**
 * 엔티티 옵션 조회 API
 * GET /api/entity/:tableName/options
 */
entityOptionsRouter.get("/:tableName/options", authenticateToken, getEntityOptions);

/**
 * 테이블 컬럼의 DISTINCT 값 조회 API (inputType: select 용)
 * GET /api/entity/:tableName/distinct/:columnName
 */
entityOptionsRouter.get("/:tableName/distinct/:columnName", authenticateToken, getDistinctColumnValues);

