Initial work on cart management
This commit is contained in:
1 parent
eb57a10bbe
commit
e069dedcda
5 files changed
+50
-2
No files matched your search
@@ -4,5 +4,6 @@ bp_errors = Blueprint('errors', __name__)
|
||||
bp = Blueprint('api', __name__)
|
||||
bp_product = Blueprint('product', __name__, url_prefix="/product")
|
||||
bp_user = Blueprint('user', __name__, url_prefix="/user")
|
||||
bp_cart = Blueprint('cart', __name__, url_prefix="/cart")
|
||||
|
||||
from . import routes
|
||||
@@ -1 +1 @@
|
||||
from . import main_routes,error_routes, product_routes, user_routes
|
||||
from app.api.routes import main_routes, error_routes, product_routes, user_routes, cart_routes
|
||||
@@ -0,0 +1,16 @@
|
||||
from flask import jsonify, abort, request
|
||||
from flask_jwt_extended import jwt_required, get_jwt_identity
|
||||
|
||||
from app.api import bp_cart
|
||||
|
||||
from app.services.cart_service import CartService
|
||||
|
||||
@bp_cart.route('add/<int:product_id>', methods=['PUT'])
|
||||
@jwt_required()
|
||||
def add_to_cart(product_id: int):
|
||||
user_id = get_jwt_identity()
|
||||
count = request.args.get('count', default=1, type=int)
|
||||
|
||||
result, status_code = CartService.add_to_cart(user_id, product_id, count)
|
||||
|
||||
return result, status_code
|
||||
Reference in new issue
Block a user