新增产品状态检查功能

- 处理前检查产品是否已存在(已发布/待审核)
- 避免重复处理已有产品
- 新增 check_product_exists API 方法
- 更新 README 文档
This commit is contained in:
2026-07-16 23:35:39 +08:00
parent a367887ace
commit 11edee581b
3 changed files with 156 additions and 2 deletions
+31
View File
@@ -44,6 +44,37 @@ class DataProcessService:
}
try:
# 0. 【新增】检查产品是否已存在于系统中(已发布或待审核)
print(f"[检查] 检查产品是否已存在: {product_name}")
exists_check = paramhub_client.check_product_exists(product_name)
if exists_check['exists']:
# 产品已存在,不进行后续处理
status_text = {
'published': '已发布',
'pending': '待审核'
}.get(exists_check['status'], '未知状态')
result['message'] = f"产品 '{product_name}' 已在系统中{status_text},跳过处理"
print(f"[跳过] {result['message']}")
# 记录处理历史
db.add_process_history(
product_name=product_name,
category=category,
subcategory=subcategory,
status='skipped',
details={
'reason': 'product_exists',
'existing_status': exists_check['status'],
'existing_data': exists_check.get('data')
}
)
return result
print(f"[检查] 产品未找到,继续处理流程")
# 1. 从内容库和互联网搜索原始数据
print(f"[处理] 开始处理产品: {product_name}")
search_results = search_service.search_all(