feat: add more role to each endpoint

This commit is contained in:
Methapon2001 2024-07-03 09:51:19 +07:00
parent 500e5a8fbe
commit 8e18546b44
3 changed files with 10 additions and 10 deletions

View file

@ -128,7 +128,7 @@ export class ProductGroup extends Controller {
} }
@Post() @Post()
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async createProductGroup(@Request() req: RequestWithUser, @Body() body: ProductGroupCreate) { async createProductGroup(@Request() req: RequestWithUser, @Body() body: ProductGroupCreate) {
const record = await prisma.$transaction( const record = await prisma.$transaction(
async (tx) => { async (tx) => {
@ -166,7 +166,7 @@ export class ProductGroup extends Controller {
} }
@Put("{groupId}") @Put("{groupId}")
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async editProductGroup( async editProductGroup(
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: ProductGroupUpdate, @Body() body: ProductGroupUpdate,
@ -193,7 +193,7 @@ export class ProductGroup extends Controller {
} }
@Delete("{groupId}") @Delete("{groupId}")
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async deleteProductGroup(@Path() groupId: string) { async deleteProductGroup(@Path() groupId: string) {
const record = await prisma.productGroup.findFirst({ where: { id: groupId } }); const record = await prisma.productGroup.findFirst({ where: { id: groupId } });

View file

@ -164,7 +164,7 @@ export class ProductController extends Controller {
} }
@Post() @Post()
@Security("keycloak") @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async createProduct(@Request() req: RequestWithUser, @Body() body: ProductCreate) { async createProduct(@Request() req: RequestWithUser, @Body() body: ProductCreate) {
const productType = await prisma.productType.findFirst({ const productType = await prisma.productType.findFirst({
include: { include: {
@ -241,7 +241,7 @@ export class ProductController extends Controller {
} }
@Put("{productId}") @Put("{productId}")
@Security("keycloak") @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async editProduct( async editProduct(
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: ProductUpdate, @Body() body: ProductUpdate,
@ -294,7 +294,7 @@ export class ProductController extends Controller {
} }
@Delete("{productId}") @Delete("{productId}")
@Security("keycloak") @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async deleteProduct(@Path() productId: string) { async deleteProduct(@Path() productId: string) {
const record = await prisma.product.findFirst({ where: { id: productId } }); const record = await prisma.product.findFirst({ where: { id: productId } });

View file

@ -87,7 +87,7 @@ export class ProductType extends Controller {
} }
@Get("{typeId}") @Get("{typeId}")
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async getProductTypeById(@Path() typeId: string) { async getProductTypeById(@Path() typeId: string) {
const record = await prisma.productType.findFirst({ const record = await prisma.productType.findFirst({
where: { id: typeId }, where: { id: typeId },
@ -104,7 +104,7 @@ export class ProductType extends Controller {
} }
@Post() @Post()
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async createProductType(@Request() req: RequestWithUser, @Body() body: ProductTypeCreate) { async createProductType(@Request() req: RequestWithUser, @Body() body: ProductTypeCreate) {
const productGroup = await prisma.productGroup.findFirst({ const productGroup = await prisma.productGroup.findFirst({
where: { id: body.productGroupId }, where: { id: body.productGroupId },
@ -161,7 +161,7 @@ export class ProductType extends Controller {
} }
@Put("{typeId}") @Put("{typeId}")
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async editProductType( async editProductType(
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: ProductTypeUpdate, @Body() body: ProductTypeUpdate,
@ -210,7 +210,7 @@ export class ProductType extends Controller {
} }
@Delete("{typeId}") @Delete("{typeId}")
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"]) @Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
async deleteProductType(@Path() typeId: string) { async deleteProductType(@Path() typeId: string) {
const record = await prisma.productType.findFirst({ where: { id: typeId } }); const record = await prisma.productType.findFirst({ where: { id: typeId } });