feat: add query
This commit is contained in:
parent
d6fa6dfee1
commit
6550ce1bb3
1 changed files with 3 additions and 1 deletions
|
|
@ -2,11 +2,12 @@ import { Controller, Get, Query, Route } from "tsoa";
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
import { Prisma, Product, Service } from "@prisma/client";
|
import { Prisma, Product, Service } from "@prisma/client";
|
||||||
|
|
||||||
@Route("product-service")
|
@Route("/api/v1/product-service")
|
||||||
export class ProductServiceController extends Controller {
|
export class ProductServiceController extends Controller {
|
||||||
@Get()
|
@Get()
|
||||||
async getProductService(
|
async getProductService(
|
||||||
@Query() status?: "ACTIVE" | "INACTIVE",
|
@Query() status?: "ACTIVE" | "INACTIVE",
|
||||||
|
@Query() query = "",
|
||||||
@Query() productTypeId?: string,
|
@Query() productTypeId?: string,
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@Query() pageSize: number = 30,
|
||||||
|
|
@ -56,6 +57,7 @@ export class ProductServiceController extends Controller {
|
||||||
const or: Prisma.Sql[] = [];
|
const or: Prisma.Sql[] = [];
|
||||||
const and: Prisma.Sql[] = [];
|
const and: Prisma.Sql[] = [];
|
||||||
|
|
||||||
|
if (query) or.push(Prisma.sql`"name" LIKE '%${query}%'`);
|
||||||
if (status) and.push(Prisma.sql`"status" = ${status}::"Status"`);
|
if (status) and.push(Prisma.sql`"status" = ${status}::"Status"`);
|
||||||
if (productTypeId) and.push(Prisma.sql`"productTypeId" = ${productTypeId}`);
|
if (productTypeId) and.push(Prisma.sql`"productTypeId" = ${productTypeId}`);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue