snp-batch-validation/frontend/src/api/screeningGuideApi.ts
HYOJIN ba19ac203d feat: 선박/회사 기본정보 및 현재 Risk&Compliance 상태 조회 (#111)
- 선박 기본정보 (tb_ship_info_mst) / 회사 기본정보 (tb_company_dtl_info) 조회 API
- 현재 Risk 지표 상태 조회 (JdbcTemplate unpivot, 카테고리별 그리드 + 색상배지)
- 현재 Compliance 상태 조회 (선박: Sanctions/Port Calls/STS/Suspicious 탭 분리)
- 회사 Compliance 헤더에 Overall 상태 배지 표시
- Risk/Compliance 지표 예외 처리 (IUU, Risk Data Maintained, Parent Company 등)
- Risk prevNarrative LATERAL JOIN으로 이전값 설명 표시
- 다국어 캐시 + category 기반 탭 매칭 (언어 전환 시 데이터 유지)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 17:26:16 +09:00

139 lines
4.3 KiB
TypeScript

// API 응답 타입
interface ApiResponse<T> {
success: boolean;
message: string;
data: T;
}
// Risk 지표 타입
export interface RiskIndicatorResponse {
indicatorId: number;
fieldKey: string;
fieldName: string;
description: string;
conditionRed: string;
conditionAmber: string;
conditionGreen: string;
dataType: string;
collectionNote: string;
}
export interface RiskCategoryResponse {
categoryCode: string;
categoryName: string;
indicators: RiskIndicatorResponse[];
}
// Compliance 지표 타입
export interface ComplianceIndicatorResponse {
indicatorId: number;
fieldKey: string;
fieldName: string;
description: string;
conditionRed: string;
conditionAmber: string;
conditionGreen: string;
dataType: string;
collectionNote: string;
}
export interface ComplianceCategoryResponse {
category: string;
indicatorType: string;
indicators: ComplianceIndicatorResponse[];
}
// 방법론 변경 이력 타입
export interface MethodologyHistoryResponse {
historyId: number;
changeDate: string;
changeType: string;
updateTitle: string;
description: string;
collectionNote: string;
}
// 값 변경 이력 타입
export interface ChangeHistoryResponse {
rowIndex: number;
searchKey: string;
lastModifiedDate: string;
changedColumnName: string;
beforeValue: string;
afterValue: string;
fieldName: string;
narrative: string;
prevNarrative: string;
sortOrder: number;
}
// 선박 기본 정보
export interface ShipInfoResponse {
imoNo: string;
shipName: string;
shipStatus: string;
nationality: string;
shipType: string;
dwt: string;
gt: string;
buildYear: string;
mmsiNo: string;
callSign: string;
shipTypeGroup: string;
}
// 회사 기본 정보
export interface CompanyInfoResponse {
companyCode: string;
fullName: string;
abbreviation: string;
country: string;
city: string;
status: string;
registrationCountry: string;
address: string;
}
// 지표 현재 상태
export interface IndicatorStatusResponse {
columnName: string;
fieldName: string;
category: string;
value: string | null;
narrative: string | null;
sortOrder: number;
}
const BASE = '/snp-api/api/screening-guide';
async function fetchJson<T>(url: string): Promise<T> {
const res = await fetch(url);
if (!res.ok) throw new Error(`API Error: ${res.status}`);
return res.json();
}
export const screeningGuideApi = {
getRiskIndicators: (lang = 'KO') =>
fetchJson<ApiResponse<RiskCategoryResponse[]>>(`${BASE}/risk-indicators?lang=${lang}`),
getComplianceIndicators: (lang = 'KO', type = 'SHIP') =>
fetchJson<ApiResponse<ComplianceCategoryResponse[]>>(`${BASE}/compliance-indicators?lang=${lang}&type=${type}`),
getMethodologyHistory: (lang = 'KO') =>
fetchJson<ApiResponse<MethodologyHistoryResponse[]>>(`${BASE}/methodology-history?lang=${lang}`),
getShipRiskHistory: (imoNo: string, lang = 'KO') =>
fetchJson<ApiResponse<ChangeHistoryResponse[]>>(`${BASE}/history/ship-risk?imoNo=${imoNo}&lang=${lang}`),
getShipComplianceHistory: (imoNo: string, lang = 'KO') =>
fetchJson<ApiResponse<ChangeHistoryResponse[]>>(`${BASE}/history/ship-compliance?imoNo=${imoNo}&lang=${lang}`),
getCompanyComplianceHistory: (companyCode: string, lang = 'KO') =>
fetchJson<ApiResponse<ChangeHistoryResponse[]>>(`${BASE}/history/company-compliance?companyCode=${companyCode}&lang=${lang}`),
getShipInfo: (imoNo: string) =>
fetchJson<ApiResponse<ShipInfoResponse>>(`${BASE}/ship-info?imoNo=${imoNo}`),
getShipRiskStatus: (imoNo: string, lang = 'KO') =>
fetchJson<ApiResponse<IndicatorStatusResponse[]>>(`${BASE}/ship-risk-status?imoNo=${imoNo}&lang=${lang}`),
getShipComplianceStatus: (imoNo: string, lang = 'KO') =>
fetchJson<ApiResponse<IndicatorStatusResponse[]>>(`${BASE}/ship-compliance-status?imoNo=${imoNo}&lang=${lang}`),
getCompanyInfo: (companyCode: string) =>
fetchJson<ApiResponse<CompanyInfoResponse>>(`${BASE}/company-info?companyCode=${companyCode}`),
getCompanyComplianceStatus: (companyCode: string, lang = 'KO') =>
fetchJson<ApiResponse<IndicatorStatusResponse[]>>(`${BASE}/company-compliance-status?companyCode=${companyCode}&lang=${lang}`),
};