feat: add support for search in request data
This commit is contained in:
parent
bbd2c23b12
commit
766f9b4af5
1 changed files with 19 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { RequestWithUser } from "../interfaces/user";
|
|||
import prisma from "../db";
|
||||
import { Prisma, RequestDataStatus, RequestWorkStatus } from "@prisma/client";
|
||||
import { createPermCondition } from "../services/permission";
|
||||
import { queryOrNot } from "../utils/relation";
|
||||
|
||||
// User in company can see.
|
||||
const permissionCond = createPermCondition((_) => true);
|
||||
|
|
@ -48,6 +49,24 @@ export class RequestDataController extends Controller {
|
|||
@Query() query: string = "",
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.RequestDataWhereInput[]>(query, [
|
||||
{ quotation: { code: { contains: query, mode: "insensitive" } } },
|
||||
{ quotation: { workName: { contains: query } } },
|
||||
{
|
||||
quotation: {
|
||||
customerBranch: {
|
||||
OR: [
|
||||
{ code: { contains: query, mode: "insensitive" } },
|
||||
{ customerName: { contains: query } },
|
||||
{ firstName: { contains: query } },
|
||||
{ firstNameEN: { contains: query } },
|
||||
{ lastName: { contains: query } },
|
||||
{ lastNameEN: { contains: query } },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
]),
|
||||
quotation: {
|
||||
customerBranch: {
|
||||
customer: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue