wing-gis/frontend/wing-gis-web/src/features/shipImage/api/shipImageApi.ts
htlee b9d924e81e chore: 팀 워크플로우 기반 초기 프로젝트 구성
WING-GIS 해양경찰 통합 GIS 위치정보시스템.
모노레포: frontend(React 19 + MapLibre + deck.gl) + services(Spring Boot + Gradle).

- npm + Nexus 프록시 레지스트리 설정
- 팀 워크플로우 v1.6.1 부트스트랩 파일 배치
- .githooks (commit-msg, post-checkout)
- custom_pre_commit: true (모노레포 pre-commit 별도 관리)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 12:36:38 +09:00

35 lines
1.1 KiB
TypeScript

export interface ShipImageInfo {
picId: number;
path: string;
copyright: string;
date: string;
}
const BASE = '/signal-batch';
export async function fetchShipImagesByImo(
imo: number,
signal?: AbortSignal,
): Promise<ShipImageInfo[]> {
const res = await fetch(`${BASE}/api/v2/shipimg/${imo}`, { signal, headers: { accept: 'application/json' } });
if (!res.ok) return [];
const json: unknown = await res.json();
return Array.isArray(json) ? json : [];
}
const ensureJpg = (path: string, suffix: '_1.jpg' | '_2.jpg'): string => {
if (/\.jpe?g$/i.test(path)) return path;
return `${path}${suffix}`;
};
export const toThumbnailUrl = (path: string): string => {
const normalized = ensureJpg(path, '_1.jpg');
return normalized.startsWith('http') || normalized.startsWith('/') ? normalized : `/shipimg/${normalized}`;
};
export const toHighResUrl = (path: string): string => {
const withExt = ensureJpg(path, '_2.jpg');
const resolved = withExt.startsWith('http') || withExt.startsWith('/') ? withExt : `/shipimg/${withExt}`;
return resolved.replace(/_1\.jpg$/i, '_2.jpg');
};