feat: add delete notification

This commit is contained in:
Methapon Metanipat 2024-10-30 14:08:39 +07:00 committed by Methapon2001
parent b4b7d633d1
commit 549410e9e3

View file

@ -17,6 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import prisma from "../db";
import { Prisma } from "@prisma/client";
import { queryOrNot } from "../utils/relation";
import { notFoundError } from "../utils/error";
type NotificationCreate = {};
type NotificationUpdate = {};
@ -95,8 +96,8 @@ export class NotificationController extends Controller {
@Delete("{notificationId}")
@Security("keycloak")
async deleteNotification(@Request() req: RequestWithUser, @Path() notificationId: string) {
// TODO: implement
return {};
const record = await prisma.notification.deleteMany({ where: { id: notificationId } });
if (record.count === 0) throw notFoundError("Notification");
return record;
}
}