-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DELETE endpoint to remove items from cart
Implemented a new DELETE endpoint to handle item removal from the user's cart. Added the corresponding handler and service logic to process the deletion, including interactions with the database to ensure item removal. Updated the cart service interface to include the delete functionality.
- Loading branch information
1 parent
3c88e2b
commit b5193af
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cart | ||
|
||
import ( | ||
"Go_Food_Delivery/pkg/database" | ||
"context" | ||
) | ||
|
||
func (cartSrv *CartService) DeleteItem(ctx context.Context, cartItemId int64) (bool, error) { | ||
filter := database.Filter{"cart_item_id": cartItemId} | ||
|
||
_, err := cartSrv.db.Delete(ctx, "cart_items", filter) | ||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
} |