Query Organization Tree
Endpoint Path
http
GET /api/open/organization/treeRequest Parameters
| Field | Type | Required | Description | Constraints | Example |
|---|---|---|---|---|---|
| enterprise_id | int | Yes | Enterprise ID | Query parameter; required | 1001 |
Request Example
json
GET 'https://neolink.com/backend/api/open/organization/tree?enterprise_id=1001'Return Information
| Field | Type | Required | Description | Remarks |
|---|---|---|---|---|
| success | bool | Yes | Request success indicator | Fixed value |
| message | string | Yes | Error message (empty if successful) | Fixed value |
| data | []TreeNode | Yes | Root nodes of organization tree | Tree structure; see table below |
TreeNode Object (Recursive Structure)
| Field | Type | Required | Description | Remarks |
|---|---|---|---|---|
| id | int | Yes | Organization ID | Department identifier |
| name | string | Yes | Organization name | Department display name |
| enterprise_id | int | Yes | Enterprise ID | Enterprise identifier |
| parent_id | int | Yes | Parent organization ID | 0=first-level department |
| level | int | Yes | Organization level | 1=first-level; 2=second-level, etc |
| path | string | Yes | ID path | Format: "/2001/2002/2003" |
| tree_path | string | Yes | Name path | Format: "/Headquarters/R&D/Backend" |
| is_leaf | bool | Yes | Is leaf node | true=no sub-departments |
| children | []TreeNode | No | Sub-organizations | Recursive; empty if leaf |
Response Example
json
{
"success": true,
"message": "",
"data": [
{
"id": 2001,
"name": "Headquarters",
"enterprise_id": 1001,
"parent_id": 0,
"level": 1,
"path": "/2001",
"tree_path": "/Headquarters",
"is_leaf": false,
"children": [
{
"id": 2002,
"name": "R&D",
"enterprise_id": 1001,
"parent_id": 2001,
"level": 2,
"path": "/2001/2002",
"tree_path": "/Headquarters/R&D",
"is_leaf": false,
"children": []
}
]
}
]
}Error responses:
json
{
"success": false,
"message": "Enterprise ID is empty"
}
{
"success": false,
"message": "Enterprise ID format error"
}
{
"success": false,
"message": "Insufficient permissions; only enterprise/department admins can view organization tree"
}
{
"success": false,
"message": "Enterprise is disabled; operation not allowed"
}