feat: product related permission
This commit is contained in:
parent
6ee2e9c4da
commit
25a1f3c4a4
2 changed files with 11 additions and 2 deletions
|
|
@ -35,14 +35,15 @@ type ProductGroupUpdate = {
|
||||||
|
|
||||||
@Route("api/v1/product-group")
|
@Route("api/v1/product-group")
|
||||||
@Tags("Product Group")
|
@Tags("Product Group")
|
||||||
@Security("keycloak")
|
|
||||||
export class ProductGroup extends Controller {
|
export class ProductGroup extends Controller {
|
||||||
@Get("stats")
|
@Get("stats")
|
||||||
|
@Security("keycloak")
|
||||||
async getProductGroupStats() {
|
async getProductGroupStats() {
|
||||||
return await prisma.productGroup.count();
|
return await prisma.productGroup.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@Security("keycloak")
|
||||||
async getProductGroup(
|
async getProductGroup(
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() status?: Status,
|
@Query() status?: Status,
|
||||||
|
|
@ -110,6 +111,7 @@ export class ProductGroup extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{groupId}")
|
@Get("{groupId}")
|
||||||
|
@Security("keycloak")
|
||||||
async getProductGroupById(@Path() groupId: string) {
|
async getProductGroupById(@Path() groupId: string) {
|
||||||
const record = await prisma.productGroup.findFirst({
|
const record = await prisma.productGroup.findFirst({
|
||||||
where: { id: groupId },
|
where: { id: groupId },
|
||||||
|
|
@ -126,6 +128,7 @@ export class ProductGroup extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "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) => {
|
||||||
|
|
@ -163,6 +166,7 @@ export class ProductGroup extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put("{groupId}")
|
@Put("{groupId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"])
|
||||||
async editProductGroup(
|
async editProductGroup(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: ProductGroupUpdate,
|
@Body() body: ProductGroupUpdate,
|
||||||
|
|
@ -189,6 +193,7 @@ export class ProductGroup extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{groupId}")
|
@Delete("{groupId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "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 } });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ type ProductTypeUpdate = {
|
||||||
|
|
||||||
@Route("api/v1/product-type")
|
@Route("api/v1/product-type")
|
||||||
@Tags("Product Type")
|
@Tags("Product Type")
|
||||||
@Security("keycloak")
|
|
||||||
export class ProductType extends Controller {
|
export class ProductType extends Controller {
|
||||||
@Get("stats")
|
@Get("stats")
|
||||||
async getProductTypeStats() {
|
async getProductTypeStats() {
|
||||||
|
|
@ -45,6 +44,7 @@ export class ProductType extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@Security("keycloak")
|
||||||
async getProductType(
|
async getProductType(
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() productGroupId?: string,
|
@Query() productGroupId?: string,
|
||||||
|
|
@ -87,6 +87,7 @@ export class ProductType extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{typeId}")
|
@Get("{typeId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "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 },
|
||||||
|
|
@ -103,6 +104,7 @@ export class ProductType extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "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 },
|
||||||
|
|
@ -159,6 +161,7 @@ export class ProductType extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put("{typeId}")
|
@Put("{typeId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "accountant"])
|
||||||
async editProductType(
|
async editProductType(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: ProductTypeUpdate,
|
@Body() body: ProductTypeUpdate,
|
||||||
|
|
@ -207,6 +210,7 @@ export class ProductType extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{typeId}")
|
@Delete("{typeId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "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 } });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue