feat: 알림 시스템 및 시설설비 관리 기능 구현

- 알림 시스템 구축 (navbar 알림 아이콘, 드롭다운)
- 알림 수신자 설정 기능 (계정관리 페이지)
- 시설설비 관리 페이지 추가 (수리 워크플로우)
- 수리 신청 → 접수 → 처리중 → 완료 상태 관리
- 사이드바 메뉴 구조 개선 (공장 관리 카테고리)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-02-04 15:56:57 +09:00
parent d1aec517a6
commit b8ccde7f17
24 changed files with 3204 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
// models/equipmentModel.js
const { getDb } = require('../dbPool');
const notificationModel = require('./notificationModel');
const EquipmentModel = {
// CREATE - 설비 생성
@@ -823,6 +824,20 @@ const EquipmentModel = {
['repair_needed', requestData.equipment_id]
);
// 알림 생성
try {
await notificationModel.createRepairNotification({
equipment_id: requestData.equipment_id,
equipment_name: requestData.equipment_name || '설비',
repair_type: requestData.repair_type || '일반 수리',
request_id: result.insertId,
created_by: requestData.reported_by
});
} catch (notifError) {
console.error('알림 생성 실패:', notifError);
// 알림 생성 실패해도 수리 신청은 성공으로 처리
}
callback(null, {
report_id: result.insertId,
equipment_id: requestData.equipment_id,
@@ -881,6 +896,53 @@ const EquipmentModel = {
} catch (error) {
callback(error);
}
},
// ADD REPAIR CATEGORY - 새 수리 항목 추가
addRepairCategory: async (itemName, callback) => {
try {
const db = await getDb();
// 설비 수리 카테고리 ID 조회
const [categories] = await db.query(
"SELECT category_id FROM issue_report_categories WHERE category_name = '설비 수리'"
);
if (categories.length === 0) {
return callback(new Error('설비 수리 카테고리가 없습니다.'));
}
const categoryId = categories[0].category_id;
// 중복 확인
const [existing] = await db.query(
'SELECT item_id FROM issue_report_items WHERE category_id = ? AND item_name = ?',
[categoryId, itemName]
);
if (existing.length > 0) {
// 이미 존재하면 해당 ID 반환
return callback(null, { item_id: existing[0].item_id, item_name: itemName, isNew: false });
}
// 다음 display_order 구하기
const [maxOrder] = await db.query(
'SELECT MAX(display_order) as max_order FROM issue_report_items WHERE category_id = ?',
[categoryId]
);
const nextOrder = (maxOrder[0].max_order || 0) + 1;
// 새 항목 추가
const [result] = await db.query(
`INSERT INTO issue_report_items (category_id, item_name, display_order, is_active)
VALUES (?, ?, ?, 1)`,
[categoryId, itemName, nextOrder]
);
callback(null, { item_id: result.insertId, item_name: itemName, isNew: true });
} catch (error) {
callback(error);
}
}
};