fix: error due top field dropped
This commit is contained in:
parent
c548386b56
commit
b0b54451a2
1 changed files with 20 additions and 5 deletions
|
|
@ -224,18 +224,33 @@ export class CustomerBranchController extends Controller {
|
|||
async listEmployee(
|
||||
@Path() branchId: string,
|
||||
@Query() zipCode?: string,
|
||||
@Query() gender?: string,
|
||||
@Query() status?: Status,
|
||||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
) {
|
||||
const filterStatus = (val?: Status) => {
|
||||
if (!val) return {};
|
||||
|
||||
return val !== Status.CREATED && val !== Status.ACTIVE
|
||||
? { status: val }
|
||||
: { OR: [{ status: Status.CREATED }, { status: Status.ACTIVE }] };
|
||||
};
|
||||
|
||||
const where = {
|
||||
AND: { customerBranchId: branchId },
|
||||
OR: [
|
||||
{ firstName: { contains: query }, zipCode },
|
||||
{ firstNameEN: { contains: query }, zipCode },
|
||||
{ lastName: { contains: query }, zipCode },
|
||||
{ lastNameEN: { contains: query }, zipCode },
|
||||
{ firstName: { contains: query } },
|
||||
{ firstNameEN: { contains: query } },
|
||||
{ lastName: { contains: query } },
|
||||
{ lastNameEN: { contains: query } },
|
||||
],
|
||||
AND: {
|
||||
...filterStatus(status),
|
||||
customerBranchId: branchId,
|
||||
subDistrict: zipCode ? { zipCode } : undefined,
|
||||
gender,
|
||||
},
|
||||
} satisfies Prisma.EmployeeWhereInput;
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue