fix: workflow query not work on filter (#3)
* fix: query not work when filter was applied * refactor: prevent query condition from being build on empty
This commit is contained in:
parent
824727582d
commit
386ad956e5
1 changed files with 8 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import { notFoundError } from "../utils/error";
|
||||
import { filterStatus } from "../services/prisma";
|
||||
import { queryOrNot } from "../utils/relation";
|
||||
|
||||
type WorkflowPayload = {
|
||||
name: string;
|
||||
|
|
@ -54,17 +55,19 @@ export class FlowTemplateController extends Controller {
|
|||
@Query() query = "",
|
||||
) {
|
||||
const where = {
|
||||
OR: [
|
||||
OR: queryOrNot(query, [
|
||||
{ name: { contains: query } },
|
||||
{
|
||||
step: {
|
||||
some: { name: { contains: query } },
|
||||
},
|
||||
},
|
||||
],
|
||||
...filterStatus(status),
|
||||
registeredBranch: {
|
||||
OR: permissionCondCompany(req.user),
|
||||
]),
|
||||
AND: {
|
||||
...filterStatus(status),
|
||||
registeredBranch: {
|
||||
OR: permissionCondCompany(req.user),
|
||||
},
|
||||
},
|
||||
} satisfies Prisma.WorkflowTemplateWhereInput;
|
||||
const [result, total] = await prisma.$transaction([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue