feat: restore database from backup and fix date formatting in restore script

This commit is contained in:
2026-04-23 13:37:45 +09:00
parent b996b18dbc
commit e5b4eb8295
26 changed files with 2027 additions and 1662 deletions

View File

@@ -16,14 +16,12 @@ export interface MasterAssetData {
// 동료 코드 호환용 통합 배열 (프론트엔드 로직용)
hw: HardwareAsset[];
sw: SoftwareAsset[];
hw: HardwareAsset[];
}
export interface AppState {
activeCategory: 'dashboard' | 'hw' | 'sw' | 'ops';
activeSubTab: string;
activeCategory: 'dashboard' | 'hw' | 'sw';
activeSubTab: string; // '대시보드', '개인PC', '서버', '스토리지', '전산비품', '구독SW', '영구SW', '클라우드'
masterData: MasterAssetData;
activeCharts: any[];
}
// 초기 상태
@@ -42,10 +40,8 @@ export const state: AppState = {
hw: [], // 호환용
sw: [], // 호환용
swUsers: [],
logs: [],
hw: []
},
activeCharts: []
logs: []
}
};
/**
@@ -89,19 +85,12 @@ export async function loadMasterDataFromDB() {
}
}
// 동료 코드 호환을 위한 통합 sw/hw 배열 생성
// 동료 코드 호환을 위한 통합 sw 배열 생성
state.masterData.sw = [
...state.masterData.subSw,
...state.masterData.permSw,
...state.masterData.cloud
];
state.masterData.hw = [
...state.masterData.pc,
...state.masterData.server,
...state.masterData.storage,
...state.masterData.equip,
...state.masterData.mobile
];
// 하드웨어 통합 배열 생성 (대시보드 등에서 사용)
state.masterData.hw = [
@@ -199,3 +188,57 @@ export function deleteHardwareAsset(assetId: string) {
...state.masterData.mobile
];
}
/**
* 소프트웨어 자산 저장 (API 연동)
*/
export async function saveSoftwareAsset(asset: SoftwareAsset) {
try {
const response = await fetch('http://localhost:3000/api/software/save', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(asset)
});
if (response.ok) {
// 로컬 상태 업데이트
const key = asset.type === '구독SW' ? 'subSw' : (asset.type === '영구SW' ? 'permSw' : 'cloud');
const arr = state.masterData[key] as SoftwareAsset[];
const idx = arr.findIndex(a => a.id === asset.id);
if (idx > -1) arr[idx] = asset;
else arr.push(asset);
// 통합 sw 배열 동기화
state.masterData.sw = [...state.masterData.subSw, ...state.masterData.permSw, ...state.masterData.cloud];
return true;
}
} catch (err) {
console.error('SW 저장 실패:', err);
}
return false;
}
/**
* 소프트웨어 자산 삭제 (API 연동)
*/
export async function deleteSoftwareAsset(type: string, id: string) {
try {
const response = await fetch(`http://localhost:3000/api/asset/${type}/${id}`, {
method: 'DELETE'
});
if (response.ok) {
const key = type === '구독SW' ? 'subSw' : (type === '영구SW' ? 'permSw' : 'cloud');
const arr = state.masterData[key] as SoftwareAsset[];
const idx = arr.findIndex(a => a.id === id);
if (idx > -1) arr.splice(idx, 1);
// 통합 sw 배열 동기화
state.masterData.sw = [...state.masterData.subSw, ...state.masterData.permSw, ...state.masterData.cloud];
return true;
}
} catch (err) {
console.error('SW 삭제 실패:', err);
}
return false;
}