-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c30eef
commit 814d1c6
Showing
2 changed files
with
22 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import List | ||
from Data.item import * | ||
from Database.models import * | ||
|
||
class ConsumeService: | ||
def consume_history_db(data : UserItemConsume): | ||
with get_db() as db: | ||
item_id = db.query(UserItem).filter(UserItem.user_id == data.user_id, UserItem.item_name == data.item_name).first().item_id | ||
print(data.user_id, item_id) | ||
return ConsumeHistory(user_id=data.user_id, item_id=item_id, count=data.consume_count, date=data.consume_date) | ||
|
||
def purchase_history_save(data : ConsumeHistory): | ||
with get_db() as db: | ||
db.add(data) | ||
db.commit() | ||
|
||
def get_consume_histories_by_item_id(item_id: str): | ||
with get_db() as db: | ||
return db.query(ConsumeHistory).filter(ConsumeHistory.item_id == item_id).all() |