Merge remote changes and update date_range format

This commit is contained in:
jlj 2025-05-26 10:32:39 +08:00
commit 0de6962ee7

View File

@ -48,11 +48,26 @@ class ContentAnalysisAPI(APIView):
]
for field in required_fields:
if field not in data:
value = data.get(field)
if value is None or (isinstance(value, str) and value.strip() == ""):
return Response(
{"error": f"Field '{field}' is required."},
{"error": f"字段 '{field}' 不能为空"},
status=status.HTTP_400_BAD_REQUEST
)
# 新增校验price和stock必须为数字且>=0
if field in ["product_info.price", "product_info.stock"]:
try:
num_value = float(value)
if num_value < 0:
return Response(
{"error": f"'{field}' 不合法"},
status=status.HTTP_400_BAD_REQUEST
)
except (ValueError, TypeError):
return Response(
{"error": f"'{field}' 不合法"},
status=status.HTTP_400_BAD_REQUEST
)
# 3. 解析 JSON 字段
try: