feat(admin): manage and sync product details
This commit is contained in:
@@ -53,27 +53,6 @@ export class PublicQueryGoodDto {
|
||||
@IsNumberString({}, { each: true })
|
||||
tagIds?: string[];
|
||||
|
||||
@ApiProperty({ required: false, type: [String], description: '印刷工艺标签 ID' })
|
||||
@IsOptional()
|
||||
@Transform(stringList)
|
||||
@IsArray()
|
||||
@IsNumberString({}, { each: true })
|
||||
craftIds?: string[];
|
||||
|
||||
@ApiProperty({ required: false, type: [String], description: '材质标签 ID' })
|
||||
@IsOptional()
|
||||
@Transform(stringList)
|
||||
@IsArray()
|
||||
@IsNumberString({}, { each: true })
|
||||
materialIds?: string[];
|
||||
|
||||
@ApiProperty({ required: false, enum: ['FREE_SHIPPING', 'NOT_FREE_SHIPPING'], isArray: true })
|
||||
@IsOptional()
|
||||
@Transform(stringList)
|
||||
@IsArray()
|
||||
@IsIn(['FREE_SHIPPING', 'NOT_FREE_SHIPPING'], { each: true })
|
||||
freeShipping?: Array<'FREE_SHIPPING' | 'NOT_FREE_SHIPPING'>;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -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