데이터베이스 틀린 비밀번호 입력시 연결거부처리

This commit is contained in:
leeheejin
2025-09-24 10:30:36 +09:00
parent bc6e6056c1
commit 4efec8d758
7 changed files with 760 additions and 2 deletions

View File

@@ -0,0 +1,49 @@
import { Router } from "express";
import { DbTypeCategoryController } from "../controllers/dbTypeCategoryController";
import { authenticateToken } from "../middleware/authMiddleware";
const router = Router();
/**
* GET /api/db-type-categories
* 모든 DB 타입 카테고리 조회
*/
router.get("/", authenticateToken, DbTypeCategoryController.getAllCategories);
/**
* GET /api/db-type-categories/stats/connections
* DB 타입별 연결 통계 조회
*/
router.get("/stats/connections", authenticateToken, DbTypeCategoryController.getConnectionStatsByType);
/**
* GET /api/db-type-categories/:typeCode
* 특정 DB 타입 카테고리 조회
*/
router.get("/:typeCode", authenticateToken, DbTypeCategoryController.getCategoryByTypeCode);
/**
* POST /api/db-type-categories
* DB 타입 카테고리 생성
*/
router.post("/", authenticateToken, DbTypeCategoryController.createCategory);
/**
* POST /api/db-type-categories/initialize
* 기본 DB 타입 카테고리 초기화
*/
router.post("/initialize", authenticateToken, DbTypeCategoryController.initializeDefaultCategories);
/**
* PUT /api/db-type-categories/:typeCode
* DB 타입 카테고리 수정
*/
router.put("/:typeCode", authenticateToken, DbTypeCategoryController.updateCategory);
/**
* DELETE /api/db-type-categories/:typeCode
* DB 타입 카테고리 삭제 (비활성화)
*/
router.delete("/:typeCode", authenticateToken, DbTypeCategoryController.deleteCategory);
export default router;

View File

@@ -85,6 +85,46 @@ router.get(
}
);
/**
* GET /api/external-db-connections/grouped
* DB 타입별로 그룹화된 외부 DB 연결 목록 조회
*/
router.get(
"/grouped",
authenticateToken,
async (req: AuthenticatedRequest, res: Response) => {
try {
const filter: ExternalDbConnectionFilter = {
db_type: req.query.db_type as string,
is_active: req.query.is_active as string,
company_code: req.query.company_code as string,
search: req.query.search as string,
};
// 빈 값 제거
Object.keys(filter).forEach((key) => {
if (!filter[key as keyof ExternalDbConnectionFilter]) {
delete filter[key as keyof ExternalDbConnectionFilter];
}
});
const result = await ExternalDbConnectionService.getConnectionsGroupedByType(filter);
if (result.success) {
return res.status(200).json(result);
} else {
return res.status(400).json(result);
}
} catch (error) {
console.error("그룹화된 외부 DB 연결 목록 조회 오류:", error);
return res.status(500).json({
success: false,
message: "그룹화된 연결 목록 조회 중 오류가 발생했습니다.",
error: error instanceof Error ? error.message : "알 수 없는 오류"
});
}
}
);
/**
* GET /api/external-db-connections/:id
@@ -264,6 +304,8 @@ router.post(
// 테스트용 비밀번호가 제공된 경우 사용
const testData = req.body.password ? { password: req.body.password } : undefined;
console.log(`🔍 [API] 연결테스트 요청 - ID: ${id}, 비밀번호 제공됨: ${!!req.body.password}`);
const result = await ExternalDbConnectionService.testConnectionById(id, testData);
return res.status(200).json({