Coverage for app/ddd/presentation/schema/user/user_request.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
3from datetime import datetime
4from typing import Any
6# from sqlmodel import Field
7from pydantic import Field, validator
9from app.core.base import BaseRequest
10from app.ddd.infrastructure.util.convert import recursive_to_snake
13class CreateUserRequest(BaseRequest):
14 user_id: str
15 user_password: str
16 user_name: str
17 user_role_code: str = Field(default="99")
19class PatchUsersRequest(BaseRequest):
20 updated_at: datetime # 楽観的ロック用途
21 user_password: str | None = Field(None)
22 user_name: str | None = Field(None)
23 user_role_code: str | None = Field(None)
26_filters_example: dict[str, Any] = {
27 "userId": "guest",
28}
30class QueryUserRequest(BaseRequest):
31 offset: int = Field(default=0)
32 limit: int = Field(default=10)
33 query: dict[str,Any] = Field(
34 default={},
35 examples=[_filters_example]
36 )
38 @validator("query", pre=True, always=True)
39 def validate_query(cls, query: dict[str, Any]) -> dict[str, Any]:
40 """filtersのcaseをスネークに変換する."""
41 # query = query or {}
42 return recursive_to_snake(query)