ajuste de cruds incompleto

This commit is contained in:
2026-04-06 16:06:31 -07:00
parent 61d386a7c7
commit 290a32364d
75 changed files with 3574 additions and 26 deletions

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.branches.models import Branches
from app.modules.branches.schema import , Response
from app.modules.branches.services import BranchesService
router = APIRouter(prefix="/branches", tags=["branches"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_branches(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a branches - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create branches")
try:
result = BranchesService.create_branches(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_branchess(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return BranchesService.get_branchess(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_branches_by_id(
branches_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get branches by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = BranchesService.get_branches(db=db, branches_id=branches_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_branches(
branches_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing branches - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update branches")
try:
result = BranchesService.update_branches(
db=db,
branches_id=branches_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_branches(
branches_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete branches by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete branches")
try:
result = BranchesService.delete_branches(db=db, branches_id=branches_id, current_user=current_user)
return {"message": "branches deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,117 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.client.models import Client
from app.modules.client.schema import , Response
from app.modules.client.services import ClientService
router = APIRouter(prefix="/client", tags=["client"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_client(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a client - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create client")
try:
result = ClientService.create_client(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_clients(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return ClientService.get_clients(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/client_id}", response_model=Response)
def get_client_by_id(
client_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get client by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = ClientService.get_client(db=db, client_id=client_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/client_id}", response_model=Response)
async def update_client(
client_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing client - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update client")
try:
result = ClientService.update_client(
db=db,
client_id=client_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/client_id}", status_code=status.HTTP_200_OK)
async def delete_client(
client_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete client by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete client")
try:
result = ClientService.delete_client(db=db, client_id=client_id, current_user=current_user)
return {"message": "client deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.coments.models import Coments
from app.modules.coments.schema import , Response
from app.modules.coments.services import ComentsService
router = APIRouter(prefix="/coments", tags=["coments"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_coments(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a coments - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create coments")
try:
result = ComentsService.create_coments(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_comentss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return ComentsService.get_comentss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_coments_by_id(
coments_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get coments by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = ComentsService.get_coments(db=db, coments_id=coments_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_coments(
coments_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing coments - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update coments")
try:
result = ComentsService.update_coments(
db=db,
coments_id=coments_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_coments(
coments_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete coments by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete coments")
try:
result = ComentsService.delete_coments(db=db, coments_id=coments_id, current_user=current_user)
return {"message": "coments deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.configuration.models import Configuration
from app.modules.configuration.schema import , Response
from app.modules.configuration.services import ConfigurationService
router = APIRouter(prefix="/configuration", tags=["configuration"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_configuration(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a configuration - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create configuration")
try:
result = ConfigurationService.create_configuration(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_configurations(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return ConfigurationService.get_configurations(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_configuration_by_id(
configuration_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get configuration by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = ConfigurationService.get_configuration(db=db, configuration_id=configuration_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_configuration(
configuration_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing configuration - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update configuration")
try:
result = ConfigurationService.update_configuration(
db=db,
configuration_id=configuration_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_configuration(
configuration_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete configuration by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete configuration")
try:
result = ConfigurationService.delete_configuration(db=db, configuration_id=configuration_id, current_user=current_user)
return {"message": "configuration deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.credits.models import Credits
from app.modules.credits.schema import , Response
from app.modules.credits.services import CreditsService
router = APIRouter(prefix="/credits", tags=["credits"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_credits(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a credits - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create credits")
try:
result = CreditsService.create_credits(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_creditss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return CreditsService.get_creditss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_credits_by_id(
credits_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get credits by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = CreditsService.get_credits(db=db, credits_id=credits_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_credits(
credits_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing credits - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update credits")
try:
result = CreditsService.update_credits(
db=db,
credits_id=credits_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_credits(
credits_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete credits by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete credits")
try:
result = CreditsService.delete_credits(db=db, credits_id=credits_id, current_user=current_user)
return {"message": "credits deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.edos.models import EDOS
from app.modules.edos.schema import , Response
from app.modules.edos.services import EDOSService
router = APIRouter(prefix="/edos", tags=["edos"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_edos(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a edos - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create edos")
try:
result = EDOSService.create_edos(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_edoss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return EDOSService.get_edoss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_edos_by_id(
edos_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get edos by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = EDOSService.get_edos(db=db, edos_id=edos_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_edos(
edos_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing edos - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update edos")
try:
result = EDOSService.update_edos(
db=db,
edos_id=edos_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_edos(
edos_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete edos by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete edos")
try:
result = EDOSService.delete_edos(db=db, edos_id=edos_id, current_user=current_user)
return {"message": "edos deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.efos.models import EFOS
from app.modules.efos.schema import , Response
from app.modules.efos.services import EFOSService
router = APIRouter(prefix="/efos", tags=["efos"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_efos(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a efos - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create efos")
try:
result = EFOSService.create_efos(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_efoss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return EFOSService.get_efoss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_efos_by_id(
efos_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get efos by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = EFOSService.get_efos(db=db, efos_id=efos_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_efos(
efos_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing efos - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update efos")
try:
result = EFOSService.update_efos(
db=db,
efos_id=efos_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_efos(
efos_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete efos by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete efos")
try:
result = EFOSService.delete_efos(db=db, efos_id=efos_id, current_user=current_user)
return {"message": "efos deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.feed.models import Feed
from app.modules.feed.schema import , Response
from app.modules.feed.services import FeedService
router = APIRouter(prefix="/feed", tags=["feed"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_feed(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a feed - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create feed")
try:
result = FeedService.create_feed(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_feeds(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return FeedService.get_feeds(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_feed_by_id(
feed_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get feed by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = FeedService.get_feed(db=db, feed_id=feed_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_feed(
feed_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing feed - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update feed")
try:
result = FeedService.update_feed(
db=db,
feed_id=feed_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_feed(
feed_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete feed by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete feed")
try:
result = FeedService.delete_feed(db=db, feed_id=feed_id, current_user=current_user)
return {"message": "feed deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.files.models import Files
from app.modules.files.schema import , Response
from app.modules.files.services import FilesService
router = APIRouter(prefix="/files", tags=["files"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_files(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a files - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create files")
try:
result = FilesService.create_files(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_filess(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return FilesService.get_filess(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_files_by_id(
files_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get files by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = FilesService.get_files(db=db, files_id=files_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_files(
files_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing files - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update files")
try:
result = FilesService.update_files(
db=db,
files_id=files_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_files(
files_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete files by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete files")
try:
result = FilesService.delete_files(db=db, files_id=files_id, current_user=current_user)
return {"message": "files deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.invoices.models import Invoices
from app.modules.invoices.schema import , Response
from app.modules.invoices.services import InvoicesService
router = APIRouter(prefix="/invoices", tags=["invoices"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_invoices(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a invoices - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create invoices")
try:
result = InvoicesService.create_invoices(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_invoicess(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return InvoicesService.get_invoicess(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_invoices_by_id(
invoices_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get invoices by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = InvoicesService.get_invoices(db=db, invoices_id=invoices_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_invoices(
invoices_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing invoices - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update invoices")
try:
result = InvoicesService.update_invoices(
db=db,
invoices_id=invoices_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_invoices(
invoices_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete invoices by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete invoices")
try:
result = InvoicesService.delete_invoices(db=db, invoices_id=invoices_id, current_user=current_user)
return {"message": "invoices deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.license.models import License
from app.modules.license.schema import , Response
from app.modules.license.services import LicenseService
router = APIRouter(prefix="/license", tags=["license"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_license(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a license - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create license")
try:
result = LicenseService.create_license(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_licenses(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return LicenseService.get_licenses(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_license_by_id(
license_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get license by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = LicenseService.get_license(db=db, license_id=license_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_license(
license_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing license - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update license")
try:
result = LicenseService.update_license(
db=db,
license_id=license_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_license(
license_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete license by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete license")
try:
result = LicenseService.delete_license(db=db, license_id=license_id, current_user=current_user)
return {"message": "license deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.locations.models import Locations
from app.modules.locations.schema import , Response
from app.modules.locations.services import LocationsService
router = APIRouter(prefix="/locations", tags=["locations"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_locations(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a locations - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create locations")
try:
result = LocationsService.create_locations(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_locationss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return LocationsService.get_locationss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_locations_by_id(
locations_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get locations by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = LocationsService.get_locations(db=db, locations_id=locations_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_locations(
locations_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing locations - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update locations")
try:
result = LocationsService.update_locations(
db=db,
locations_id=locations_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_locations(
locations_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete locations by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete locations")
try:
result = LocationsService.delete_locations(db=db, locations_id=locations_id, current_user=current_user)
return {"message": "locations deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.moves.models import Moves
from app.modules.moves.schema import , Response
from app.modules.moves.services import MovesService
router = APIRouter(prefix="/moves", tags=["moves"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_moves(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a moves - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create moves")
try:
result = MovesService.create_moves(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_movess(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return MovesService.get_movess(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_moves_by_id(
moves_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get moves by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = MovesService.get_moves(db=db, moves_id=moves_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_moves(
moves_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing moves - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update moves")
try:
result = MovesService.update_moves(
db=db,
moves_id=moves_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_moves(
moves_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete moves by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete moves")
try:
result = MovesService.delete_moves(db=db, moves_id=moves_id, current_user=current_user)
return {"message": "moves deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))

View File

@@ -0,0 +1,116 @@
from fastapi import APIRouter, Depends, HTTPException, Query, Header, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from sqlalchemy.orm import Session
from typing import Optional, List
#
from database import get_db
from app.core.auth import get_current_user
from app.models.user import User # Modelo base de usuario
from app.modules.suppliers.models import Suppliers
from app.modules.suppliers.schema import , Response
from app.modules.suppliers.services import SuppliersService
router = APIRouter(prefix="/suppliers", tags=["suppliers"])
security = HTTPBearer()
#================ Create ====================
@router.post("/create", response_model=Response, status_code=status.HTTP_201_CREATED)
async def create_suppliers(
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Create a suppliers - Requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="User not found - invalid token")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to create suppliers")
try:
result = SuppliersService.create_suppliers(db=db, data=data)
return result
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
#================ Get ====================
@router.get("/", response_model=List[Response])
def get_supplierss(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
skip: int = Query(0, ge=0, description="Number of records to skip"),
limit: int = Query(100, ge=1, le=1000, description="Max number of records to return")
):
"""Get list with pagination - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
return SuppliersService.get_supplierss(db=db, skip=skip, limit=limit)
#================ Get by ID ====================
@router.get("/{{{entity_name}}_id}", response_model=Response)
def get_suppliers_by_id(
suppliers_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Get suppliers by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
try:
result = SuppliersService.get_suppliers(db=db, suppliers_id=suppliers_id, current_user=current_user)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Update ====================
@router.patch("/update/{{{entity_name}}_id}", response_model=Response)
async def update_suppliers(
suppliers_id: int,
data: ,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Update existing suppliers - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to update suppliers")
try:
result = SuppliersService.update_suppliers(
db=db,
suppliers_id=suppliers_id,
data=data,
current_user=current_user
)
return result
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
#================ Delete ====================
@router.delete("/delete/{{{entity_name}}_id}", status_code=status.HTTP_200_OK)
async def delete_suppliers(
suppliers_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""Delete suppliers by ID - requires authentication"""
if not current_user:
raise HTTPException(status_code=401, detail="Authentication required")
if current_user.tipo_usuario not in ["root", "admin"]:
raise HTTPException(status_code=403, detail="You don't have permission to delete suppliers")
try:
result = SuppliersService.delete_suppliers(db=db, suppliers_id=suppliers_id, current_user=current_user)
return {"message": "suppliers deleted successfully"}
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))