feat: customer permission role
This commit is contained in:
parent
6113b56f93
commit
6c521c1b09
1 changed files with 6 additions and 1 deletions
|
|
@ -117,9 +117,9 @@ function imageLocation(id: string) {
|
||||||
|
|
||||||
@Route("api/v1/customer")
|
@Route("api/v1/customer")
|
||||||
@Tags("Customer")
|
@Tags("Customer")
|
||||||
@Security("keycloak")
|
|
||||||
export class CustomerController extends Controller {
|
export class CustomerController extends Controller {
|
||||||
@Get("type-stats")
|
@Get("type-stats")
|
||||||
|
@Security("keycloak")
|
||||||
async stat() {
|
async stat() {
|
||||||
const list = await prisma.customer.groupBy({
|
const list = await prisma.customer.groupBy({
|
||||||
by: "customerType",
|
by: "customerType",
|
||||||
|
|
@ -139,6 +139,7 @@ export class CustomerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@Security("keycloak")
|
||||||
async list(
|
async list(
|
||||||
@Query() customerType?: CustomerType,
|
@Query() customerType?: CustomerType,
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
|
|
@ -203,6 +204,7 @@ export class CustomerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{customerId}")
|
@Get("{customerId}")
|
||||||
|
@Security("keycloak")
|
||||||
async getById(@Path() customerId: string) {
|
async getById(@Path() customerId: string) {
|
||||||
const record = await prisma.customer.findFirst({
|
const record = await prisma.customer.findFirst({
|
||||||
include: {
|
include: {
|
||||||
|
|
@ -230,6 +232,7 @@ export class CustomerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "head_of_sale", "sale"])
|
||||||
async create(@Request() req: RequestWithUser, @Body() body: CustomerCreate) {
|
async create(@Request() req: RequestWithUser, @Body() body: CustomerCreate) {
|
||||||
const { customerBranch, ...payload } = body;
|
const { customerBranch, ...payload } = body;
|
||||||
|
|
||||||
|
|
@ -341,6 +344,7 @@ export class CustomerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put("{customerId}")
|
@Put("{customerId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "head_of_sale", "sale"])
|
||||||
async editById(
|
async editById(
|
||||||
@Path() customerId: string,
|
@Path() customerId: string,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
|
|
@ -500,6 +504,7 @@ export class CustomerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{customerId}")
|
@Delete("{customerId}")
|
||||||
|
@Security("keycloak", ["system", "head_of_admin", "admin", "head_of_sale", "sale"])
|
||||||
async deleteById(@Path() customerId: string) {
|
async deleteById(@Path() customerId: string) {
|
||||||
const record = await prisma.customer.findFirst({ where: { id: customerId } });
|
const record = await prisma.customer.findFirst({ where: { id: customerId } });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue