"""组织树接口。"""

from __future__ import annotations

from flask import request

from dms.api.v1.blueprint import api_v1
from dms.common.response import success_response
from dms.security.decorators import admin_required, bearer_auth_required
from dms.services.organization_service import organization_tree


@api_v1.get("/organizations/tree")
@bearer_auth_required
@admin_required
def organizations_tree():
    return success_response(
        organization_tree(
            keyword=request.args.get("keyword"),
            status=request.args.get("status"),
        )
    )
