|
1 | 1 | from app.schemas.base import ResponseBase |
2 | 2 | from app.schemas.memo import MemoCreate, MemoResponse, MemoUpdate |
3 | 3 | from app.services.memo import ( |
4 | | - select_today_memos_service, |
5 | | - select_month_memos_service, |
6 | | - select_month_memos_by_category_id_service, |
| 4 | + select_memos_by_period, |
7 | 5 | add_memo_service, |
8 | 6 | edit_memo_service, |
9 | 7 | delete_memo_service, |
|
13 | 11 | from sqlalchemy.ext.asyncio import AsyncSession |
14 | 12 | from typing import List |
15 | 13 | from uuid import UUID |
| 14 | +from datetime import date |
16 | 15 |
|
17 | 16 | router = APIRouter() |
18 | 17 |
|
19 | 18 |
|
20 | 19 | @router.get("/", response_model=ResponseBase[List[MemoResponse]]) |
21 | | -async def get_today_memos( |
22 | | - user_id: UUID, db: AsyncSession = Depends(get_db) |
23 | | -) -> ResponseBase[List[MemoResponse]]: |
24 | | - try: |
25 | | - memos = await select_today_memos_service(db, user_id) |
26 | | - return ResponseBase(status_code=status.HTTP_200_OK, data=memos) |
27 | | - except HTTPException as e: |
28 | | - return ResponseBase(status_code=e.status_code, error=e.detail) |
29 | | - except Exception as e: |
30 | | - return ResponseBase( |
31 | | - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, error=str(e) |
32 | | - ) |
33 | | - |
34 | | - |
35 | | -@router.get("/", response_model=ResponseBase[List[MemoResponse]]) |
36 | | -async def get_month_memos( |
37 | | - user_id: UUID, year: int, month: int, db: AsyncSession = Depends(get_db) |
38 | | -) -> ResponseBase[List[MemoResponse]]: |
39 | | - try: |
40 | | - memos = await select_month_memos_service(db, user_id, year, month) |
41 | | - return ResponseBase(status_code=status.HTTP_200_OK, data=memos) |
42 | | - except HTTPException as e: |
43 | | - return ResponseBase(status_code=e.status_code, error=e.detail) |
44 | | - except Exception as e: |
45 | | - return ResponseBase( |
46 | | - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, error=str(e) |
47 | | - ) |
48 | | - |
49 | | - |
50 | | -@router.get("/", response_model=ResponseBase[List[MemoResponse]]) |
51 | | -async def get_month_memos_by_category( |
| 20 | +async def get_memos_by_period( |
52 | 21 | user_id: UUID, |
53 | | - category_id: UUID, |
54 | | - year: int, |
55 | | - month: int, |
| 22 | + start_date: date, |
| 23 | + end_date: date, |
56 | 24 | db: AsyncSession = Depends(get_db), |
57 | 25 | ) -> ResponseBase[List[MemoResponse]]: |
58 | 26 | try: |
59 | | - memos = await select_month_memos_by_category_id_service( |
60 | | - db, user_id, category_id, year, month |
61 | | - ) |
| 27 | + memos = await select_memos_by_period(db, user_id, start_date, end_date) |
62 | 28 | return ResponseBase(status_code=status.HTTP_200_OK, data=memos) |
63 | 29 | except HTTPException as e: |
64 | 30 | return ResponseBase(status_code=e.status_code, error=e.detail) |
|
0 commit comments