29 lines
965 B
Python
29 lines
965 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Annotated
|
||
|
|
|
||
|
|
from fastapi import APIRouter, Depends
|
||
|
|
|
||
|
|
from core.auth.models import CurrentUser
|
||
|
|
from v1.points.dependencies import get_points_service
|
||
|
|
from v1.points.schemas import PointsBalanceResponse
|
||
|
|
from v1.points.service import PointsService
|
||
|
|
from v1.users.dependencies import get_current_user
|
||
|
|
|
||
|
|
router = APIRouter(prefix="/points", tags=["points"])
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/balance", response_model=PointsBalanceResponse)
|
||
|
|
async def get_points_balance(
|
||
|
|
service: Annotated[PointsService, Depends(get_points_service)],
|
||
|
|
current_user: Annotated[CurrentUser, Depends(get_current_user)],
|
||
|
|
) -> PointsBalanceResponse:
|
||
|
|
result = await service.get_points_balance(user_id=current_user.id)
|
||
|
|
return PointsBalanceResponse(
|
||
|
|
balance=result.balance,
|
||
|
|
frozenBalance=result.frozen_balance,
|
||
|
|
availableBalance=result.available_balance,
|
||
|
|
runCost=result.run_cost,
|
||
|
|
canRun=result.can_run,
|
||
|
|
)
|