feat: 하드웨어 자산 관리 고도화 및 자동 이력 시스템 구축
- 통합 원격 접속 정보 UI 구현 (IP/MAC 및 계정 정보 통합) - 서버 측 스냅샷 비교 기반 자동 이력(Log) 생성 로직 도입 - 타임라인 UI 개선 (이벤트별 색상 뱃지 및 변동 사항 강조) - 자산 상세 필드 확장 (서비스 구분, 용도 등) - 테스트 데이터 생성기 및 이력 계획서 추가
This commit is contained in:
71
test_data_generator.js
Normal file
71
test_data_generator.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import mysql from 'mysql2/promise';
|
||||
import dotenv from 'dotenv';
|
||||
import crypto from 'crypto';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const { DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT } = process.env;
|
||||
|
||||
const CATEGORIES = ['PC', '서버', '노트북', '모니터', '업무지원장비'];
|
||||
const DEPTS = ['기술개발센터', '총괄기획실', '한맥', '삼안', '장헌', '한라'];
|
||||
const USERS = ['홍길동', '김철수', '이영희', '박지성', '손흥민', '봉준호', '싸이'];
|
||||
const STATUSES = ['운영', '재고', '수리', '폐기', '기타'];
|
||||
const CORPS = ['한맥', '삼안', '장헌', '한라', 'PTC', '바론'];
|
||||
|
||||
async function generateTestData() {
|
||||
const connection = await mysql.createConnection({
|
||||
host: DB_HOST,
|
||||
user: DB_USER,
|
||||
password: DB_PASS,
|
||||
database: DB_NAME,
|
||||
port: parseInt(DB_PORT || '3306')
|
||||
});
|
||||
|
||||
console.log('🚀 무작위 테스트 데이터 생성을 시작합니다 (Crypto UUID 방식)...');
|
||||
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
const category = CATEGORIES[Math.floor(Math.random() * CATEGORIES.length)];
|
||||
const dept = DEPTS[Math.floor(Math.random() * DEPTS.length)];
|
||||
const user = USERS[Math.floor(Math.random() * USERS.length)];
|
||||
const status = STATUSES[Math.floor(Math.random() * STATUSES.length)];
|
||||
const corp = CORPS[Math.floor(Math.random() * CORPS.length)];
|
||||
|
||||
// Crypto UUID 생성
|
||||
const id = crypto.randomUUID();
|
||||
const assetCode = `TEST-${Date.now().toString().slice(-6)}-${String(i).padStart(3, '0')}`;
|
||||
|
||||
try {
|
||||
// 1. asset_core 삽입 (id 수동 지정)
|
||||
await connection.query(
|
||||
`INSERT INTO asset_core
|
||||
(id, asset_code, category, asset_type, purchase_corp, current_dept, user_current, purchase_date, service_type)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[id, assetCode, category, category, corp, dept, user, '2026-06-10', '내부']
|
||||
);
|
||||
|
||||
// 2. asset_spec 삽입
|
||||
await connection.query(
|
||||
`INSERT INTO asset_spec
|
||||
(asset_id, hw_status, model_name, cpu, ram)
|
||||
VALUES (?, ?, ?, ?, ?)`,
|
||||
[id, status, `${category} Model ${i}`, 'Intel i7', '16GB']
|
||||
);
|
||||
|
||||
// 3. 초기 이력 삽입
|
||||
await connection.query(
|
||||
`INSERT INTO asset_history (asset_id, event_type, details, log_date, log_user)
|
||||
VALUES (?, ?, ?, ?, ?)`,
|
||||
[id, 'STATUS_CHANGE', `[최초 등록] 테스트 데이터 생성 (${status})`, '2026-06-10', '시스템']
|
||||
);
|
||||
|
||||
console.log(`✅ 생성 완료: ${assetCode} (${category} / ${dept} / ${user})`);
|
||||
} catch (err) {
|
||||
console.error(`❌ 생성 실패 (${i}):`, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
await connection.end();
|
||||
console.log('\n✨ 20개의 테스트 데이터 생성이 완료되었습니다.');
|
||||
}
|
||||
|
||||
generateTestData().catch(console.error);
|
||||
Reference in New Issue
Block a user