# 组织管理

> 模块标识：organization  |  接口数量：7

## 1. 获取组织列表
**方法**：	GET

**路径**：				/api/organizations

**功能说明**：
获取组织列表，支持树形结构

### 请求参数
```json
{
  "query": [
    {
      "name": "pageNum",
      "type": "number",
      "required": false,
      "description": "页码，默认1"
    },
    {
      "name": "pageSize",
      "type": "number",
      "required": false,
      "description": "每页数量，默认10"
    },
    {
      "name": "name",
      "type": "string",
      "required": false,
      "description": "组织名称关键词"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "list": [
        {
          "id": 1,
          "code": "ORG0001",
          "name": "总部",
          "parentId": null,
          "status": 1,
          "createTime": "2025-01-01T10:00:00.000Z"
        }
      ],
      "total": 100,
      "pageNum": 1,
      "pageSize": 10
    }
  }
}
```


## 2. 获取组织详情
**方法**：	GET

**路径**：				/api/organizations/{id}

**功能说明**：
根据组织ID获取组织详细信息

### 请求参数
```json
{
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "组织ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "id": 1,
      "code": "ORG0001",
      "name": "总部",
      "parentId": null,
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4040",
    "message": "组织不存在",
    "data": null
  }
}
```


## 3. 创建组织
**方法**：	POST

**路径**：				/api/organizations

**功能说明**：
创建新的组织

### 请求参数
```json
{
  "body": {
    "name": "string｜必填，组织名称",
    "parentId": "string｜可选，父级组织ID，根节点为空",
    "status": "number｜可选，状态：1-启用，0-禁用"
  }
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "创建组织成功",
    "data": {
      "id": 1,
      "code": "ORG0001",
      "name": "总部",
      "parentId": null,
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4000",
    "message": "创建组织失败",
    "data": null
  }
}
```


## 4. 更新组织
**方法**：	PUT

**路径**：				/api/organizations/{id}

**功能说明**：
更新指定组织的信息

### 请求参数
```json
{
  "body": {
    "name": "string｜必填，组织名称",
    "parentId": "string｜可选，父级组织ID，根节点为空",
    "status": "number｜可选，状态：1-启用，0-禁用"
  },
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "组织ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "更新组织成功",
    "data": {
      "id": 1,
      "code": "ORG0001",
      "name": "总部",
      "parentId": null,
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4000",
    "message": "更新组织失败",
    "data": null
  }
}
```


## 5. 删除组织
**方法**：	DELETE

**路径**：				/api/organizations/{id}

**功能说明**：
删除指定的组织

### 请求参数
```json
{
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "组织ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "删除组织成功",
    "data": {
      "result": true
    }
  },
  "failure": {
    "code": "4000",
    "message": "删除组织失败",
    "data": null
  }
}
```


## 6. 获取组织关联用户
**方法**：	GET

**路径**：				/api/organizations/{id}/users

**功能说明**：
获取指定组织关联的用户

### 请求参数
```json
{
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "组织ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "获取成功",
    "data": {
      "id": 1,
      "code": "ORG0001",
      "name": "总部",
      "parentId": null,
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4040",
    "message": "组织不存在",
    "data": null
  }
}
```


## 7. 更新组织用户关联
**方法**：	PUT

**路径**：				/api/organizations/{id}/users

**功能说明**：
更新指定组织的用户关联关系

### 请求参数
```json
{
  "body": {
    "name": "string｜必填，组织名称",
    "parentId": "string｜可选，父级组织ID，根节点为空",
    "status": "number｜可选，状态：1-启用，0-禁用"
  },
  "path": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "组织ID"
    }
  ]
}
```

### 响应示例
```json
{
  "success": {
    "code": "0000",
    "message": "更新组织成功",
    "data": {
      "id": 1,
      "code": "ORG0001",
      "name": "总部",
      "parentId": null,
      "status": 1,
      "createTime": "2025-01-01T10:00:00.000Z"
    }
  },
  "failure": {
    "code": "4000",
    "message": "更新组织失败",
    "data": null
  }
}
```

