feat: add filter status institution
This commit is contained in:
parent
596e336233
commit
23baff94de
1 changed files with 7 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ import { RequestWithUser } from "../interfaces/user";
|
|||
import { deleteFile, fileLocation, getFile, getPresigned, listFile, setFile } from "../utils/minio";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { filterStatus } from "../services/prisma";
|
||||
|
||||
type InstitutionPayload = {
|
||||
name: string;
|
||||
|
|
@ -55,9 +56,11 @@ export class InstitutionController extends Controller {
|
|||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() status?: Status,
|
||||
@Query() activeOnly?: boolean,
|
||||
@Query() group?: string,
|
||||
) {
|
||||
return this.getInstitutionListByCriteria(query, page, pageSize, group);
|
||||
return this.getInstitutionListByCriteria(query, page, pageSize, status, activeOnly, group);
|
||||
}
|
||||
|
||||
@Post("list")
|
||||
|
|
@ -67,6 +70,8 @@ export class InstitutionController extends Controller {
|
|||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() status?: Status,
|
||||
@Query() activeOnly?: boolean,
|
||||
@Query() group?: string,
|
||||
@Body()
|
||||
body?: {
|
||||
|
|
@ -74,6 +79,7 @@ export class InstitutionController extends Controller {
|
|||
},
|
||||
) {
|
||||
const where = {
|
||||
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||
group: body?.group ? { in: body.group } : group,
|
||||
OR: queryOrNot<Prisma.InstitutionWhereInput[]>(query, [
|
||||
{ name: { contains: query } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue