Work on swag documentation
This commit is contained in:
1 parent
0f7d69899a
commit
f259aa3993
13 files changed
+115
-55
No files matched your search
@@ -23,17 +23,18 @@ class CartService:
|
||||
cursor.execute("select count from cart_item where cart_id = %s and product_id = %s", (user_id, product_id))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if cursor.rowcount != 0:
|
||||
if cursor.rowcount == 1:
|
||||
cursor.execute("update cart_item set count = count + %s where cart_id = %s and product_id = %s", (count, user_id, product_id))
|
||||
else:
|
||||
cursor.execute("insert into cart_item(cart_id, product_id, count) values (%s, %s, %s)", (user_id, product_id, count))
|
||||
|
||||
db_connection.commit()
|
||||
|
||||
return {"Success": "Successfully added to cart"}, 200
|
||||
|
||||
except Error as e:
|
||||
return {"Failed": f"Failed to add item to cart. Reason: {e}"}, 400
|
||||
return {"Failed": f"Failed to add item to cart. Reason: {e}"}, 500
|
||||
|
||||
return {"Success": "Successfully added to cart"}, 200
|
||||
|
||||
@staticmethod
|
||||
def update_count(user_id: str, product_id: int, count: int) -> Tuple[Union[dict, str], int]:
|
||||
|
||||
Reference in new issue
Block a user