From 900353b62f47ece241069d9f69faaa9616eb729f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:27:30 +0900 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20domain=20req=20put=20schema=20-=20?= =?UTF-8?q?book=20id=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/schemas/book_schemas.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domain/schemas/book_schemas.py b/src/domain/schemas/book_schemas.py index 6e4ca51e..93aecb6a 100644 --- a/src/domain/schemas/book_schemas.py +++ b/src/domain/schemas/book_schemas.py @@ -69,6 +69,7 @@ class DomainResAdminPostBook(BaseModel): updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) class DomainReqAdminPutBook(BaseModel): + book_id: int = Field(title="book_id", description="책 ID", gt=0) book_title: str = Field(title="book_title", description="책 제목", example="FastAPI Tutorial") code: str = Field(title="code", description="책 코드", examples="A3") category_name: str = Field(title="category_name", description="카테고리명", examples="웹") From 9cbb83f23294f4d26c539e1df0e1755f7a33d42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:43:35 +0900 Subject: [PATCH 02/16] feat: service admin update book --- src/domain/services/admin/book_service.py | 69 ++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index 36c7d5f0..49f78ad5 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -5,7 +5,12 @@ from sqlalchemy.orm import Session from domain.enums.book_category import BookCategoryStatus -from domain.schemas.book_schemas import DomainReqAdminPostBook, DomainResAdminPostBook +from domain.schemas.book_schemas import ( + DomainReqAdminPostBook, + DomainReqAdminPutBook, + DomainResAdminPostBook, + DomainResAdminPutBook, +) from repositories.models import Book @@ -69,3 +74,65 @@ async def service_admin_create_book(request: DomainReqAdminPostBook, db: Session updated_at=new_book.updated_at ) return domain_res + +async def service_admin_update_book(request: DomainReqAdminPutBook, db: Session): + stmt = select(Book).where(Book.id == request.book_id) + request_book = db.execute(stmt).scalar_one_or_none() + + if not request_book: + raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, + detail="Requested Book Not Found") + if request.code[0] not in {category.name for category in BookCategoryStatus}: + raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, + detail="Invalid Category") + if request.category_name not in {category.category for category in BookCategoryStatus}: + raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, + detail="Invalid Category") + + requested_book = request_book.__dict__ + updated_book = request.__dict__ + + try: + for key, value in updated_book.items(): + if value is not None and key in requested_book: + if isinstance(value, type(requested_book[key])): + setattr(request_book, key, value) + else: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=f"Invalid value type for column {key}. \ + Expected {type(request_book[key])}, got {type(value)}." + ) + db.add(request_book) + db.flush() + except Exception as e: + db.rollback() + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Unexpected error occurred during update: {str(e)}", + ) from e + else: + db.commit() + db.refresh(request_book) + + domain_res = DomainResAdminPutBook( + book_id=request_book.id, + book_title=request_book.book_title, + code=request_book.code, + category_name=request_book.category_name, + subtitle=request_book.subtitle, + author=request_book.author, + publisher=request_book.publisher, + publication_year=request_book.publication_year, + image_url=request_book.image_url, + version=request_book.version, + major=request_book.major, + language=request_book.language, + book_status=request_book.book_status, + donor_name=request_book.donor_name, + created_at=request_book.created_at, + updated_at=request_book.updated_at + ) + + + return domain_res From af775d86235d7ca94b94814b08904f9f3ae1d051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:45:41 +0900 Subject: [PATCH 03/16] feat: route req admin put book --- src/routes/admin/request/book_request.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/routes/admin/request/book_request.py b/src/routes/admin/request/book_request.py index c97ce86e..278a0711 100644 --- a/src/routes/admin/request/book_request.py +++ b/src/routes/admin/request/book_request.py @@ -16,3 +16,17 @@ class RouteReqAdminPostBook(BaseModel): major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) + +class RouteReqAdminPutBook(BaseModel): + book_title: str = Field(title="book_title", description="책 제목", example="FastAPI Tutorial") + code: str = Field(title="code", description="책 코드", example="A3") + category_name: str = Field(title="category_name", description="카테고리명", example="웹") + subtitle: Optional[str] = Field(title="subtitle", description="책 부제", default=None) + author : str = Field(title="author", description="저자") + publisher: str = Field(title="publisher", description="출판사") + publication_year: int = Field(title="publication_year", description="출판연도", gt=0) + image_url: Optional[str] = Field(title="image_url", description="책 표지", default=None) + version: Optional[str] = Field(title="version", description="판본", default=None) + major: bool = Field(title="major", description="전공 책 여부", default=False) + language: str = Field(title="language", description="언어", default="KOREAN") + donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) From 22e2381785e1bbf20c44a63b2c7d7942e7c6b459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:50:13 +0900 Subject: [PATCH 04/16] =?UTF-8?q?fix:=20updated=5Fat=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/services/admin/book_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index 49f78ad5..ba35da01 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -103,6 +103,7 @@ async def service_admin_update_book(request: DomainReqAdminPutBook, db: Session) detail=f"Invalid value type for column {key}. \ Expected {type(request_book[key])}, got {type(value)}." ) + request_book.updated_at = datetime.now() db.add(request_book) db.flush() except Exception as e: From 46060afd5d3261a37910322325ba3013218aaf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:53:06 +0900 Subject: [PATCH 05/16] =?UTF-8?q?feat:=20route=20res=20admin=20put=20book?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/admin/response/book_response.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/routes/admin/response/book_response.py b/src/routes/admin/response/book_response.py index a7074584..7fdc7743 100644 --- a/src/routes/admin/response/book_response.py +++ b/src/routes/admin/response/book_response.py @@ -21,3 +21,21 @@ class RouteResAdminPostBook(BaseModel): donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) + +class RouteResAdminPutBook(BaseModel): + book_id: int = Field(title="book_id", description="책 ID", gt=0) + book_title: str = Field(title="book_title", description="책 제목", example="FastAPI Tutorial") + code: str = Field(title="code", description="책 코드", examples="A3") + category_name: str = Field(title="category_name", description="카테고리명", examples="웹") + subtitle: Optional[str] = Field(title="subtitle", description="책 부제", default=None) + author : str = Field(title="author", description="저자") + publisher: str = Field(title="publisher", description="출판사") + publication_year: int = Field(title="publication_year", description="출판연도", gt=0) + image_url: Optional[str] = Field(title="image_url", description="책 표지", default=None) + version: Optional[str] = Field(title="version", description="판본", default=None) + major: bool = Field(title="major", description="전공 책 여부", default=False) + language: str = Field(title="language", description="언어", default="KOREAN") + book_status = Field(title="book_status", description="도서 상태", default=True) + donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) + created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) + updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) From 98da06ecbf947b8351a1f727b5584c9501a8b1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Wed, 13 Nov 2024 22:54:01 +0900 Subject: [PATCH 06/16] feat: rout update admin book --- src/routes/admin/admin_books_route.py | 57 ++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index 2a6ce563..83aa1290 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -2,10 +2,10 @@ from sqlalchemy.orm import Session from dependencies import get_current_admin, get_db -from domain.schemas.book_schemas import DomainReqAdminPostBook -from domain.services.admin.book_service import service_admin_create_book -from routes.admin.request.book_request import RouteReqAdminPostBook -from routes.admin.response.book_response import RouteResAdminPostBook +from domain.schemas.book_schemas import DomainReqAdminPostBook, DomainReqAdminPutBook +from domain.services.admin.book_service import service_admin_create_book, service_admin_update_book +from routes.admin.request.book_request import RouteReqAdminPostBook, RouteReqAdminPutBook +from routes.admin.response.book_response import RouteResAdminPostBook, RouteResAdminPutBook router = APIRouter( prefix="/admin/books", @@ -39,7 +39,54 @@ async def create_admin_book( ) domain_res = await service_admin_create_book(domain_req, db) result = RouteResAdminPostBook( - book_id=domain_res.id, + book_id=domain_res.book_id, + book_title=domain_res.book_title, + code=domain_res.code, + category_name=domain_res.category_name, + subtitle=domain_res.subtitle, + author=domain_res.author, + publisher=domain_res.publisher, + publication_year=domain_res.publication_year, + image_url=domain_res.image_url, + version=domain_res.version, + major=domain_res.major, + language=domain_res.language, + book_status=domain_res.book_status, + donor_name=domain_res.donor_name, + created_at=domain_res.created_at, + updated_at=domain_res.updated_at + ) + return result + + +@router.put( + "/{book_id}", + summary="관리자 도서 정보 수정", + status_code=status.HTTP_200_OK +) +async def update_admin_book( + book_id: int, + request: RouteReqAdminPutBook, + db: Session = Depends(get_db), +): + domain_req = DomainReqAdminPutBook( + book_id= book_id, + book_title = request.book_title, + code=request.code, + category_name = request.category_name, + subtitle=request.subtitle, + author=request.author, + publisher=request.publisher, + publication_year=request.publication_year, + image_url = request.image_url, + version = request.version, + major = request.major, + language=request.language, + donor_name = request.donor_name + ) + domain_res = await service_admin_update_book(domain_req, db) + result = RouteResAdminPutBook( + book_id=domain_res.book_id, book_title=domain_res.book_title, code=domain_res.code, category_name=domain_res.category_name, From e1e02436c7646eee8a7dd971493ad5537a9012b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 00:37:19 +0900 Subject: [PATCH 07/16] =?UTF-8?q?style:=20=EA=B3=B5=EB=B0=B1=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/services/admin/book_service.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index ba35da01..dc7318a5 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -135,5 +135,4 @@ async def service_admin_update_book(request: DomainReqAdminPutBook, db: Session) updated_at=request_book.updated_at ) - return domain_res From d9e721c9d0c5d9495b751ec454dd5b3f2dfcbdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 00:48:40 +0900 Subject: [PATCH 08/16] feat: domain request admin delete book --- src/domain/schemas/book_schemas.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/domain/schemas/book_schemas.py b/src/domain/schemas/book_schemas.py index 9d504cdb..bdd6865c 100644 --- a/src/domain/schemas/book_schemas.py +++ b/src/domain/schemas/book_schemas.py @@ -67,3 +67,6 @@ class DomainResAdminPostBook(BaseModel): donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) + +class DomainReqAdminDelBook(BaseModel): + book_id: int = Field(title="book_id", description="책 ID", gt=0) From c2a44e8b30e50b72c8b3aa98b2f4035fb6caf33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 00:54:40 +0900 Subject: [PATCH 09/16] feat: admin delete book service --- src/domain/services/admin/book_service.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index 36c7d5f0..b287fc67 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -5,8 +5,9 @@ from sqlalchemy.orm import Session from domain.enums.book_category import BookCategoryStatus -from domain.schemas.book_schemas import DomainReqAdminPostBook, DomainResAdminPostBook +from domain.schemas.book_schemas import DomainReqAdminDelBook, DomainReqAdminPostBook, DomainResAdminPostBook from repositories.models import Book +from src.utils.crud_utils import delete_item async def service_admin_create_book(request: DomainReqAdminPostBook, db: Session): @@ -69,3 +70,7 @@ async def service_admin_create_book(request: DomainReqAdminPostBook, db: Session updated_at=new_book.updated_at ) return domain_res + +async def service_admin_delete_book(request: DomainReqAdminDelBook, db: Session): + delete_item(Book, request.book_id, db) + return From 462d6cef722aac3c79de676d418d502dcf30c055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 00:56:00 +0900 Subject: [PATCH 10/16] feat: route admin book delete --- src/routes/admin/admin_books_route.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index 2a6ce563..e0fc64ae 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -2,8 +2,8 @@ from sqlalchemy.orm import Session from dependencies import get_current_admin, get_db -from domain.schemas.book_schemas import DomainReqAdminPostBook -from domain.services.admin.book_service import service_admin_create_book +from domain.schemas.book_schemas import DomainReqAdminDelBook, DomainReqAdminPostBook +from domain.services.admin.book_service import service_admin_create_book, service_admin_delete_book from routes.admin.request.book_request import RouteReqAdminPostBook from routes.admin.response.book_response import RouteResAdminPostBook @@ -57,3 +57,18 @@ async def create_admin_book( updated_at=domain_res.updated_at ) return result + +@router.delete( + "/{book_id}", + summary="관리자 도서 정보 등록", + status_code=status.HTTP_204_NO_CONTENT +) +async def delete_admin_book( + book_id: int, + db: Session = Depends(get_db), +): + domain_req = DomainReqAdminDelBook( + book_id=book_id + ) + await service_admin_delete_book(domain_req, db) + return From 8854815688ed64e636d5a8fcbf46fcfe487ac120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 01:13:17 +0900 Subject: [PATCH 11/16] =?UTF-8?q?fix:=20POST=20admin=20book=20response=20m?= =?UTF-8?q?odel=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/admin/admin_books_route.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index e0fc64ae..3b062e09 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -17,6 +17,7 @@ @router.post( "/", summary="관리자 도서 정보 등록", + response_model=RouteResAdminPostBook, status_code=status.HTTP_201_CREATED ) async def create_admin_book( From 1a3bd48cc296aa812065a34c8f2dc64836ba04a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 01:14:51 +0900 Subject: [PATCH 12/16] =?UTF-8?q?fix:=20router=20response=20model=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/admin/admin_books_route.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index 83aa1290..e820c7aa 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -17,6 +17,7 @@ @router.post( "/", summary="관리자 도서 정보 등록", + response_model=RouteResAdminPostBook, status_code=status.HTTP_201_CREATED ) async def create_admin_book( @@ -62,6 +63,7 @@ async def create_admin_book( @router.put( "/{book_id}", summary="관리자 도서 정보 수정", + response_model=RouteResAdminPutBook, status_code=status.HTTP_200_OK ) async def update_admin_book( From 2a2aca72c0b8e3a83028f853f33761b3c171bfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 14:49:31 +0900 Subject: [PATCH 13/16] =?UTF-8?q?fix:=20=EB=88=84=EB=9D=BD=EB=90=9C=20book?= =?UTF-8?q?=5Fstatus=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/schemas/book_schemas.py | 1 + src/routes/admin/admin_books_route.py | 1 + src/routes/admin/request/book_request.py | 1 + 3 files changed, 3 insertions(+) diff --git a/src/domain/schemas/book_schemas.py b/src/domain/schemas/book_schemas.py index 93aecb6a..6310be8e 100644 --- a/src/domain/schemas/book_schemas.py +++ b/src/domain/schemas/book_schemas.py @@ -81,6 +81,7 @@ class DomainReqAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") + book_status = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class DomainResAdminPutBook(BaseModel): diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index e820c7aa..d02f8f32 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -84,6 +84,7 @@ async def update_admin_book( version = request.version, major = request.major, language=request.language, + book_status=request.book_status, donor_name = request.donor_name ) domain_res = await service_admin_update_book(domain_req, db) diff --git a/src/routes/admin/request/book_request.py b/src/routes/admin/request/book_request.py index 278a0711..3ed79996 100644 --- a/src/routes/admin/request/book_request.py +++ b/src/routes/admin/request/book_request.py @@ -29,4 +29,5 @@ class RouteReqAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") + book_status = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) From 890c1c9265abba571dea965fe04947c183bc6aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 15:08:58 +0900 Subject: [PATCH 14/16] =?UTF-8?q?fix:=20POST=20reqest=EC=97=90=20book=5Fst?= =?UTF-8?q?atus=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/schemas/book_schemas.py | 1 + src/domain/services/admin/book_service.py | 2 +- src/routes/admin/admin_books_route.py | 1 + src/routes/admin/request/book_request.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/domain/schemas/book_schemas.py b/src/domain/schemas/book_schemas.py index 6310be8e..1234e83e 100644 --- a/src/domain/schemas/book_schemas.py +++ b/src/domain/schemas/book_schemas.py @@ -48,6 +48,7 @@ class DomainReqAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") + book_status = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class DomainResAdminPostBook(BaseModel): diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index dc7318a5..baa52d87 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -39,7 +39,7 @@ async def service_admin_create_book(request: DomainReqAdminPostBook, db: Session image_url = request.image_url, version = request.version, major = request.major, - book_status = True, + book_status = request.book_status, donor_name = request.donor_name, created_at = datetime.now(), updated_at = datetime.now(), diff --git a/src/routes/admin/admin_books_route.py b/src/routes/admin/admin_books_route.py index d02f8f32..3bef2f13 100644 --- a/src/routes/admin/admin_books_route.py +++ b/src/routes/admin/admin_books_route.py @@ -36,6 +36,7 @@ async def create_admin_book( version = request.version, major = request.major, language=request.language, + book_status=request.book_status, donor_name = request.donor_name ) domain_res = await service_admin_create_book(domain_req, db) diff --git a/src/routes/admin/request/book_request.py b/src/routes/admin/request/book_request.py index 3ed79996..2ed71eac 100644 --- a/src/routes/admin/request/book_request.py +++ b/src/routes/admin/request/book_request.py @@ -15,6 +15,7 @@ class RouteReqAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") + book_status = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class RouteReqAdminPutBook(BaseModel): From 7855bf21c0e57bc147804345c14f65629bfe316b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 15:24:20 +0900 Subject: [PATCH 15/16] style: typo --- src/domain/schemas/book_schemas.py | 8 ++++---- src/domain/services/admin/book_service.py | 2 +- src/routes/admin/request/book_request.py | 4 ++-- src/routes/admin/response/book_response.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/domain/schemas/book_schemas.py b/src/domain/schemas/book_schemas.py index 7d0ac0ae..e34c3bc2 100644 --- a/src/domain/schemas/book_schemas.py +++ b/src/domain/schemas/book_schemas.py @@ -48,7 +48,7 @@ class DomainReqAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class DomainResAdminPostBook(BaseModel): @@ -64,7 +64,7 @@ class DomainResAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) @@ -82,7 +82,7 @@ class DomainReqAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class DomainResAdminPutBook(BaseModel): @@ -98,7 +98,7 @@ class DomainResAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) diff --git a/src/domain/services/admin/book_service.py b/src/domain/services/admin/book_service.py index 2bcdbc84..9ad965f0 100644 --- a/src/domain/services/admin/book_service.py +++ b/src/domain/services/admin/book_service.py @@ -13,7 +13,7 @@ DomainResAdminPutBook, ) from repositories.models import Book -from src.utils.crud_utils import delete_item +from utils.crud_utils import delete_item async def service_admin_create_book(request: DomainReqAdminPostBook, db: Session): diff --git a/src/routes/admin/request/book_request.py b/src/routes/admin/request/book_request.py index 2ed71eac..2bfe16eb 100644 --- a/src/routes/admin/request/book_request.py +++ b/src/routes/admin/request/book_request.py @@ -15,7 +15,7 @@ class RouteReqAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) class RouteReqAdminPutBook(BaseModel): @@ -30,5 +30,5 @@ class RouteReqAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) diff --git a/src/routes/admin/response/book_response.py b/src/routes/admin/response/book_response.py index 7fdc7743..b2c2ce1e 100644 --- a/src/routes/admin/response/book_response.py +++ b/src/routes/admin/response/book_response.py @@ -17,7 +17,7 @@ class RouteResAdminPostBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) @@ -35,7 +35,7 @@ class RouteResAdminPutBook(BaseModel): version: Optional[str] = Field(title="version", description="판본", default=None) major: bool = Field(title="major", description="전공 책 여부", default=False) language: str = Field(title="language", description="언어", default="KOREAN") - book_status = Field(title="book_status", description="도서 상태", default=True) + book_status: bool = Field(title="book_status", description="도서 상태", default=True) donor_name: Optional[str] = Field(title="donor_name", description="기부자명", default=None) created_at: datetime = Field(title="create_at", description="생성일시", example=datetime.now()) updated_at: datetime = Field(title="update_at", description="수정일시", example=datetime.now()) From 3b5d87bbef67ff8ea90cb4a997acb936a2e929d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=9C=A0=EB=82=98?= Date: Thu, 14 Nov 2024 15:27:06 +0900 Subject: [PATCH 16/16] style: typo (examples -> example) --- src/routes/admin/response/book_response.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/admin/response/book_response.py b/src/routes/admin/response/book_response.py index b2c2ce1e..6839ce89 100644 --- a/src/routes/admin/response/book_response.py +++ b/src/routes/admin/response/book_response.py @@ -7,8 +7,8 @@ class RouteResAdminPostBook(BaseModel): book_id: int = Field(title="book_id", description="책 ID", gt=0) book_title: str = Field(title="book_title", description="책 제목", example="FastAPI Tutorial") - code: str = Field(title="code", description="책 코드", examples="A3") - category_name: str = Field(title="category_name", description="카테고리명", examples="웹") + code: str = Field(title="code", description="책 코드", example="A3") + category_name: str = Field(title="category_name", description="카테고리명", example="웹") subtitle: Optional[str] = Field(title="subtitle", description="책 부제", default=None) author : str = Field(title="author", description="저자") publisher: str = Field(title="publisher", description="출판사") @@ -25,8 +25,8 @@ class RouteResAdminPostBook(BaseModel): class RouteResAdminPutBook(BaseModel): book_id: int = Field(title="book_id", description="책 ID", gt=0) book_title: str = Field(title="book_title", description="책 제목", example="FastAPI Tutorial") - code: str = Field(title="code", description="책 코드", examples="A3") - category_name: str = Field(title="category_name", description="카테고리명", examples="웹") + code: str = Field(title="code", description="책 코드", example="A3") + category_name: str = Field(title="category_name", description="카테고리명", example="웹") subtitle: Optional[str] = Field(title="subtitle", description="책 부제", default=None) author : str = Field(title="author", description="저자") publisher: str = Field(title="publisher", description="출판사")