diff --git a/src/controllers/customer-controller.ts b/src/controllers/customer-controller.ts index e71485c..cb18ca5 100644 --- a/src/controllers/customer-controller.ts +++ b/src/controllers/customer-controller.ts @@ -52,6 +52,25 @@ function imageLocation(id: string) { @Tags("Customer") @Security("keycloak") export class CustomerController extends Controller { + @Get("type-stats") + async stat() { + const list = await prisma.customer.groupBy({ + by: "customerType", + _count: true, + }); + + return list.reduce>( + (a, c) => { + a[c.customerType] = c._count; + return a; + }, + { + CORP: 0, + PERS: 0, + }, + ); + } + @Get() async list( @Query() query: string = "",