feat(api): category-based family grouping, tree family info and custom goods family attribution
This commit is contained in:
@@ -41,6 +41,10 @@ export interface OriginGoodsTreeNode {
|
||||
variantCount: number;
|
||||
sizeRowCount: number;
|
||||
packageRowCount: number;
|
||||
familyId: string | null;
|
||||
familyName: string | null;
|
||||
familyCode: string | null;
|
||||
familyStale: boolean | null;
|
||||
}
|
||||
|
||||
/** A category node in the hierarchical tree, with origin goods as leaves. */
|
||||
@@ -129,7 +133,11 @@ export class OriginGoodsService {
|
||||
this.prisma.originGood.findMany({
|
||||
where: { delisted: false, source: 'SDS' },
|
||||
orderBy: { goodName: 'asc' },
|
||||
include: { detail: true, _count: { select: { variants: true } } },
|
||||
include: {
|
||||
detail: true,
|
||||
_count: { select: { variants: true } },
|
||||
family: { select: { id: true, familyName: true, familyCode: true, stale: true } },
|
||||
},
|
||||
}),
|
||||
this.prisma.good.groupBy({
|
||||
by: ['originGoodId'],
|
||||
@@ -271,6 +279,10 @@ export class OriginGoodsService {
|
||||
variantCount: og._count.variants,
|
||||
sizeRowCount: this.jsonRows(og.detail?.sizeChart),
|
||||
packageRowCount: this.jsonRows(og.detail?.packageSpecs),
|
||||
familyId: og.family?.id.toString() ?? null,
|
||||
familyName: og.family?.familyName ?? null,
|
||||
familyCode: og.family?.familyCode ?? null,
|
||||
familyStale: og.family?.stale ?? null,
|
||||
}));
|
||||
|
||||
const childTotal = childNodes.reduce((s, n) => s + n.totalCount, 0);
|
||||
@@ -322,6 +334,10 @@ export class OriginGoodsService {
|
||||
variantCount: og._count.variants,
|
||||
sizeRowCount: this.jsonRows(og.detail?.sizeChart),
|
||||
packageRowCount: this.jsonRows(og.detail?.packageSpecs),
|
||||
familyId: og.family?.id.toString() ?? null,
|
||||
familyName: og.family?.familyName ?? null,
|
||||
familyCode: og.family?.familyCode ?? null,
|
||||
familyStale: og.family?.stale ?? null,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user