diff --git a/app/api/endpoints/merchant_product.py b/app/api/endpoints/merchant_product.py index 386ac09..7587ea7 100644 --- a/app/api/endpoints/merchant_product.py +++ b/app/api/endpoints/merchant_product.py @@ -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( diff --git a/jobs.sqlite b/jobs.sqlite index 7dade05..fe7f531 100644 Binary files a/jobs.sqlite and b/jobs.sqlite differ