This commit is contained in:
aaron 2025-03-21 20:20:08 +08:00
parent df3d128e58
commit e79785bce6
2 changed files with 12 additions and 1 deletions

View File

@ -15,6 +15,7 @@ from app.models.merchant import MerchantDB
from sqlalchemy import func
from sqlalchemy.orm import joinedload
from app.models.merchant_product import OperationType, DeliveryType, DeliveryTimeType
from app.models.merchant import MerchantInfo
router = APIRouter()
@router.post("", response_model=ResponseModel)
@ -138,11 +139,21 @@ async def get_product(
product = db.query(MerchantProductDB).filter(
MerchantProductDB.id == product_id
).first()
product_info = MerchantProductInfo.model_validate(product)
merchant = MerchantInfo.model_validate(product.merchant)
result = {
**product_info.model_dump(),
"gift_points" : int(float(product.gift_points_rate) / 10 * float(product.sale_price)),
"merchant": merchant.model_dump()
}
if not product:
return error_response(code=404, message="产品不存在")
return success_response(data=MerchantProductInfo.model_validate(product))
return success_response(data=result)
@router.delete("/{product_id}", response_model=ResponseModel)
async def delete_product(

Binary file not shown.