feat: add filter parameter
This commit is contained in:
parent
f06f7366b7
commit
4c28941bc2
1 changed files with 4 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ import {
|
||||||
import { RequestWithUser } from "../interfaces/user";
|
import { RequestWithUser } from "../interfaces/user";
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
import { notFoundError } from "../utils/error";
|
import { notFoundError } from "../utils/error";
|
||||||
|
import { queryOrNot } from "../utils/relation";
|
||||||
|
|
||||||
const MANAGE_ROLES = ["system", "head_of_admin", "admin"];
|
const MANAGE_ROLES = ["system", "head_of_admin", "admin"];
|
||||||
|
|
||||||
|
|
@ -52,9 +53,11 @@ export class InstitutionController extends Controller {
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@Query() pageSize: number = 30,
|
||||||
|
@Query() group?: string,
|
||||||
) {
|
) {
|
||||||
const where = {
|
const where = {
|
||||||
name: { contains: query },
|
group,
|
||||||
|
OR: queryOrNot<Prisma.InstitutionWhereInput[]>(query, [{ name: { contains: query } }]),
|
||||||
} satisfies Prisma.InstitutionWhereInput;
|
} satisfies Prisma.InstitutionWhereInput;
|
||||||
|
|
||||||
const [result, total] = await prisma.$transaction([
|
const [result, total] = await prisma.$transaction([
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue