feat: add permission query to noti
This commit is contained in:
parent
53c0c0fce9
commit
f0db968b20
2 changed files with 16 additions and 4 deletions
|
|
@ -21,6 +21,9 @@ model Notification {
|
|||
|
||||
groupReceiver NotificationGroup[]
|
||||
|
||||
registeredBranchId String?
|
||||
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
|
||||
|
||||
receiver User? @relation(name: "NotificationReceiver", fields: [receiverId], references: [id], onDelete: Cascade)
|
||||
receiverId String?
|
||||
|
||||
|
|
@ -313,6 +316,7 @@ model Branch {
|
|||
quotation Quotation[]
|
||||
workflowTemplate WorkflowTemplate[]
|
||||
taskOrder TaskOrder[]
|
||||
notification Notification[]
|
||||
}
|
||||
|
||||
model BranchBank {
|
||||
|
|
|
|||
|
|
@ -19,10 +19,14 @@ import { Prisma } from "@prisma/client";
|
|||
import { queryOrNot } from "../utils/relation";
|
||||
import { notFoundError } from "../utils/error";
|
||||
import dayjs from "dayjs";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { createPermCondition } from "../services/permission";
|
||||
|
||||
type NotificationCreate = {};
|
||||
type NotificationUpdate = {};
|
||||
|
||||
const permissionCondCompany = createPermCondition((_) => true);
|
||||
|
||||
@Route("/api/v1/notification")
|
||||
@Tags("Notification")
|
||||
export class NotificationController extends Controller {
|
||||
|
|
@ -46,7 +50,10 @@ export class NotificationController extends Controller {
|
|||
OR: [
|
||||
{ receiverId: req.user.sub },
|
||||
req.user.roles.length > 0
|
||||
? { groupReceiver: { some: { name: { in: req.user.roles } } } }
|
||||
? {
|
||||
groupReceiver: { some: { name: { in: req.user.roles } } },
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
}
|
||||
: {},
|
||||
],
|
||||
},
|
||||
|
|
@ -97,8 +104,9 @@ export class NotificationController extends Controller {
|
|||
async createNotification(@Request() req: RequestWithUser, @Body() body: NotificationCreate) {
|
||||
// TODO: implement
|
||||
|
||||
this.setStatus(HttpStatus.CREATED);
|
||||
return {};
|
||||
// this.setStatus(HttpStatus.CREATED);
|
||||
|
||||
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented");
|
||||
}
|
||||
|
||||
@Put("{notificationId}")
|
||||
|
|
@ -110,7 +118,7 @@ export class NotificationController extends Controller {
|
|||
) {
|
||||
// TODO: implement
|
||||
|
||||
return {};
|
||||
throw new HttpError(HttpStatus.NOT_IMPLEMENTED, "Not implemented.", "notImplemented");
|
||||
}
|
||||
|
||||
@Delete("{notificationId}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue