Appearance
Notification - Technical Map
Auto-generated bởi codebase-doc-generator ngày 2026-03-23 (verified từ code thực). Không chỉnh sửa thủ công.
Routes
| Route | Path | Mục đích |
|---|---|---|
ROUTE_NOTIFICATION | /n/notification | Danh sách notification |
ROUTE_NOTIFICATION_CREATE | /n/notification/create | Tạo notification |
ROUTE_NOTIFICATION_DETAIL | /n/notification/:id | Xem chi tiết notification |
ROUTE_NOTIFICATION_UPDATE | /n/notification/:id/edit | Chỉnh sửa notification |
ROUTE_NOTIFICATION_UPDATE_IN_DETAIL | /n/notification/:id/update-in-detail | Chỉnh sửa khi đang ở detail |
ROUTE_NOTIFICATION_TEMPLATE | /n/notification-template | Danh sách template notification |
ROUTE_NOTIFICATION_TEMPLATE_CREATE | /n/notification-template/create | Tạo template notification |
ROUTE_NOTIFICATION_TEMPLATE_DETAIL | /n/notification-template/:id | Chi tiết template notification |
ROUTE_EMAIL | /n/email | Danh sách email |
ROUTE_EMAIL_CREATE | /n/email/create | Tạo email |
ROUTE_EMAIL_DETAIL | /n/email/:id | Chi tiết email |
ROUTE_EMAIL_TEMPLATE | /n/email-template | Danh sách email template |
ROUTE_EMAIL_TEMPLATE_CREATE | /n/email-template/create | Tạo email template |
ROUTE_EMAIL_TEMPLATE_DETAIL | /n/email-template/:id | Chi tiết email template |
Navigation & Permission
| Item | Giá trị |
|---|---|
MODULE_NOTIFICATION | n |
| Shared moderator permissions | ITLeader, ITStaff |
Shared moduleId | notification |
| Navigation status | Đã khai báo nhưng toàn bộ block navigation đang bị comment |
FE Pages (12)
Có logic thật
| Page | File | Vai trò |
|---|---|---|
| Notifications | pages/Notifications.tsx | Render NotificationTable hoặc RouterView detail |
| NotificationCreate | pages/NotificationCreate.tsx | Wrapper cho form tạo/sửa |
| NotificationDetail | pages/NotificationDetail.tsx | Card detail, preview recipient, delete/edit |
Placeholder / scaffold
| Page | File | Trạng thái |
|---|---|---|
| NotificationTemplates | pages/NotificationTemplates.tsx | Placeholder |
| NotificationTemplateCreate | pages/NotificationTemplateCreate.tsx | Placeholder |
| NotificationTemplateDetail | pages/NotificationTemplateDetail.tsx | Placeholder |
| Emails | pages/Emails.tsx | Placeholder |
| EmailCreate | pages/EmailCreate.tsx | Placeholder |
| EmailDetail | pages/EmailDetail.tsx | Placeholder |
| EmailTemplates | pages/EmailTemplates.tsx | Placeholder |
| EmailTemplateCreate | pages/EmailTemplateCreate.tsx | Placeholder |
| EmailTemplateDetail | pages/EmailTemplateDetail.tsx | Placeholder |
FE Components (10)
| Component | Vai trò |
|---|---|
NotificationTable | Bảng danh sách notification quản trị |
NotificationCreate | Component submit create/update notification |
NotificationForm | Form lõi cho targeting, content, schedule |
NotificationStatus | Badge trạng thái gửi |
NotificationButton | Icon chuông + badge unread + mở drawer |
NotificationList | Inbox cá nhân với paging và mark-read |
NotificationListener | Runtime listener cho push/message |
NotificationTypeSelect | Chọn loại notification |
FilteredTargetSelection | Chọn đối tượng theo filter |
FilteredTargetTable | Preview danh sách recipient theo filter |
GraphQL Operations
File: diva-admin/src/modules/notification/graphql/notification.graphql
Personal inbox
| Operation | Mục đích |
|---|---|
GetMyNotifications | Lấy notification cá nhân |
WatchUnreadNotificationsAggregate | Subscription unread stats |
GetUnreadNotificationsAggregate | Query unread stats |
GetUnreadNotificationIDs | Lấy list unread ids để mark-all-read |
UpsertNotificationUsers | Mark read/delete trên bảng notification_user |
Admin notification
| Operation | Mục đích |
|---|---|
GetNotifications | Query thẳng bảng notification |
GetNotificationPaginations | Query qua notification_filter view |
GetNotificationByPk | Lấy detail notification |
SendNotifications | Gọi action sendNotifications |
UpdateNotificationStatus | Bật/tắt visible theo subject_id |
UpdateNotification | Update notification by pk |
DeleteNotificationByPk | Xóa notification |
GetNotificationMasterData | Lấy master data notification |
GetListIdByFilter | Lấy list recipient ids theo filter |
FE Runtime logic
NotificationForm.tsx
| Logic | Ghi chú |
|---|---|
| Locale dictionaries | Dùng createDictionaryLocales() để build headings, contents, message_content đa ngôn ngữ |
| Content type | message hoặc url |
| Targeting | broadcast, topics, user_ids, filter_value |
| Validation | Chặn nếu thiếu content/url hoặc thiếu heading/content ở locale mặc định |
| Send time | send_after convert bằng createDate(..., "DD/MM/YYYY HH:mm") |
| Message cleanup | Strip HTML trước khi submit |
NotificationDetail.tsx
| Logic | Ghi chú |
|---|---|
| Detail source | GetNotificationByPk(id) |
| Filter rehydrate | Dựng lại customer/employee filter từ notification.data |
| Target preview | Gọi GetListIdByFilter để intersect với modelValue.user_ids |
| Sent state | isSent nếu send_after <= now |
| Delete | DeleteNotificationByPk rồi redirect về list |
NotificationButton.tsx
| Logic | Ghi chú |
|---|---|
| Count cache | Dùng Pinia store + localStorage |
| Reload throttling | Không query lại nếu lần request trước < 60 giây |
| Drawer | Mở QDialog bên phải, render NotificationList |
NotificationList.tsx
| Logic | Ghi chú |
|---|---|
| Personal feed | Query notification_personal(args) |
| Read one | Upsert notification_user(read = true) |
| Read all | Lấy unread ids rồi bulk upsert |
| Show all / unread only | Điều khiển bằng _read trong args |
| Routing | Resolve route từ subject_type thông qua NOTIFICATION_TYPE |
NotificationListener.tsx
| Logic | Ghi chú |
|---|---|
| Subscription source | useNotification().onMessage() |
| Runtime effect | Hiện Quasar notify popup khi có push hiển thị |
| Guard | Chỉ subscribe khi globalStore.account.id tồn tại |
useOneSignal.ts
| Logic | Ghi chú |
|---|---|
| Init | oneSignal.init({ appId: Config.oneSignalAppId }) |
| Auto register | Nếu chưa bật push thì registerForPushNotifications() |
| User binding | setExternalUserId(userId) |
| Event | Lắng nghe notificationDisplay |
| Tag APIs | Hỗ trợ sendTags, getTags, deleteTags |
Backend Services
| Service | Vai trò |
|---|---|
notification-api | Gửi push, email, SMS; scheduler gửi pending notification |
notification-v2-api | ZNS, scheduled tasks, integrations khác |
controller | CRUD tables/functions của notification DB |
Backend Actions / Schedulers
notification-api
| Action/Scheduler | Vai trò |
|---|---|
sendNotifications | Gửi ad-hoc hoặc persist notification |
sendEmails | Lấy template email, apply vars, save hoặc send-now |
sendSMS | Lấy template SMS, apply vars, save hoặc send-now |
notification_send | Scheduler quét notification pending và gửi |
notification_cleanup | Cleanup notification cũ/pending theo scheduler riêng |
notification-v2-api
| Action/Event | Vai trò |
|---|---|
scheduleTask | Persist scheduled_tasks và nạp vào scheduler runtime |
zns_request_insert | Gửi ZNS ngay hoặc schedule sau |
scheduled_task_insert / scheduled_task_update | Đồng bộ runtime scheduler |
Messenger model
NotificationInput
| Field | Ý nghĩa |
|---|---|
TemplateID | Template notification sử dụng |
Broadcast | Gửi toàn hệ thống |
Headings, Contents, ContentsHTML | Nội dung đa ngôn ngữ |
SubjectType, SubjectID | Gắn context điều hướng |
Topics, UserIDs | Nhóm người nhận |
SendAfter | Thời điểm gửi |
Data | Payload phụ trợ |
Metadata | URL, icon, buttons, image, badge, subtitle... |
NotificationMetadata
| Field nhóm | Vai trò |
|---|---|
| Deep link / media | URL, ImageURL, SmallIcon, LargeIcon |
| Grouping | GroupID, GroupMessage, CollapseID |
| Delivery | TTL, Priority, DelayedOption, DeliveryTimeOfDay |
| Platform overrides | IOS*, Android*, Huawei*, APNSPushTypeOverride |
| Buttons | Action buttons cho notification |
Store / Data model
Notification domain
| Object | Vai trò |
|---|---|
notification | Bản ghi notification gốc |
notification_user | Trạng thái đọc/xóa theo user |
notification_template | Template push/in-app |
notification_filter | View/filter cho admin list |
notification_personal | Function/view cho inbox cá nhân |
notification_personal_stats | Aggregate unread/read stats |
Email / SMS / ZNS
| Object | Vai trò |
|---|---|
email_request | Hàng đợi/lịch sử email |
email_template | Template email |
sms_request | Hàng đợi/lịch sử SMS |
sms_template | Template SMS |
zns_request | Hàng đợi/lịch sử ZNS |
zns_template | Template ZNS |
notification_queue | Queue metadata-driven cho SMS/ZNS |
scheduled_tasks | Tác vụ gửi deferred trong v2 |
Trigger codes và domain links
| Nhóm | Ví dụ trigger code |
|---|---|
| Requests / HR | noti_request_working_schedule_pending, noti_late_arrival, noti_leave_early_employee |
| Appointments / orders | noti_appointment_reminder, noti_order_confirm, noti_order_complete |
| KPI / task / project | noti_staff_kpi_assign, noti_task_updated, noti_project_task_comment_new |
| Commission / wallet | noti_commission_received_customer, noti_wallet_deposit_success |
| Events | noti_birthday_user, noti_birthday_customer, noti_voucher_activated_print |
Rủi ro / Findings kỹ thuật
| # | Note |
|---|---|
| 1 | Nhiều page quản trị email/template và notification template hiện vẫn là stub FE dù route đã khai báo đầy đủ. |
| 2 | navigation của module đang bị comment, nên khả năng cao module không có menu sidebar mặc định. |
| 3 | Admin notification và personal notification dùng hai bề mặt đọc khác nhau: bảng/view quản trị vs function notification_personal. |
| 4 | Backend notification đang chia đôi giữa notification-api và notification-v2-api, với ZNS/scheduled task đi theo nhánh v2. |