fix product details api

This commit is contained in:
CHIEFSOFT\ameye
2025-10-08 11:12:18 -04:00
parent e06948643a
commit 825d4c0438
+25 -12
View File
@@ -6,7 +6,8 @@ from app.api.services.base_service import BaseService
from sqlalchemy import func, desc
from datetime import datetime, timedelta, timezone
from app.extensions import db
from app.models import MembersProducts, Products, Payments, Members, CustomTemplates, ProductsTemplates, MembersProfile
from app.models import MembersProducts, Products, Payments, Members, CustomTemplates, ProductsTemplates, MembersProfile, \
ProductsDetails
class OfficeDashboardService(BaseService):
@@ -155,23 +156,35 @@ class OfficeDashboardService(BaseService):
@staticmethod
def get_office_product_detail(filters):
product_id = filters.get('product_id')
product_data=[]
products = Products.get_product_by_product_id(product_id)
product_data = {
'id': products.id,
'uid': products.uid,
'product_id': products.product_id,
'description': products.description,
'name': products.name,
'status': products.status,
'added': products.added.isoformat() if products.added else None,
'updated': products.updated.isoformat() if products.updated else None,
'banner': products.banner,
if products:
product_data = {
'id': products.id,
'uid': products.uid,
'product_id': products.product_id,
'description': products.description,
'name': products.name,
'status': products.status,
'added': products.added.isoformat() if products.added else None,
'updated': products.updated.isoformat() if products.updated else None,
'banner': products.banner,
}
product_details= []
productDetails =ProductsDetails.get_product_details_with_product_id(product_id)
if productDetails:
product_details = {
'product_detail_id': productDetails.id,
'product_id': productDetails.product_id,
'details': productDetails.details,
'sale_text': productDetails.sale_text,
'added': productDetails.added.isoformat() if productDetails.added else None,
}
products_result = {
"product_configuration": product_data,
"product_details": product_data,
"product_details": product_details,
}
return products_result