from fastapi import APIRouter
from api.v1.common.tenant_crud_routes import TenantCRUDRoutes
from .dto import (
    IdentifierCreate, IdentifierResponse, IdentifierUpdate,
    IdentifierDetailCreate, IdentifierDetailResponse, IdentifierDetailUpdate
)
from .service import IdentifierService, IdentifierDetailService

router = APIRouter(prefix="/identifiers",
                   tags=["a76.general_catalogs.identifiers"])

# Identifier CRUD
identifier_crud = TenantCRUDRoutes(
    create_schema=IdentifierCreate,
    update_schema=IdentifierUpdate,
    response_schema=IdentifierResponse,
    service=IdentifierService,
    prefix="",
    tags=["Identifiers"],
    resource_name="Identifier",
    enable_list=True,
    enable_filters=True,
    list_permissions=["cat_identifiers.view"],
    get_permissions=["cat_identifiers.view"],
    create_permissions=["cat_identifiers.create"],
    update_permissions=["cat_identifiers.edit"],
    delete_permissions=["cat_identifiers.delete"],
)

# Identifier Detail CRUD
detail_crud = TenantCRUDRoutes(
    create_schema=IdentifierDetailCreate,
    update_schema=IdentifierDetailUpdate,
    response_schema=IdentifierDetailResponse,
    service=IdentifierDetailService,
    prefix="/details",
    tags=["Identifier Details"],
    resource_name="Identifier Detail",
    list_permissions=["cat_identifiers.view"],
    get_permissions=["cat_identifiers.view"],
    create_permissions=["cat_identifiers.create"],
    update_permissions=["cat_identifiers.edit"],
    delete_permissions=["cat_identifiers.delete"],
)

router.include_router(identifier_crud.router)
router.include_router(detail_crud.router)
