feat(purchase): 소모품 신청 시스템 v2 — 모바일 최적화, 스마트 검색, 그룹화, 입고 알림

- 4단계 상태 플로우: pending → grouped → purchased → received
- 한국어 스마트 검색: 초성 매칭(ㅁㅈㄱ→면장갑), 별칭 테이블, 인메모리 캐시
- 모바일 전용 신청 페이지: 바텀시트 UI, FAB, 카드 리스트, 스크롤 페이지네이션
- 인라인 품목 등록: 미등록 품목 검색→등록→신청 단일 트랜잭션
- 관리자 그룹화: 체크박스 다중 선택, 구매 그룹(batch) 생성/일괄 구매/입고
- 입고 처리: 사진+보관위치 등록, 부분 입고 허용, batch 자동 상태 전환
- 알림: notifyHelper에 target_user_ids 추가, 구매진행중/입고완료 시 신청자 ntfy+push

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-01 09:21:20 +09:00
parent 0cc37d7773
commit cf75462380
24 changed files with 2138 additions and 25 deletions

View File

@@ -169,21 +169,36 @@ const notificationController = {
return res.status(403).json({ success: false, message: '권한이 없습니다.' });
}
const { type, title, message, link_url, reference_type, reference_id, created_by } = req.body;
const { type, title, message, link_url, reference_type, reference_id, created_by, target_user_ids } = req.body;
if (!title) {
return res.status(400).json({ success: false, message: '알림 제목은 필수입니다.' });
}
const results = await notificationModel.createTypedNotification({
type: type || 'system',
title,
message,
link_url,
reference_type,
reference_id,
created_by
});
let results;
if (target_user_ids && Array.isArray(target_user_ids) && target_user_ids.length > 0) {
// 특정 사용자 직접 알림 (type 기반 브로드캐스트 대신)
results = await notificationModel.createTargetedNotification({
type: type || 'system',
title,
message,
link_url,
reference_type,
reference_id,
created_by,
target_user_ids
});
} else {
results = await notificationModel.createTypedNotification({
type: type || 'system',
title,
message,
link_url,
reference_type,
reference_id,
created_by
});
}
res.json({
success: true,

View File

@@ -304,6 +304,31 @@ const notificationModel = {
sendPushToUsers(recipientIds, { title, body: message || '', url: link_url || '/' });
return results;
},
// 특정 사용자 직접 알림 (target_user_ids 기반, type 브로드캐스트 아님)
async createTargetedNotification(notificationData) {
const { type, title, message, link_url, reference_type, reference_id, created_by, target_user_ids } = notificationData;
const results = [];
for (const userId of target_user_ids) {
const notificationId = await this.create({
user_id: userId,
type,
title,
message,
link_url,
reference_type,
reference_id,
created_by
});
results.push(notificationId);
}
// ntfy + WebPush 발송
sendPushToUsers(target_user_ids, { title, body: message || '', url: link_url || '/' });
return results;
}
};