feat: 실시간 알림 시스템 (Web Push + 알림 벨 + 서비스간 알림 연동)
- Phase 1: 모든 서비스 헤더에 알림 벨 UI 추가 (notification-bell.js) - Phase 2: VAPID Web Push 구독/전송 (push-sw.js, pushSubscription API) - Phase 3: 내부 알림 API + notifyHelper로 서비스간 알림 연동 - tksafety: 출입 승인/반려, 안전교육 완료, 방문자 체크인 - tkpurchase: 일용공 신청, 작업보고서 제출 - system2-report: 신고 접수/확인/처리완료 - Phase 4: 30일 이상 알림 자동 정리 cron, Redis 캐싱 - CORS에 tkuser/tkpurchase/tksafety 서브도메인 추가 - HTML cache busting 버전 갱신 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
const workIssueModel = require('../models/workIssueModel');
|
||||
const imageUploadService = require('../services/imageUploadService');
|
||||
const mProjectService = require('../services/mProjectService');
|
||||
const notify = require('../utils/notifyHelper');
|
||||
|
||||
// ==================== 신고 카테고리 관리 ====================
|
||||
|
||||
@@ -191,6 +192,17 @@ exports.createReport = async (req, res) => {
|
||||
|
||||
const reportId = await workIssueModel.createReport(reportData);
|
||||
|
||||
// 알림: 신고 접수
|
||||
notify.send({
|
||||
type: 'safety',
|
||||
title: '신고 접수',
|
||||
message: `${catInfo ? catInfo.category_name : '문제'} 신고가 접수되었습니다.`,
|
||||
link_url: '/pages/safety-report-list.html',
|
||||
reference_type: 'work_issue_reports',
|
||||
reference_id: reportId,
|
||||
created_by: req.user.id || req.user.user_id
|
||||
});
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
message: '문제 신고가 등록되었습니다.',
|
||||
@@ -398,6 +410,18 @@ exports.receiveReport = async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
await workIssueModel.receiveReport(id, req.user.user_id);
|
||||
|
||||
// 알림: 신고 상태 변경 → 접수됨
|
||||
notify.send({
|
||||
type: 'safety',
|
||||
title: '신고 접수 확인',
|
||||
message: '신고가 접수되어 처리가 시작됩니다.',
|
||||
link_url: '/pages/safety-report-list.html',
|
||||
reference_type: 'work_issue_reports',
|
||||
reference_id: parseInt(id),
|
||||
created_by: req.user.user_id
|
||||
});
|
||||
|
||||
res.json({ success: true, message: '신고가 접수되었습니다.' });
|
||||
} catch (err) {
|
||||
console.error('신고 접수 실패:', err);
|
||||
@@ -442,6 +466,18 @@ exports.completeReport = async (req, res) => {
|
||||
if (resolution_photos[1]) resolution_photo_path2 = await imageUploadService.saveBase64Image(resolution_photos[1], 'resolution');
|
||||
|
||||
await workIssueModel.completeReport(id, { resolution_notes, resolution_photo_path1, resolution_photo_path2, resolved_by: req.user.user_id });
|
||||
|
||||
// 알림: 신고 처리 완료
|
||||
notify.send({
|
||||
type: 'safety',
|
||||
title: '신고 처리 완료',
|
||||
message: '신고 처리가 완료되었습니다.',
|
||||
link_url: '/pages/safety-report-list.html',
|
||||
reference_type: 'work_issue_reports',
|
||||
reference_id: parseInt(id),
|
||||
created_by: req.user.user_id
|
||||
});
|
||||
|
||||
res.json({ success: true, message: '처리가 완료되었습니다.' });
|
||||
} catch (err) {
|
||||
console.error('처리 완료 실패:', err);
|
||||
|
||||
Reference in New Issue
Block a user