wing-ops/backend/src/scat/scatRouter.ts
leedano 9881b99ee7 feat(scat): Pre-SCAT 해안조사 UI 개선 + WeatherRightPanel 정리
SCAT 좌측패널 리팩토링, 해안조사 뷰 기능 보강, 기상 우측패널 중복 코드 제거

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:22:20 +09:00

92 lines
3.5 KiB
TypeScript

import { Router } from 'express';
import { requireAuth } from '../auth/authMiddleware.js';
import { listOffices, listJurisdictions, listZones, listSections, getSection } from './scatService.js';
const router = Router();
// ============================================================
// GET /api/scat/offices — 관할청 목록
// ============================================================
router.get('/offices', requireAuth, async (_req, res) => {
try {
const offices = await listOffices();
res.json(offices);
} catch (err) {
console.error('[scat] 관할청 목록 조회 오류:', err);
res.status(500).json({ error: '관할청 목록 조회 중 오류가 발생했습니다.' });
}
});
// ============================================================
// GET /api/scat/jurisdictions — 관할서 목록
// ============================================================
router.get('/jurisdictions', requireAuth, async (req, res) => {
try {
const { officeCd } = req.query as { officeCd?: string };
const jurisdictions = await listJurisdictions(officeCd);
res.json(jurisdictions);
} catch (err) {
console.error('[scat] 관할서 목록 조회 오류:', err);
res.status(500).json({ error: '관할서 목록 조회 중 오류가 발생했습니다.' });
}
});
// ============================================================
// GET /api/scat/zones — 조사구역 목록
// ============================================================
router.get('/zones', requireAuth, async (req, res) => {
try {
const { jurisdiction, officeCd } = req.query as { jurisdiction?: string; officeCd?: string };
const zones = await listZones({ jurisdiction, officeCd });
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, officeCd } = req.query as {
zone?: string;
status?: string;
sensitivity?: string;
jurisdiction?: string;
search?: string;
officeCd?: string;
};
const sections = await listSections({ zone, status, sensitivity, jurisdiction, search, officeCd });
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;