refactor: quotation query and relation
This commit is contained in:
parent
9358cac3f8
commit
4f4b8df9a3
1 changed files with 13 additions and 8 deletions
|
|
@ -185,17 +185,22 @@ export class QuotationController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() payCondition?: PayCondition,
|
||||
) {
|
||||
const where = {
|
||||
payCondition,
|
||||
customerBranch: {
|
||||
customer: {
|
||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
||||
},
|
||||
},
|
||||
} satisfies Prisma.QuotationWhereInput;
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
prisma.quotation.findMany({
|
||||
where: {
|
||||
customerBranch: {
|
||||
customer: {
|
||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
||||
},
|
||||
},
|
||||
},
|
||||
where,
|
||||
include: {
|
||||
customerBranch: true,
|
||||
worker: true,
|
||||
service: {
|
||||
include: {
|
||||
|
|
@ -209,7 +214,7 @@ export class QuotationController extends Controller {
|
|||
},
|
||||
},
|
||||
}),
|
||||
prisma.quotation.count(),
|
||||
prisma.quotation.count({ where }),
|
||||
]);
|
||||
|
||||
return { result: result, page, pageSize, total };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue