feata: add relation to service
This commit is contained in:
parent
c79851d074
commit
d6fa6dfee1
1 changed files with 8 additions and 1 deletions
|
|
@ -78,8 +78,15 @@ export class ProductServiceController extends Controller {
|
||||||
${where}
|
${where}
|
||||||
`,
|
`,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const work = await prisma.work.findMany({
|
||||||
|
where: { serviceId: { in: result.flatMap((v) => (v.type === "service" ? v.id : [])) } },
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
result,
|
result: result.map((v) =>
|
||||||
|
v.type === "service" ? { ...v, work: work.filter((w) => w.serviceId === v.id) || [] } : v,
|
||||||
|
),
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
total: +String(total),
|
total: +String(total),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue