feat: add more role to each endpoint
This commit is contained in:
parent
500e5a8fbe
commit
8e18546b44
3 changed files with 10 additions and 10 deletions
|
|
@ -128,7 +128,7 @@ export class ProductGroup extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const record = await prisma.$transaction(
|
||||
async (tx) => {
|
||||
|
|
@ -166,7 +166,7 @@ export class ProductGroup extends Controller {
|
|||
}
|
||||
|
||||
@Put("{groupId}")
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"])
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
|
||||
async editProductGroup(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: ProductGroupUpdate,
|
||||
|
|
@ -193,7 +193,7 @@ export class ProductGroup extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const record = await prisma.productGroup.findFirst({ where: { id: groupId } });
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ export class ProductController extends Controller {
|
|||
}
|
||||
|
||||
@Post()
|
||||
@Security("keycloak")
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
|
||||
async createProduct(@Request() req: RequestWithUser, @Body() body: ProductCreate) {
|
||||
const productType = await prisma.productType.findFirst({
|
||||
include: {
|
||||
|
|
@ -241,7 +241,7 @@ export class ProductController extends Controller {
|
|||
}
|
||||
|
||||
@Put("{productId}")
|
||||
@Security("keycloak")
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
|
||||
async editProduct(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: ProductUpdate,
|
||||
|
|
@ -294,7 +294,7 @@ export class ProductController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{productId}")
|
||||
@Security("keycloak")
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
|
||||
async deleteProduct(@Path() productId: string) {
|
||||
const record = await prisma.product.findFirst({ where: { id: productId } });
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export class ProductType extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const record = await prisma.productType.findFirst({
|
||||
where: { id: typeId },
|
||||
|
|
@ -104,7 +104,7 @@ export class ProductType extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const productGroup = await prisma.productGroup.findFirst({
|
||||
where: { id: body.productGroupId },
|
||||
|
|
@ -161,7 +161,7 @@ export class ProductType extends Controller {
|
|||
}
|
||||
|
||||
@Put("{typeId}")
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"])
|
||||
@Security("keycloak", ["system", "head_of_admin", "admin", "branch_accountant", "accountant"])
|
||||
async editProductType(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: ProductTypeUpdate,
|
||||
|
|
@ -210,7 +210,7 @@ export class ProductType extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const record = await prisma.productType.findFirst({ where: { id: typeId } });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue