feat(product-family): replace legacy good merge with family mechanism in config view and public detail

This commit is contained in:
yeuimu
2026-08-28 14:14:58 +08:00
parent 14c53504f0
commit 4eadb67c36
11 changed files with 2894 additions and 2710 deletions
+13
View File
@@ -31,6 +31,7 @@ const GOOD_INCLUDE = {
detail: true,
variants: { orderBy: [{ sortOrder: 'asc' }, { id: 'asc' }] },
_count: { select: { variants: true } },
family: { select: { id: true, familyCode: true, familyName: true, stale: true } },
},
},
goodTags: { include: { tag: true } },
@@ -334,6 +335,18 @@ export class GoodsService {
}
if (dto.goodPriority !== undefined) data.goodPriority = dto.goodPriority;
if (dto.goodImage !== undefined) data.goodImage = dto.goodImage;
if (dto.familyId !== undefined) {
if (dto.familyId !== null) {
const family = await this.prisma.productFamily.findUnique({
where: { id: BigInt(dto.familyId) },
select: { id: true },
});
if (!family) throw new NotFoundException(`product family ${dto.familyId} not found`);
data.family = { connect: { id: family.id } };
} else {
data.family = { disconnect: true };
}
}
if (dto.tagIds !== undefined) {
for (const tagId of dto.tagIds) {
await this.ensureTag(tagId);