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(
|
async listEmployee(
|
||||||
@Path() branchId: string,
|
@Path() branchId: string,
|
||||||
@Query() zipCode?: string,
|
@Query() zipCode?: string,
|
||||||
|
@Query() gender?: string,
|
||||||
|
@Query() status?: Status,
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@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 = {
|
const where = {
|
||||||
AND: { customerBranchId: branchId },
|
|
||||||
OR: [
|
OR: [
|
||||||
{ firstName: { contains: query }, zipCode },
|
{ firstName: { contains: query } },
|
||||||
{ firstNameEN: { contains: query }, zipCode },
|
{ firstNameEN: { contains: query } },
|
||||||
{ lastName: { contains: query }, zipCode },
|
{ lastName: { contains: query } },
|
||||||
{ lastNameEN: { contains: query }, zipCode },
|
{ lastNameEN: { contains: query } },
|
||||||
],
|
],
|
||||||
|
AND: {
|
||||||
|
...filterStatus(status),
|
||||||
|
customerBranchId: branchId,
|
||||||
|
subDistrict: zipCode ? { zipCode } : undefined,
|
||||||
|
gender,
|
||||||
|
},
|
||||||
} satisfies Prisma.EmployeeWhereInput;
|
} satisfies Prisma.EmployeeWhereInput;
|
||||||
|
|
||||||
const [result, total] = await prisma.$transaction([
|
const [result, total] = await prisma.$transaction([
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue