fix: bugs-04
This commit is contained in:
@@ -5,7 +5,12 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.repositories.transaction_repo import TransactionRepository
|
||||
from app.schemas.transaction import TransactionOut, TransactionListOut, FlowGraphOut
|
||||
from app.schemas.transaction import (
|
||||
TransactionOut,
|
||||
TransactionListOut,
|
||||
FlowGraphOut,
|
||||
TransactionUpdateIn,
|
||||
)
|
||||
from app.services.flow_service import build_flow_graph
|
||||
|
||||
router = APIRouter()
|
||||
@@ -31,6 +36,23 @@ async def get_transaction(tx_id: UUID, db: AsyncSession = Depends(get_db)):
|
||||
return tx
|
||||
|
||||
|
||||
@router.patch("/transactions/{tx_id}", response_model=TransactionOut)
|
||||
async def update_transaction(
|
||||
tx_id: UUID,
|
||||
body: TransactionUpdateIn,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = TransactionRepository(db)
|
||||
tx = await repo.get(tx_id)
|
||||
if not tx:
|
||||
raise HTTPException(404, "交易不存在")
|
||||
|
||||
update_data = body.model_dump(exclude_unset=True)
|
||||
tx = await repo.update(tx, update_data)
|
||||
await db.commit()
|
||||
return tx
|
||||
|
||||
|
||||
@router.get("/cases/{case_id}/flows", response_model=FlowGraphOut)
|
||||
async def get_fund_flows(case_id: UUID, db: AsyncSession = Depends(get_db)):
|
||||
return await build_flow_graph(case_id, db)
|
||||
|
||||
Reference in New Issue
Block a user