跳转至

角色(RoleController)

提供 KMS 知识管理模块「角色配置域」的能力:管理员配置 KMS 角色与用户的绑定关系。本控制器仅有 1 个端点,返回的是 ModelAndView(页面视图)而非 JSON 资源,供后台管理控制台渲染角色配置页。

据源码:源码中还存在 doSaveConfig/saveConfig.action)方法的注释块(约 40 行),但整段被 // 注释掉,未暴露为实际端点,故本控制器实际方法级端点数为 1。

  • 接口类型:页面视图(@RestController + 方法返回 ModelAndView;视图名 core/sysconfig/configureKmRole
  • 基址${myapps.context-path.kms:}/api/core/sysconfig(类级 @RequestMapping 仅声明单一前缀)
  • Tag:kms角色模块

公共说明

  • 鉴权(据源码 KmsMvcConfig + KmsSecurityFilterKmsMvcConfig 注册全局 Servlet 过滤器 KmsSecurityFilter(URL 模式 /*,context-path 为 / 时为 /kms/*)。本控制器路径 /api/core/sysconfig/** 不在 KmsSecurityFilter.isExcludeURI 的豁免名单内(豁免仅覆盖 /login.*/admin/domain.*/tray/service/authtimeservice/OfficeServer.*outsideshare/.*/preview、静态资源后缀、actuator/health 等)。过滤器调用 Security.getUserIdFromToken(request),取不到用户则返回 HTTP 401因此所有端点均需 accessToken,可通过以下任一方式传递(据 Security.getUserIdFromToken):query 参数 accessToken、query 参数 access_token(移动端)、请求头 accessToken、Cookie accessToken、请求头 Authorization: Bearer <token>。完整鉴权机制见 index.md「鉴权说明」。
  • 执行用户:控制器内 getParams()(继承自 AbstractBaseController,调用 ParamsTable.convertHTTP(request))将 HTTP 请求参数与 Cookie 转为 ParamsTable,从其中读取 domainIddepartmentIdsm_name_currpage 等。控制器内部不直接调用 getUser()
  • 响应类型:本控制器返回 ModelAndView,由 Spring 解析为视图 core/sysconfig/configureKmRole 渲染为 HTML 页面,非统一 Resource JSON
  • @RequestMapping("/configure.action") 不限定 HTTP 方法GET/POST 等均可访问(.action 后缀为历史 Struts 风格命名)。

1. 配置角色

渲染「KMS 角色配置」管理页:从 ParamsTable 读取 domainIddepartmentIdsm_name(名称/登录名模糊关键字)、_currpage(页码,缺省 "1")等参数,结合 Cookie FILELIST_PAGELINE(缺省 10)作为每页条数,查询角色集合、用户分页与部门列表,注入 model 后返回视图。

  • 接口类型:页面视图(返回 ModelAndView,视图名 core/sysconfig/configureKmRole
  • 请求方式@RequestMapping(不限定方法,GET/POST 均可;浏览器访问通常用 GET
  • 请求路径/configure.action(完整:{kms-context}/api/core/sysconfig/configure.action
  • 鉴权:是(需 accessToken,据源码)
  • Tag:kms角色模块

请求参数

参数经 ParamsTable.convertHTTP(request) 统一收集,既可经 query 也可经 form-body 传入;以下表格合并标注。

参数名 位置 类型 必填 说明
domainId query/form string 企业域Id(决定是否查询用户与部门列表)
departmentId query/form string 部门Id(缺省按空串处理)
sm_name query/form string 名称或登录名模糊关键字
_currpage query/form string 当前页码(缺省 "1"
FILELIST_PAGELINE Cookie string(int) 每页条数(缺省 10

注:方法会主动从 ParamsTable 中移除 _orderby1_orderby_pagelines 等历史参数;并将 _pagelines 重设为 Cookie 中读到的 FILELIST_PAGELINE 值。

请求示例

GET /api/core/sysconfig/configure.action?domainId=__DOMAINID__&departmentId=__DEPTID__&sm_name=张&_currpage=1&accessToken=__TOKEN__ HTTP/1.1
Cookie: FILELIST_PAGELINE=20; accessToken=__TOKEN__

响应

结构:HTML 页面(视图 core/sysconfig/configureKmRole),非 JSON Resource。Content-Type 由视图解析器决定(通常 text/html;charset=UTF-8)。

影响 model 的属性(据源码 modelAndView.addObject(...)

model 属性 类型 条件 说明
datas DataPackage<Role> 始终 全部角色集合(roleService.list()
departmentId String 始终 当前选中部门Id(空串安全)
sm_name String 始终 名称/登录名模糊关键字
usersDataPackage DataPackage<KmsUser> domainId != null 当前域+部门+关键字下的用户分页
departments List<Department> domainId != null 当前域下的部门列表
ERROR_MESSAGE String(国际化键) 异常分支 "{*[core.sysconfig.km.role.config.error]*}"(异常时视图名同为 core/sysconfig/configureKmRole

失败行为(异常分支):方法内 try/catch 捕获 Exception,打印堆栈后将视图名设为 core/sysconfig/configureKmRole、注入 model 属性 ERROR_MESSAGE = "{*[core.sysconfig.km.role.config.error]*}" 返回(HTTP 状态仍为 200,由 @RequestMapping 默认决定)。

注意:本端点为后台管理控制台页面入口,调用方需具有管理员权限;具体权限校验在视图层 / 服务层完成(不在 KmsSecurityFilter 层)。