feat: plantilla base workspace SaaS
Convierte el repositorio de Anexo76 en una plantilla limpia y reutilizable para nuevos proyectos del ecosistema Workspace de Aduanasoft. Cambios principales: - Elimina módulos específicos de Anexo76: a76, a24, sitar, public - Agrega módulo example/ con patrón CRUD de referencia (models/dto/service/routes) - Limpia migraciones Alembic: solo quedan las 6 de core (users, tenants, permissions) - Reemplaza todas las rutas del dashboard con stubs genéricos - Elimina lógica de negocio aduanera: shortcuts, CSV imports, permisos, catálogos - Simplifica variables de entorno: una sola WORKSPACE_URL deriva Hub y Keycloak - Agrega scripts/auth-mode.sh para alternar entre auth local y workspace - Configura docker-compose con nombres genéricos (app-*) - Corrige flujo SSO: elimina system-gate SCAF/SCAII que bloqueaba el login - Modo DEV_LOCAL_AUTH para desarrollo sin Keycloak ni Hub Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
65
backend/api/v1/modules/example/routes.py
Normal file
65
backend/api/v1/modules/example/routes.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from fastapi import APIRouter, Depends, Query, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from core.database import get_core_db
|
||||
from core.security import get_current_user
|
||||
|
||||
from .dto import ItemCreate, ItemResponse, ItemUpdate
|
||||
from . import service
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/items", response_model=list[ItemResponse])
|
||||
def list_items(
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_core_db),
|
||||
):
|
||||
tenant_id = current_user["tenant_id"]
|
||||
return service.get_items(db, tenant_id, company_id)
|
||||
|
||||
|
||||
@router.get("/items/{item_id}", response_model=ItemResponse)
|
||||
def get_item(
|
||||
item_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_core_db),
|
||||
):
|
||||
tenant_id = current_user["tenant_id"]
|
||||
return service.get_item(db, item_id, tenant_id, company_id)
|
||||
|
||||
|
||||
@router.post("/items", response_model=ItemResponse, status_code=status.HTTP_201_CREATED)
|
||||
def create_item(
|
||||
payload: ItemCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_core_db),
|
||||
):
|
||||
tenant_id = current_user["tenant_id"]
|
||||
return service.create_item(db, payload, tenant_id, company_id)
|
||||
|
||||
|
||||
@router.patch("/items/{item_id}", response_model=ItemResponse)
|
||||
def update_item(
|
||||
item_id: int,
|
||||
payload: ItemUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_core_db),
|
||||
):
|
||||
tenant_id = current_user["tenant_id"]
|
||||
return service.update_item(db, item_id, payload, tenant_id, company_id)
|
||||
|
||||
|
||||
@router.delete("/items/{item_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
def delete_item(
|
||||
item_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: Session = Depends(get_core_db),
|
||||
):
|
||||
tenant_id = current_user["tenant_id"]
|
||||
service.delete_item(db, item_id, tenant_id, company_id)
|
||||
Reference in New Issue
Block a user