Files
Henry_Du 4ce4649aaf
Build VoiceHub FPK / build-fpk (push) Failing after 56m5s
Build and Push Docker Image / build-and-push (push) Canceled after 1h9m35s
初次提交
2026-09-06 08:19:02 +08:00

33 lines
762 B
TypeScript

import { and, db, eq, notifications } from '~/drizzle/db'
export default defineEventHandler(async (event) => {
// 检查用户认证
const user = event.context.user
if (!user) {
throw createError({
statusCode: 401,
message: '需要登录才能标记通知'
})
}
try {
// 标记该用户的所有未读通知为已读
const result = await db
.update(notifications)
.set({ read: true })
.where(and(eq(notifications.userId, user.id), eq(notifications.read, false)))
return {
success: true,
count: result.count
}
} catch (err) {
console.error('标记所有通知失败:', err)
throw createError({
statusCode: 500,
message: '标记所有通知失败'
})
}
})