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 { deleteFile, fileLocation, getFile, getPresigned, listFile, setFile } from "../utils/minio";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
import { filterStatus } from "../services/prisma";
|
||||||
|
|
||||||
type InstitutionPayload = {
|
type InstitutionPayload = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -55,9 +56,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() status?: Status,
|
||||||
|
@Query() activeOnly?: boolean,
|
||||||
@Query() group?: string,
|
@Query() group?: string,
|
||||||
) {
|
) {
|
||||||
return this.getInstitutionListByCriteria(query, page, pageSize, group);
|
return this.getInstitutionListByCriteria(query, page, pageSize, status, activeOnly, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post("list")
|
@Post("list")
|
||||||
|
|
@ -67,6 +70,8 @@ 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() status?: Status,
|
||||||
|
@Query() activeOnly?: boolean,
|
||||||
@Query() group?: string,
|
@Query() group?: string,
|
||||||
@Body()
|
@Body()
|
||||||
body?: {
|
body?: {
|
||||||
|
|
@ -74,6 +79,7 @@ export class InstitutionController extends Controller {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const where = {
|
const where = {
|
||||||
|
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||||
group: body?.group ? { in: body.group } : group,
|
group: body?.group ? { in: body.group } : group,
|
||||||
OR: queryOrNot<Prisma.InstitutionWhereInput[]>(query, [
|
OR: queryOrNot<Prisma.InstitutionWhereInput[]>(query, [
|
||||||
{ name: { contains: query } },
|
{ name: { contains: query } },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue