feat: add option to get list with head

This commit is contained in:
Methapon Metanipat 2024-09-25 14:13:27 +07:00
parent a26188cbb3
commit 4036a36236

View file

@ -222,7 +222,8 @@ export class BranchController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Query() filter?: "head" | "sub", @Query() filter?: "head" | "sub",
@Query() headOfficeId?: string, @Query() headOfficeId?: string,
@Query() includeHead?: boolean, @Query() includeHead?: boolean, // Include relation
@Query() withHead?: boolean, // List cover head
@Query() tree?: boolean, @Query() tree?: boolean,
@Query() status?: Status, @Query() status?: Status,
@Query() query: string = "", @Query() query: string = "",
@ -234,7 +235,7 @@ export class BranchController extends Controller {
...filterStatus(status), ...filterStatus(status),
headOfficeId: headOfficeId ?? (filter === "head" || tree ? null : undefined), headOfficeId: headOfficeId ?? (filter === "head" || tree ? null : undefined),
NOT: { headOfficeId: filter === "sub" && !headOfficeId ? null : undefined }, NOT: { headOfficeId: filter === "sub" && !headOfficeId ? null : undefined },
OR: permissionCond(req.user, true), OR: permissionCond(req.user, withHead),
}, },
OR: [ OR: [
{ nameEN: { contains: query } }, { nameEN: { contains: query } },