feat(consumable): 소모품 마스터에 "규격(spec)" 필드 추가
품목의 규격 정보(예: 4" 용접, M16)를 분리 저장할 수 있도록 spec 컬럼 추가. DB ALTER 필요: ALTER TABLE consumable_items ADD COLUMN spec VARCHAR(200) DEFAULT NULL AFTER item_name; Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ async function findAll({ category, search, is_active } = {}) {
|
||||
const params = [];
|
||||
if (is_active !== undefined) { sql += ' AND is_active = ?'; params.push(is_active); }
|
||||
if (category) { sql += ' AND category = ?'; params.push(category); }
|
||||
if (search) { sql += ' AND (item_name LIKE ? OR maker LIKE ?)'; params.push(`%${search}%`, `%${search}%`); }
|
||||
if (search) { sql += ' AND (item_name LIKE ? OR maker LIKE ? OR spec LIKE ?)'; params.push(`%${search}%`, `%${search}%`, `%${search}%`); }
|
||||
sql += ' ORDER BY category, item_name';
|
||||
const [rows] = await db.query(sql, params);
|
||||
return rows;
|
||||
@@ -23,9 +23,9 @@ async function findById(id) {
|
||||
async function create(data) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO consumable_items (item_name, maker, category, base_price, unit, photo_path)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`,
|
||||
[data.item_name, data.maker || null, data.category,
|
||||
`INSERT INTO consumable_items (item_name, spec, maker, category, base_price, unit, photo_path)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[data.item_name, data.spec || null, data.maker || null, data.category,
|
||||
data.base_price || 0, data.unit || 'EA', data.photo_path || null]
|
||||
);
|
||||
return findById(result.insertId);
|
||||
@@ -36,6 +36,7 @@ async function update(id, data) {
|
||||
const fields = [];
|
||||
const values = [];
|
||||
if (data.item_name !== undefined) { fields.push('item_name = ?'); values.push(data.item_name); }
|
||||
if (data.spec !== undefined) { fields.push('spec = ?'); values.push(data.spec || null); }
|
||||
if (data.maker !== undefined) { fields.push('maker = ?'); values.push(data.maker || null); }
|
||||
if (data.category !== undefined) { fields.push('category = ?'); values.push(data.category); }
|
||||
if (data.base_price !== undefined) { fields.push('base_price = ?'); values.push(data.base_price); }
|
||||
|
||||
Reference in New Issue
Block a user