Skip to content

Config And Template Surface — Business Rules

Tổng quan

Domain này gom phần notification mà IT/ops nhìn thấy như một bề mặt cấu hình:

  • notification admin list/create/detail
  • notification template
  • email request + email template
  • phần template SMS/ZNS và trigger config đang sống trong DB/service notification nhưng ownership UI lại rơi nhiều về settings

Điểm quan trọng là notification trong FE hiện không chỉ là nơi "cấu hình template". Nó đang là một admin surface pha trộn giữa:

  • cấu hình nội dung/thông điệp,
  • chọn audience,
  • lên lịch gửi,
  • xem lại lịch sử request đã tạo.

Scope nghiệp vụ

NhómVai tròSurface chính
Notification requestsTạo và quản lý notification in-app/push dạng generalNotifications, NotificationCreate, NotificationDetail
Notification templatesQuản trị template push/in-app theo trigger_codenotification_template, notification_trigger_conditions
Email requestsTạo/lưu request email và đọc lịch sử gửiemail_request, sendEmails
Email templatesQuản trị subject/body/html theo localeemail_template
SMS/ZNS template configQuản trị template SMS, ZNS, trigger conditionsms_template, zns_template, zns_config, zns_oa_list

Luồng chính

text
IT/ops mở admin notification surface
  -> tạo notification hoặc chỉnh sửa notification đã có
  -> nhập headings / contents / message payload / icon / target
  -> chọn audience theo topic, user_ids hoặc filter
  -> chọn send_after
  -> submit
  -> backend action save request vào DB hoặc gửi ngay tùy path

IT/ops quản lý template
  -> CRUD notification/email template
  -> mapping trigger_code -> nội dung template
  -> runtime service load template để apply variables khi gửi

Quy tắc nghiệp vụ

Quy tắc
BR-NCF-001FE admin surface của notification chỉ mở cho ITLeader, ITStaff; người dùng business thường chỉ chạm runtime result chứ không vào route quản trị.
BR-NCF-002Một notification admin hợp lệ phải có ít nhất một trong các cơ chế target: broadcast, user_ids, hoặc topics.
BR-NCF-003FE đang cho phép hai kiểu body chính: message hoặc url; nếu là url thì metadata chỉ giữ deep-link thay vì rich text message.
BR-NCF-004FE luôn ép locale mặc định phải có headingscontents, rồi tự fill locale còn thiếu từ locale mặc định.
BR-NCF-005Nếu người dùng chọn "all" trong recipient picker, FE sẽ expand ra toàn bộ account.id theo filter hiện tại thay vì lưu literal "all".
BR-NCF-006notification_template là template family cho push/in-app; email_template, sms_template, zns_template là các family riêng, không phải cùng một bảng.
BR-NCF-007Template runtime gắn với trigger qua trigger_code; đây là điểm nối giữa domain notification với ecommerce/hrm/project/wallet.
BR-NCF-008sendEmailssendSMS đều có hai mode: Save = true để lưu request vào DB, Save = false để gửi ngay.
BR-NCF-009Khi request email/SMS dùng template, backend sẽ load nội dung từ template rồi apply variables dạng {\{.key}\} trước khi gửi.
BR-NCF-010scheduleTask của nhánh notification-v2-api là primitive chung để persist future task vào scheduled_tasks, không chỉ dành riêng cho ZNS.

Boundary

BoundaryGhi chú
settingsSMS/ZNS/notification template management trong thực tế bị split ownership với settings
userAudience chọn theo account, role, branch, department, customer group/source
cmsCampaign/event/voucher có thể bơm trigger code sang notification template
ecommerce / wallet / hrm / projectsNhiều trigger code thực chất đến từ domain khác, notification chỉ giữ template và delivery

Rủi ro / Findings

MứcFinding
P1FE khai báo đủ route cho notification template, email, email template, nhưng nhiều page hiện vẫn là placeholder return <div></div>.
P1navigation của module đang bị comment toàn bộ, nên admin surface tồn tại theo route nhưng không chắc hiện trên sidebar.
P1FE đang mô tả semantics "lên lịch" rất rõ, nhưng implementation path phía backend không khớp hoàn toàn với cảm nhận này.
P2Ownership template bị tách giữa notificationsettings, nên BA/dev rất dễ đọc nhầm chỗ cấu hình với chỗ runtime.