Add admin-frontend and user-frontend standalone projects, certification/invoice/discovery features, fix auth header and theme consistency
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from app.database import get_db
|
||||
from app.api.v1.deps import get_current_user_id
|
||||
from app.services.invoice import InvoiceService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
class InvoiceApplyRequest(BaseModel):
|
||||
invoice_type: str
|
||||
title: str
|
||||
tax_id: Optional[str] = None
|
||||
amount: float
|
||||
|
||||
|
||||
@router.post("/apply")
|
||||
async def apply_invoice(
|
||||
data: InvoiceApplyRequest,
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
service = InvoiceService(db)
|
||||
result = await service.apply(user_id, data.model_dump())
|
||||
if "error" in result:
|
||||
raise HTTPException(status_code=400, detail=result["error"])
|
||||
return {"success": True, "data": result}
|
||||
|
||||
|
||||
@router.get("/list")
|
||||
async def list_invoices(
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
service = InvoiceService(db)
|
||||
items = await service.list_user(user_id)
|
||||
return {"success": True, "data": items}
|
||||
Reference in New Issue
Block a user