[refactor] negodata/backend: 공용 PageParams(page/size/skip) + 상태 enum·모델 정비
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ece24f4067
commit
4587be5844
3 files changed
+133
-17
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Query
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from common.enums import ErrorType
|
||||
@@ -45,6 +46,24 @@ class Res_WebPacketProtocol(WebPacketProtocol):
|
||||
msg: Optional[str] = None
|
||||
|
||||
|
||||
class Res_PageProtocol(Res_WebPacketProtocol):
|
||||
# 목록 응답 공용 페이지 메타.
|
||||
total: int = 0
|
||||
page: int = 0
|
||||
size: int = 0
|
||||
|
||||
|
||||
class PageParams:
|
||||
# 목록 엔드포인트 공용 쿼리 파라미터. 라우터에서 Depends() 로 주입한다.
|
||||
def __init__(self, page: int = Query(1, ge=1), size: int = Query(20, ge=1, le=100)):
|
||||
self.page = page
|
||||
self.size = size
|
||||
|
||||
@property
|
||||
def skip(self) -> int:
|
||||
return (self.page - 1) * self.size
|
||||
|
||||
|
||||
class UserInfo(StructModel):
|
||||
"""JWT subject 로 인코딩되는 유저 식별 정보."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user