Coverage for app/ddd/presentation/endpoint/group/query_group.py: 73%
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.group import QueryGroupInputDTO, QueryGroupOutputDTO
5from app.ddd.application.usecase.group import QueryGroupUseCase
6from app.ddd.infrastructure.database.db import get_session
7from app.ddd.infrastructure.uow import GroupUnitOfWorkImpl
8from app.ddd.presentation.endpoint.group.router import router
9from app.ddd.presentation.schema.group import QueryGroupRequest, QueryGroupResponse
12def __usecase(session: Session = Depends(get_session)) -> QueryGroupUseCase:
13 return QueryGroupUseCase(uow=GroupUnitOfWorkImpl(session))
16@router.post(
17 path="/query/groups",
18 response_model=QueryGroupResponse
19)
20def query_group(
21 request: QueryGroupRequest,
22 usecase: QueryGroupUseCase = Depends(__usecase),
23) -> QueryGroupResponse:
24 """Userをクエリする."""
25 input_dto: QueryGroupInputDTO = QueryGroupInputDTO.model_validate(request)
26 dto: QueryGroupOutputDTO = usecase.execute(input_dto)
27 return QueryGroupResponse.model_validate(dto)