Coverage for app/ddd/presentation/endpoint/user/query_user.py: 100%
15 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
1from fastapi import Depends
2from sqlmodel import Session
4from app.ddd.application.dto.user import QueryUserInputDTO, QueryUserOutputDTO
5from app.ddd.application.usecase.user import QueryUserUseCase
6from app.ddd.infrastructure.database.db import get_session
7from app.ddd.infrastructure.uow import UserUnitOfWorkImpl
8from app.ddd.presentation.endpoint.user.router import router
9from app.ddd.presentation.schema.user import QueryUserRequest, QueryUserResponse
12def __usecase(session: Session = Depends(get_session)) -> QueryUserUseCase:
13 return QueryUserUseCase(uow=UserUnitOfWorkImpl(session))
16@router.post(
17 path="/query/users",
18 response_model=QueryUserResponse
19)
20def query_user(
21 request: QueryUserRequest,
22 usecase: QueryUserUseCase = Depends(__usecase),
23) -> QueryUserResponse:
24 """Userをクエリする."""
25 input_dto: QueryUserInputDTO = QueryUserInputDTO.model_validate(request)
26 dto: QueryUserOutputDTO = usecase.execute(input_dto)
27 return QueryUserResponse.model_validate(dto)