feat(models): 优化商品名称获取逻辑
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
根据商品信息中的多个字段获取商品名称,并在没有匹配字段时设置默认值为"暂无"。
This commit is contained in:
parent
4b0f954b42
commit
80103802cc
@ -52,7 +52,8 @@ class ScanLog(BaseModel):
|
||||
try:
|
||||
product = BarcodeDB.get(BarcodeDB.barcode == self.barcode)
|
||||
product_info = json.loads(product.product_info)
|
||||
name_key = ['goodsName', 'goods_name', 'name']
|
||||
name = '暂无'
|
||||
name_key = ['goodsName', 'goods_name', 'name', 'description_cn', 'description']
|
||||
for key in name_key:
|
||||
if key in product_info:
|
||||
name = product_info.get(key)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user