refactor: mixins for services
This commit is contained in:
@ -14,6 +14,7 @@ class BaseSchema(BaseModel):
|
||||
from_attributes = True
|
||||
alias_generator = to_camel
|
||||
populate_by_name = True
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
@classmethod
|
||||
def from_sql_model(cls, model, fields: dict):
|
||||
|
||||
21
schemas/base_crud.py
Normal file
21
schemas/base_crud.py
Normal file
@ -0,0 +1,21 @@
|
||||
from typing import TypeVar
|
||||
|
||||
from schemas.base import BaseResponse, BaseSchema
|
||||
|
||||
SchemaType = TypeVar("SchemaType", bound=BaseSchema)
|
||||
|
||||
|
||||
class BaseGetAllResponse[SchemaType](BaseSchema):
|
||||
items: list[SchemaType]
|
||||
|
||||
|
||||
class BaseCreateResponse[SchemaType](BaseResponse):
|
||||
entity: SchemaType
|
||||
|
||||
|
||||
class BaseUpdateResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class BaseDeleteResponse(BaseResponse):
|
||||
pass
|
||||
Reference in New Issue
Block a user