跳转至

设计时校验库管理(ValidatesController)

校验库(ValidateRepository)的设计时管理:列表查询、详情获取、新建、更新与批量删除;用于在表单字段上配置可复用的校验规则库。

  • 接口类型:REST 资源
  • 基址${myapps.context-path.designer:}/api/designtime/applications(类级 @RequestMappingproduces = APPLICATION_JSON_VALUE
  • Tag:检验库模块

公共说明

  • 鉴权:是(需 designerToken)。控制器继承自 AbstractDesignTimeController(基类为 @RestController),通过 Security.getDesignerIdFromToken(request) 从 designerToken JWT 中解析设计器用户。鉴权机制详见 index.md「鉴权说明」。
  • 路径变量{applicationId}{validId} 均为**明文设计时 ID**。
  • 响应:统一 Resource(见 ../index.md「统一响应结构」)。成功 errcode=0;保存时抛 OBPMValidateException(库名称重复)返回 errcode=40001;其他异常 errcode=500
  • HTTP 方法:受 CommonSecurityFilter 限制,仅允许 GET/POST/HEAD/OPTIONS
  • 请求体约定:POST/PUT 接收原始 JSON 字符串(@RequestBody String content),由服务端用 JSONObject.fromObject 解析后通过 json2objValidateRepositoryVO;DELETE 接收 JSON 字符串数组(@RequestBody String[])。
  • 隶属关系:新建时 applicationidparentId 均固定设为 applicationId(校验库直接挂在应用下,无模块层)。

1. 获取校验库列表

分页获取指定应用下的校验库列表,可按名称查询。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/validates(完整:{designer-context}/api/designtime/applications/{applicationId}/validates
  • 鉴权:是(需 designerToken)
  • Tag:检验库模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id
name query string 按名称查询关键字
pageNo query string 页码(缺省 1
linesPerPage query string 每页条数(缺省 10

说明:name/pageNo/linesPerPage 形参未标注 @RequestParam,由 Spring MVC 按请求参数绑定,故均可缺省。

请求示例

GET /api/designtime/applications/{applicationId}/validates?name=&pageNo=1&linesPerPage=10 HTTP/1.1

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataDataPackage<ValidateRepositoryVO>(含分页字段与 datas)。

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "linesPerPage": 10,
    "pageNo": 1,
    "pageCount": 1,
    "rowCount": 1,
    "datas": [
      { "id": "...", "name": "校验库名", "description": "...", "content": "...", "...": "..." }
    ]
  },
  "errors": null
}
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


2. 获取校验库详情

按校验库Id获取完整校验库对象。

注:源码 @Operation(summary) 文案误写为「获取样式库详情」,实际功能为校验库详情。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/validates/{validId}
  • 鉴权:是(需 designerToken)
  • Tag:检验库模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id
validId path string 校验库Id

响应

dataValidateRepositoryVO 完整对象。

{ "errcode": 0, "errmsg": "ok", "data": { "id": "...", "name": "...", "content": "...", "description": "...", "...": "..." }, "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


3. 新建校验库

在指定应用下新建校验库。请求体解析为 ValidateRepositoryVO 后强制覆盖 applicationidparentId(均设为 applicationId),id 为空时生成新的设计时序列号;保存前做库名唯一性校验。HTTP 状态码 201

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/{applicationId}/validates
  • 鉴权:是(需 designerToken)
  • Tag:检验库模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id
content body string(JSON) 校验库对象 JSON

请求体

对应 ValidateRepositoryVO 对象 JSON(namecontentdescription 等)。

{ "name": "<校验库名>", "content": "<校验脚本/规则>", "description": "..." }

响应

dataJSONObject,仅含 id(新建校验库Id)。

{ "errcode": 0, "errmsg": "ok", "data": { "id": "<校验库Id>" }, "errors": null }
失败示例(库名重复):
{ "errcode": 40001, "errmsg": " 库名称重复 ,请重新命名再保存! ", "data": null, "errors": null }
失败示例(其他异常):
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


4. 更新校验库

按校验库Id更新校验库对象。先按 validId 查出原对象并克隆,再用请求体中的 content/name/description 覆盖(其余字段保留原值),强制清空 uri 后保存。HTTP 状态码 200

  • 接口类型:REST 资源
  • 请求方式PUT
  • 请求路径/{applicationId}/validates/{validId}
  • 鉴权:是(需 designerToken)
  • Tag:检验库模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id
validId path string 校验库Id(用于查找原对象)
content body string(JSON) 校验库对象 JSON(取 content/name/description

请求体

对应 ValidateRepositoryVO 对象 JSON(仅 content/name/description 会被采用)。

{ "name": "<校验库名>", "content": "<校验脚本/规则>", "description": "..." }

响应

datanull(成功)。

{ "errcode": 0, "errmsg": "ok", "data": null, "errors": null }
失败示例(库名重复):
{ "errcode": 40001, "errmsg": " 库名称重复 ,请重新命名再保存! ", "data": null, "errors": null }
失败示例(其他异常):
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


5. 删除校验库(可批量)

按校验库Id数组批量删除校验库(删除前收集各校验库的路径信息)。

  • 接口类型:REST 资源
  • 请求方式DELETE
  • 请求路径/{applicationId}/validates
  • 鉴权:是(需 designerToken)
  • Tag:检验库模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id
ids body string 校验库Id字符串数组

请求体

["<validId1>", "<validId2>"]

响应

dataString,固定为 "删除成功"

{ "errcode": 0, "errmsg": "ok", "data": "删除成功", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }