From 1eb2c983cc123c8ea6338386af6b0434b5a98f39 Mon Sep 17 00:00:00 2001 From: jingooo5 Date: Sun, 3 Nov 2024 06:12:08 +0900 Subject: [PATCH] chore:update endpoint --- Service/useritem_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Service/useritem_service.py b/Service/useritem_service.py index e93c765..8dcccbd 100644 --- a/Service/useritem_service.py +++ b/Service/useritem_service.py @@ -28,6 +28,9 @@ def get_all_userItem(user_id: str): with get_db() as db: return db.query(UserItem).filter(UserItem.user_id == user_id, UserItem.count > 0).all() + def get_all_userItem_filtered_by_category(user_id: str, category: str): + with get_db() as db: + return db.query(UserItem).filter(UserItem.user_id == user_id, UserItem.count > 0).join(Item).filter(Item.item_category == category).all() def get_all_userItem_filtered_by_date(user_id, year: int, month: int): with get_db() as db: @@ -35,7 +38,7 @@ def get_all_userItem_filtered_by_date(user_id, year: int, month: int): extract("month", UserItem.consume_date) == month).all() - def to_userItem_dict(userItemList: List[UserItem]): + def to_userItem_dict(userItemList: List[UserItem], category: str): itemlist = [] for userItem in userItemList: