-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f2cc61
commit 21670c0
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
prisma/migrations/20240418080551_add_announcements/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- CreateTable | ||
CREATE TABLE "Announcement" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"isSent" BOOLEAN NOT NULL DEFAULT false, | ||
"eventId" TEXT, | ||
"eventGroupId" TEXT, | ||
|
||
CONSTRAINT "Announcement_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Announcement" ADD CONSTRAINT "Announcement_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {AnnouncementScalarFieldEnum, ModelConfig} from "../generated/typegraphql-prisma"; | ||
import {Authorized} from "type-graphql"; | ||
import {AuthRole} from "../context"; | ||
|
||
let defaultPerms: {[key: string]: MethodDecorator[]} = {}; | ||
Object.keys(AnnouncementScalarFieldEnum).forEach((value: string) => defaultPerms[value] = [Authorized(AuthRole.ADMIN, AuthRole.MANAGER)]) | ||
|
||
export const announcementEnhanceConfig: ModelConfig<"Announcement"> = { | ||
fields: { | ||
...defaultPerms, | ||
id: [], | ||
createdAt: [], | ||
updatedAt: [], | ||
content: [], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {ResolverActionsConfig, AnnouncementCrudResolver} from "../generated/typegraphql-prisma"; | ||
import {Authorized} from "type-graphql"; | ||
import {AuthRole} from "../context"; | ||
|
||
let defaultPerms: {[key: string]: MethodDecorator[]} = {}; | ||
Object.getOwnPropertyNames(AnnouncementCrudResolver.prototype).forEach((value: string) => defaultPerms[value] = [Authorized(AuthRole.ADMIN)]) | ||
|
||
export const announcementEnhanceConfig: ResolverActionsConfig<"Announcement"> = { | ||
...defaultPerms, | ||
createAnnouncement: [Authorized(AuthRole.ADMIN, AuthRole.MANAGER)], | ||
updateAnnouncement: [Authorized(AuthRole.ADMIN)], | ||
deleteAnnouncement: [Authorized(AuthRole.ADMIN)], | ||
} |