feat(admin): manage and sync product details
This commit is contained in:
@@ -145,14 +145,9 @@ export class PublicService {
|
||||
where.categoryId = { in: await this.collectCategoryDescendants(BigInt(query.categoryId)) };
|
||||
}
|
||||
|
||||
const tagIds = [
|
||||
...new Set([
|
||||
...(query.tagIds ?? []),
|
||||
...(query.craftIds ?? []),
|
||||
...(query.materialIds ?? []),
|
||||
]),
|
||||
];
|
||||
const tagFilters = await this.buildTagGroupFilters(tagIds, query.freeShipping);
|
||||
const tagFilters = await this.buildTagGroupFilters([
|
||||
...new Set(query.tagIds ?? []),
|
||||
]);
|
||||
if (tagFilters.length) where.AND = tagFilters;
|
||||
|
||||
const minPrice = this.parsePrice(query.minPrice, 'minPrice');
|
||||
@@ -325,7 +320,6 @@ export class PublicService {
|
||||
|
||||
private async buildTagGroupFilters(
|
||||
selectedTagIds: string[],
|
||||
freeShipping?: Array<'FREE_SHIPPING' | 'NOT_FREE_SHIPPING'>,
|
||||
): Promise<Prisma.GoodWhereInput[]> {
|
||||
const selected = selectedTagIds.length
|
||||
? await this.prisma.tag.findMany({
|
||||
@@ -336,19 +330,6 @@ export class PublicService {
|
||||
if (selected.length !== selectedTagIds.length) {
|
||||
throw new BadRequestException('包含不存在的标签 ID');
|
||||
}
|
||||
if (freeShipping?.length) {
|
||||
const names = freeShipping.map((value) =>
|
||||
value === 'FREE_SHIPPING' ? '包邮' : '不包邮',
|
||||
);
|
||||
const shippingTags = await this.prisma.tag.findMany({
|
||||
where: { tagName: { in: names }, tagGroup: { groupName: '物流渠道' } },
|
||||
select: { id: true, tagGroupId: true },
|
||||
});
|
||||
if (shippingTags.length !== new Set(names).size) {
|
||||
throw new BadRequestException('物流渠道标签配置不完整');
|
||||
}
|
||||
selected.push(...shippingTags);
|
||||
}
|
||||
const byGroup = new Map<string, bigint[]>();
|
||||
for (const tag of selected) {
|
||||
const key = tag.tagGroupId?.toString() ?? `tag:${tag.id.toString()}`;
|
||||
|
||||
Reference in New Issue
Block a user