notifications.service.js 829 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.notificationsService = exports.NotificationsService = void 0;
  4. const models_1 = require("../../models");
  5. /**
  6. * 通知服务
  7. */
  8. class NotificationsService {
  9. /**
  10. * 获取用户通知列表
  11. */
  12. async getNotifications(userId) {
  13. return await models_1.prisma.notification.findMany({
  14. where: { userId },
  15. orderBy: { createdAt: 'desc' },
  16. take: 50,
  17. });
  18. }
  19. /**
  20. * 标记通知为已读
  21. */
  22. async markAsRead(id) {
  23. return await models_1.prisma.notification.update({
  24. where: { id },
  25. data: { isRead: true },
  26. });
  27. }
  28. }
  29. exports.NotificationsService = NotificationsService;
  30. exports.notificationsService = new NotificationsService();