feat: CPU, GPU, RAM 입력 시 부품 마스터 기준 정합성 검증 추가 및 기존 데이터 정제

This commit is contained in:
이태훈
2026-06-25 13:41:31 +09:00
parent 1ecee53966
commit 6ed939c6bf
2 changed files with 45 additions and 0 deletions

View File

@@ -261,6 +261,30 @@ app.post('/api/asset/:category/save', async (req, res) => {
connection = await pool.getConnection();
await connection.beginTransaction();
// 3.0.0 CPU, GPU, RAM 부품 마스터 유효성 검사
const partsToCheck = [
{ value: asset.cpu, category: 'CPU', label: 'CPU' },
{ value: asset.gpu, category: 'GPU', label: 'GPU' },
{ value: asset.ram, category: 'RAM', label: 'RAM' }
];
for (const part of partsToCheck) {
const val = String(part.value || '').trim();
if (val) {
const [rows] = await connection.query(
'SELECT id FROM hardware_components_master WHERE UPPER(category) = ? AND LOWER(TRIM(component_name)) = ?',
[part.category, val.toLowerCase()]
);
if (rows.length === 0) {
await connection.rollback();
return res.status(400).json({
success: false,
message: `입력하신 ${part.label} "${val}"은(는) 부품 마스터에 존재하지 않는 규격입니다.`
});
}
}
}
// 3.0 History Tracking & Auto Field Update
const [oldCoreRows] = await connection.query('SELECT * FROM asset_core WHERE id = ?', [asset.id]);
const [oldSpecRows] = await connection.query('SELECT * FROM asset_spec WHERE asset_id = ?', [asset.id]);