Inital work on better product fetching
This commit is contained in:
1 parent
a7a1ea72f1
commit
a45efa6433
2 files changed
+56
-68
No files matched your search
@@ -5,58 +5,14 @@ from app.api import bp_product
|
||||
from app.services.product_service import ProductService
|
||||
|
||||
@bp_product.route('/<int:id>', methods=['GET'])
|
||||
def all_product_info(id: int):
|
||||
result = ProductService.get_all_info(id)
|
||||
def get_product_info(id: int):
|
||||
fields = ['name', 'price', 'image', 'image_name', 'seller']
|
||||
|
||||
if result is not None:
|
||||
return jsonify(result)
|
||||
else:
|
||||
abort(404)
|
||||
fields_param = request.args.get('fields')
|
||||
requested_fields = []
|
||||
|
||||
return abort(501)
|
||||
|
||||
@bp_product.route('/<int:id>/name', methods=['GET'])
|
||||
def get_name(id: int):
|
||||
result = ProductService.get_name(id)
|
||||
|
||||
if result is not None:
|
||||
return jsonify({"name": result})
|
||||
else:
|
||||
return abort(404)
|
||||
|
||||
@bp_product.route('/<int:id>/manufacturer', methods=['GET'])
|
||||
def get_manufacturer(id: int):
|
||||
result = ProductService.get_manufacturer(id)
|
||||
|
||||
if result is not None:
|
||||
return jsonify({"name": result})
|
||||
else:
|
||||
return abort(404)
|
||||
|
||||
@bp_product.route('/<int:id>/price', methods=['GET'])
|
||||
def get_price(id: int):
|
||||
result = ProductService.get_price(id)
|
||||
|
||||
if result is not None:
|
||||
return jsonify({"price": result})
|
||||
else:
|
||||
return abort(404)
|
||||
|
||||
@bp_product.route('/<int:id>/image', methods=['GET'])
|
||||
def get_image(id: int):
|
||||
result = ProductService.get_image(id)
|
||||
|
||||
if result is not None:
|
||||
return jsonify({"image": result})
|
||||
else:
|
||||
return abort(404)
|
||||
|
||||
@bp_product.route('/<int:id>/image_name', methods=['GET'])
|
||||
def get_image_name(id: int):
|
||||
result = ProductService.get_image_name(id)
|
||||
|
||||
if result is not None:
|
||||
return jsonify({"image_name": result})
|
||||
else:
|
||||
return abort(404)
|
||||
|
||||
@bp_product.route('/create', methods=['POST'])
|
||||
def create_product_listing():
|
||||
|
||||
Reference in new issue
Block a user