Demo

NotificationService

User သို့မဟုတ် role သို့ in-app / push notification ပို့ပေးပါသည်။ /app/ စာမျက်နှာများအတွက် real-time delivery နှင့် ချိတ်ဆက်ထားပါသည်။

Inject

TSXinject
1import { 2 ContainerRegistryManager, 3 NotificationService, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class MyPluginService { 10 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private notificationService: NotificationService; 12}

send(props: CreateNotificationDto)

Notification အတန်း သိမ်းပြီး push ပို့ပါသည်။ userIds → သတ်မှတ် user; roleIds → သတ်မှတ် role; နှစ်ခုလုံး မပေးပါက အားလုံးသို့ ပို့ပါသည်။

  • title / subtitle / body — မဖြစ်မနေ လိုအပ်ပါသည်
  • pluginName — ပုံမှန်အားဖြင့် metadata.name
  • topic — event key
  • userIds? / roleIds? — ပစ်မှတ်
  • url? / data? — deep link နှင့် extra payload
TSXsend
1import { 2 ContainerRegistryManager, 3 Inject, 4 NotificationService, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7import metadata from "../../module.metadata.json" with { type: "json" }; 8 9@Service() 10export class ProjectNotifyService { 11 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN) 12 private notificationService: NotificationService; 13 14 async notifyUpdate() { 15 await this.notificationService.send({ 16 userIds: [1, 2], 17 // roleIds: [1], 18 title: "Project Updated", 19 subtitle: "Status change", 20 body: "Status changed to Completed.", 21 pluginName: metadata.name, 22 topic: "project-update", 23 url: "/app/projects/12", 24 data: { projectId: 12 }, 25 }); 26 } 27}

Inbox method များ

  • get({ userId, roleId, skip, limit }) — user မြင်ရသော notification စာရင်း
  • getUnreadNotiCount({ userId, roleId }) — မဖတ်ရသေးသော အရေအတွက်
  • markRead({ id, userId }) — ဖတ်ပြီးဟု မှတ်ပါသည်
TSXinbox
1import { 2 ContainerRegistryManager, 3 Inject, 4 NotificationService, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class InboxService { 10 @Inject(NotificationService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private notificationService: NotificationService; 12 13 async list(userId: number, roleId: number) { 14 const unread = await this.notificationService.getUnreadNotiCount({ 15 userId, 16 roleId, 17 }); 18 const items = await this.notificationService.get({ 19 userId, 20 roleId, 21 skip: 0, 22 limit: 20, 23 }); 24 return { unread, items }; 25 } 26 27 async read(id: number, userId: number) { 28 await this.notificationService.markRead({ id, userId }); 29 } 30}