跳转至

部门(DepartmentController)

按当前用户所属企业域获取部门集合,供前台组织维度展示与选择。

  • 接口类型:REST 资源(@Component + 类级 @RequestMapping(produces = APPLICATION_JSON_VALUE),继承自 @RestControllerAbstractRuntimeController,方法返回值由 Spring 以 JSON 序列化输出)
  • 基址${myapps.context-path.runtime:}/api/runtime/department
  • Tag:部门执行模块

公共说明

  • 鉴权(据源码 RuntimeMvcConfig + RestSecurityHandlerInterceptor:基址位于 /api/runtime/**不在豁免名单(豁免规则详见 login.md「公共说明 · 鉴权」)。拦截器走 Security.getUserIdFromToken(request),未取到再尝试 Security.getDebugUserIdFromToken(request),两者皆无则拒绝访问。所有端点均需 accessToken(或 debugToken),可通过 Cookie / 请求头 / query 参数任一方式传递。
  • 响应结构:统一 Resource(见 ../index.md「统一响应结构」)。
  • HTTP 状态码:端点类级标注 @ResponseStatus(HttpStatus.OK),成功统一返回 200。

1. 获取部门列表

根据当前用户所属企业域获取部门集合。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/list(完整:{runtime-context}/api/runtime/department/list
  • 鉴权:是(需 accessToken,据源码)
  • Tag:部门执行模块

请求参数

无(企业域 Id 从当前登录用户 getUser().getDomainid() 取得)。

请求示例

GET /api/runtime/department/list HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构:统一 ResourcedataCollection<DepartmentVO>,企业域下的部门对象集合。

{
  "errcode": 0,
  "errmsg": "ok",
  "data": [
    { "id": "...", "name": "研发部", "code": "RD", "level": 1 }
  ],
  "errors": null
}