- PostGIS GEOMETRY 컬럼 추가 (010_postgis_geom.sql) - ASSET_ORG.GEOM (84건), ACDNT.LOC_GEOM (12건) + GIST 인덱스 - SCAT 테이블 생성 + 시드 (011_scat.sql) - CST_SRVY_ZONE 28건, CST_SECT 1,092건, 상세 21건 - GEOMETRY 컬럼 + GIST 공간 인덱스 - 백엔드 API: GET /api/scat/zones, /sections, /sections/:sn - 프론트엔드: Mock 데이터 완전 제거, API 호출로 전환 - 에러 상태 UI, USE_YN 논리삭제 조건 적용 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { Router } from 'express';
|
|
import { requireAuth } from '../auth/authMiddleware.js';
|
|
import { listZones, listSections, getSection } from './scatService.js';
|
|
|
|
const router = Router();
|
|
|
|
// ============================================================
|
|
// GET /api/scat/zones — 조사구역 목록
|
|
// ============================================================
|
|
router.get('/zones', requireAuth, async (_req, res) => {
|
|
try {
|
|
const zones = await listZones();
|
|
res.json(zones);
|
|
} catch (err) {
|
|
console.error('[scat] 조사구역 목록 조회 오류:', err);
|
|
res.status(500).json({ error: '조사구역 목록 조회 중 오류가 발생했습니다.' });
|
|
}
|
|
});
|
|
|
|
// ============================================================
|
|
// GET /api/scat/sections — 해안구간 목록 (필터링)
|
|
// ============================================================
|
|
router.get('/sections', requireAuth, async (req, res) => {
|
|
try {
|
|
const { zone, status, sensitivity, jurisdiction, search } = req.query as {
|
|
zone?: string;
|
|
status?: string;
|
|
sensitivity?: string;
|
|
jurisdiction?: string;
|
|
search?: string;
|
|
};
|
|
const sections = await listSections({ zone, status, sensitivity, jurisdiction, search });
|
|
res.json(sections);
|
|
} catch (err) {
|
|
console.error('[scat] 해안구간 목록 조회 오류:', err);
|
|
res.status(500).json({ error: '해안구간 목록 조회 중 오류가 발생했습니다.' });
|
|
}
|
|
});
|
|
|
|
// ============================================================
|
|
// GET /api/scat/sections/:sn — 해안구간 상세
|
|
// ============================================================
|
|
router.get('/sections/:sn', requireAuth, async (req, res) => {
|
|
try {
|
|
const sn = parseInt(req.params.sn as string, 10);
|
|
if (isNaN(sn)) {
|
|
res.status(400).json({ error: '유효하지 않은 구간 번호입니다.' });
|
|
return;
|
|
}
|
|
const section = await getSection(sn);
|
|
if (!section) {
|
|
res.status(404).json({ error: '해안구간을 찾을 수 없습니다.' });
|
|
return;
|
|
}
|
|
res.json(section);
|
|
} catch (err) {
|
|
console.error('[scat] 해안구간 상세 조회 오류:', err);
|
|
res.status(500).json({ error: '해안구간 상세 조회 중 오류가 발생했습니다.' });
|
|
}
|
|
});
|
|
|
|
export default router;
|