From 4036a362365930e1da23fb1d7340008e9bb13c7d Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 25 Sep 2024 14:13:27 +0700 Subject: [PATCH] feat: add option to get list with head --- src/controllers/01-branch-controller.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/01-branch-controller.ts b/src/controllers/01-branch-controller.ts index 4545b22..b040fb6 100644 --- a/src/controllers/01-branch-controller.ts +++ b/src/controllers/01-branch-controller.ts @@ -222,7 +222,8 @@ export class BranchController extends Controller { @Request() req: RequestWithUser, @Query() filter?: "head" | "sub", @Query() headOfficeId?: string, - @Query() includeHead?: boolean, + @Query() includeHead?: boolean, // Include relation + @Query() withHead?: boolean, // List cover head @Query() tree?: boolean, @Query() status?: Status, @Query() query: string = "", @@ -234,7 +235,7 @@ export class BranchController extends Controller { ...filterStatus(status), headOfficeId: headOfficeId ?? (filter === "head" || tree ? null : undefined), NOT: { headOfficeId: filter === "sub" && !headOfficeId ? null : undefined }, - OR: permissionCond(req.user, true), + OR: permissionCond(req.user, withHead), }, OR: [ { nameEN: { contains: query } },