Fascicoli+Tassonomia+permessi
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
Router tag (Label).
|
||||
Router tag (Label) con supporto tassonomia gerarchica (Feature N2).
|
||||
|
||||
Endpoint:
|
||||
- GET /labels – elenca i tag del tenant
|
||||
- POST /labels – crea un nuovo tag (admin)
|
||||
- GET /labels – elenca i tag del tenant (flat)
|
||||
- GET /labels/tree – albero tassonomico (Ambito > Processo > Classificazione)
|
||||
- POST /labels – crea un nuovo tag / nodo tassonomico (admin)
|
||||
- PATCH /labels/{id} – modifica un tag (admin)
|
||||
- DELETE /labels/{id} – elimina un tag (admin)
|
||||
|
||||
@@ -31,6 +32,7 @@ from app.models.message import Message
|
||||
from app.schemas.label import (
|
||||
LabelCreate,
|
||||
LabelResponse,
|
||||
LabelTreeResponse,
|
||||
LabelUpdate,
|
||||
MessageBulkLabelRequest,
|
||||
MessageBulkLabelResponse,
|
||||
@@ -77,12 +79,28 @@ async def list_labels(
|
||||
current_user: CurrentUser,
|
||||
db: DB,
|
||||
) -> list[LabelResponse]:
|
||||
"""Elenca tutti i tag del tenant corrente."""
|
||||
"""Elenca tutti i tag del tenant corrente (lista flat, include nodi tassonomici)."""
|
||||
svc = LabelService(db)
|
||||
labels = await svc.list_labels(current_user.tenant_id)
|
||||
return [LabelResponse.model_validate(l) for l in labels]
|
||||
|
||||
|
||||
@router.get("/labels/tree", response_model=list[LabelTreeResponse])
|
||||
async def get_label_tree(
|
||||
current_user: CurrentUser,
|
||||
db: DB,
|
||||
) -> list[LabelTreeResponse]:
|
||||
"""
|
||||
Restituisce la tassonomia come albero annidato.
|
||||
|
||||
Struttura: [ Ambito { children: [ Processo { children: [ Classificazione ] } ] } ]
|
||||
|
||||
I nodi radice (parent_id=NULL) possono essere sia Ambiti tassonomici che label piatte.
|
||||
"""
|
||||
svc = LabelService(db)
|
||||
return await svc.get_label_tree(current_user.tenant_id)
|
||||
|
||||
|
||||
@router.post("/labels", response_model=LabelResponse, status_code=status.HTTP_201_CREATED)
|
||||
async def create_label(
|
||||
data: LabelCreate,
|
||||
|
||||
Reference in New Issue
Block a user