/** * 위성 API */ import { fetchWithAuth } from './fetchWithAuth'; const SATELLITE_VIDEO_SEARCH_ENDPOINT = '/api/gis/satlit/search'; const SATELLITE_CSV_ENDPOINT = '/api/gis/satlit/excelToJson'; const SATELLITE_DETAIL_ENDPOINT = '/api/gis/satlit/id/search'; const SATELLITE_UPDATE_ENDPOINT = '/api/gis/satlit/update'; const SATELLITE_COMPANY_LIST_ENDPOINT = '/api/gis/satlit/sat-bz/all/search'; const SATELLITE_MANAGE_LIST_ENDPOINT = '/api/gis/satlit/sat-mng/bz/search'; const SATELLITE_SAVE_ENDPOINT = '/api/gis/satlit/save'; const SATELLITE_COMPANY_SEARCH_ENDPOINT = '/api/gis/satlit/sat-bz/search'; const SATELLITE_COMPANY_SAVE_ENDPOINT = '/api/gis/satlit/sat-bz/save'; const SATELLITE_COMPANY_DETAIL_ENDPOINT = '/api/gis/satlit/sat-bz/id/search'; const SATELLITE_COMPANY_UPDATE_ENDPOINT = '/api/gis/satlit/sat-bz/update'; const SATELLITE_MANAGE_SEARCH_ENDPOINT = '/api/gis/satlit/sat-mng/search'; const SATELLITE_MANAGE_SAVE_ENDPOINT = '/api/gis/satlit/sat-mng/save'; const SATELLITE_MANAGE_DETAIL_ENDPOINT = '/api/gis/satlit/sat-mng/id/search'; const SATELLITE_MANAGE_UPDATE_ENDPOINT = '/api/gis/satlit/sat-mng/update'; /** * 위성영상 목록 조회 * * @param {Object} params * @param {number} params.page - 페이지 번호 * @param {string} [params.startDate] - 촬영 시작일 * @param {string} [params.endDate] - 촬영 종료일 * @param {string} [params.satelliteVideoName] - 위성영상명 * @param {string} [params.satelliteVideoTransmissionCycle] - 전송주기 * @param {string} [params.satelliteVideoKind] - 영상 종류 * @param {string} [params.satelliteVideoOrbit] - 위성 궤도 * @param {string} [params.satelliteVideoOrigin] - 영상 출처 * @returns {Promise<{ list: Array, totalPage: number }>} */ export async function fetchSatelliteVideoList({ page, startDate, endDate, satelliteVideoName, satelliteVideoTransmissionCycle, satelliteVideoKind, satelliteVideoOrbit, satelliteVideoOrigin, }) { try { const response = await fetchWithAuth(SATELLITE_VIDEO_SEARCH_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ page, startDate, endDate, satelliteVideoName, satelliteVideoTransmissionCycle, satelliteVideoKind, satelliteVideoOrbit, satelliteVideoOrigin, }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return { list: result?.satelliteVideoInfoList || [], totalPage: result?.totalPage || 0, }; } catch (error) { console.error('[fetchSatelliteVideoList] Error:', error); throw error; } } /** * 위성영상 CSV → JSON 변환 (선박 좌표 추출) * * @param {string} csvFileName - CSV 파일명 * @returns {Promise>} */ export async function fetchSatelliteCsvFeatures(csvFileName) { try { const response = await fetchWithAuth(SATELLITE_CSV_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ csvFileName }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); const data = result?.jsonData; if (!data) return []; const parsed = typeof data === 'string' ? JSON.parse(data) : data; return parsed.map(({ lon, lat }) => ({ coordinates: [parseFloat(lon), parseFloat(lat)], })); } catch (error) { console.error('[fetchSatelliteCsvFeatures] Error:', error); throw error; } } /** * 위성영상 상세조회 * * @param {number} satelliteId - 위성 ID * @returns {Promise} SatelliteVideoInfoOneDto */ export async function fetchSatelliteVideoDetail(satelliteId) { try { const response = await fetchWithAuth(SATELLITE_DETAIL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ satelliteId }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return result?.satelliteVideoInfoById || null; } catch (error) { console.error('[fetchSatelliteVideoDetail] Error:', error); throw error; } } /** * 위성영상 수정 * * @param {Object} params * @param {number} params.satelliteId * @param {number} params.satelliteManageId * @param {string} [params.photographDate] * @param {string} [params.satelliteVideoName] * @param {string} [params.satelliteVideoTransmissionCycle] * @param {string} [params.satelliteVideoKind] * @param {string} [params.satelliteVideoOrbit] * @param {string} [params.satelliteVideoOrigin] * @param {string} [params.photographPurpose] * @param {string} [params.photographMode] * @param {string} [params.purchaseCode] * @param {number} [params.purchasePrice] */ export async function updateSatelliteVideo(params) { try { const response = await fetchWithAuth(SATELLITE_UPDATE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[updateSatelliteVideo] Error:', error); throw error; } } /** * 사업자 목록 조회 * * @returns {Promise>} */ export async function fetchSatelliteCompanyList() { try { const response = await fetchWithAuth(SATELLITE_COMPANY_LIST_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return result?.satelliteCompanyNameList || []; } catch (error) { console.error('[fetchSatelliteCompanyList] Error:', error); throw error; } } /** * 사업자별 위성명 목록 조회 * * @param {number} companyNo - 사업자 번호 * @returns {Promise>} */ export async function fetchSatelliteManageList(companyNo) { try { const response = await fetchWithAuth(SATELLITE_MANAGE_LIST_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ companyNo }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return result?.satelliteManageInfoList || []; } catch (error) { console.error('[fetchSatelliteManageList] Error:', error); throw error; } } /** * 위성영상 등록 (multipart/form-data) * * @param {FormData} formData - 파일(tifFile, csvFile, cloudMaskFile) + 폼 필드 */ export async function saveSatelliteVideo(formData) { try { const response = await fetchWithAuth(SATELLITE_SAVE_ENDPOINT, { method: 'POST', body: formData, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[saveSatelliteVideo] Error:', error); throw error; } } /** * 위성 사업자 목록 검색 * * @param {Object} params * @param {string} [params.companyTypeCode] - 사업자 분류 코드 * @param {string} [params.companyName] - 사업자명 * @returns {Promise<{ list: Array, totalPage: number }>} */ export async function searchSatelliteCompany({ companyTypeCode, companyName, page, limit }) { try { const response = await fetchWithAuth(SATELLITE_COMPANY_SEARCH_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ companyTypeCode, companyName, page, limit }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return { list: result?.satelliteCompanySearchList || [], totalPage: result?.totalPage || 0, }; } catch (error) { console.error('[searchSatelliteCompany] Error:', error); throw error; } } /** * 위성 사업자 등록 * * @param {Object} params * @param {string} params.companyTypeCode - 사업자 분류 코드 * @param {string} params.companyName - 사업자명 * @param {string} params.nationalCode - 국가코드 * @param {string} [params.location] - 소재지 * @param {string} [params.companyDetail] - 상세내역 */ export async function saveSatelliteCompany(params) { try { const response = await fetchWithAuth(SATELLITE_COMPANY_SAVE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[saveSatelliteCompany] Error:', error); throw error; } } /** * 위성 사업자 상세조회 * * @param {number} companyNo - 사업자 번호 * @returns {Promise} SatelliteCompanySearchDto */ export async function fetchSatelliteCompanyDetail(companyNo) { try { const response = await fetchWithAuth(SATELLITE_COMPANY_DETAIL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ companyNo }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return result?.satelliteCompany || null; } catch (error) { console.error('[fetchSatelliteCompanyDetail] Error:', error); throw error; } } /** * 위성 사업자 수정 * * @param {Object} params * @param {number} params.companyNo - 사업자 번호 * @param {string} params.companyTypeCode - 사업자 분류 코드 * @param {string} params.companyName - 사업자명 * @param {string} params.nationalCode - 국가코드 * @param {string} [params.location] - 소재지 * @param {string} [params.companyDetail] - 상세내역 */ export async function updateSatelliteCompany(params) { try { const response = await fetchWithAuth(SATELLITE_COMPANY_UPDATE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[updateSatelliteCompany] Error:', error); throw error; } } /** * 위성관리 목록 검색 * * @param {Object} params * @param {number} [params.companyNo] - 사업자 번호 * @param {string} [params.satelliteName] - 위성명 * @param {string} [params.sensorType] - 센서 타입 * @returns {Promise<{ list: Array, totalPage: number }>} */ export async function searchSatelliteManage({ companyNo, satelliteName, sensorType, page, limit }) { try { const response = await fetchWithAuth(SATELLITE_MANAGE_SEARCH_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ companyNo, satelliteName, sensorType, page, limit }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return { list: result?.satelliteManageInfoSearchList || [], totalPage: result?.totalPage || 0, }; } catch (error) { console.error('[searchSatelliteManage] Error:', error); throw error; } } /** * 위성 관리 등록 * * @param {Object} params * @param {number} params.companyNo - 사업자 번호 * @param {string} params.satelliteName - 위성명 * @param {string} [params.sensorType] - 센서 타입 * @param {string} [params.photoResolution] - 촬영 해상도 * @param {string} [params.frequency] - 주파수 * @param {string} [params.photoDetail] - 상세내역 */ export async function saveSatelliteManage(params) { try { const response = await fetchWithAuth(SATELLITE_MANAGE_SAVE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[saveSatelliteManage] Error:', error); throw error; } } /** * 위성 관리 상세조회 * * @param {number} satelliteManageId - 위성 관리 ID * @returns {Promise} SatelliteManageInfoDto */ export async function fetchSatelliteManageDetail(satelliteManageId) { try { const response = await fetchWithAuth(SATELLITE_MANAGE_DETAIL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ satelliteManageId }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); return result?.satelliteManageInfo || null; } catch (error) { console.error('[fetchSatelliteManageDetail] Error:', error); throw error; } } /** * 위성 관리 수정 * * @param {Object} params * @param {number} params.satelliteManageId - 위성 관리 ID * @param {number} params.companyNo - 사업자 번호 * @param {string} params.satelliteName - 위성명 * @param {string} [params.sensorType] - 센서 타입 * @param {string} [params.photoResolution] - 촬영 해상도 * @param {string} [params.frequency] - 주파수 * @param {string} [params.photoDetail] - 상세내역 */ export async function updateSatelliteManage(params) { try { const response = await fetchWithAuth(SATELLITE_MANAGE_UPDATE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } } catch (error) { console.error('[updateSatelliteManage] Error:', error); throw error; } }