feat(server): 站内通知基础设施与关键事件触发(F14,F30)

- 新增 notifications 表与 API(list/mark-read)
- submit/approve/reject/return/transfer/pay/forgot-password 写入站内通知
- 通知失败降级,不阻塞主流程
这个提交包含在:
2026-02-09 17:45:17 +08:00
父节点 8bd068f2a3
当前提交 5faf843cee
共修改 8 个文件,包含 495 行新增和 1 行删除
@@ -0,0 +1,23 @@
-- CreateTable
CREATE TABLE "notifications" (
"id" UUID NOT NULL,
"recipient_employee_id" UUID NOT NULL,
"type" VARCHAR(64) NOT NULL,
"title" VARCHAR(200) NOT NULL,
"body" TEXT,
"target_type" VARCHAR(64),
"target_id" UUID,
"read_at" TIMESTAMP(3),
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "notifications_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "notifications_recipient_employee_id_created_at_idx" ON "notifications"("recipient_employee_id", "created_at");
-- CreateIndex
CREATE INDEX "idx_notifications_unread_query" ON "notifications"("recipient_employee_id", "read_at", "created_at");
-- AddForeignKey
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_recipient_employee_id_fkey" FOREIGN KEY ("recipient_employee_id") REFERENCES "employees"("id") ON DELETE CASCADE ON UPDATE CASCADE;