{ "type": "object", "properties": { "conditions": { "type": "object", "properties": { "children": { "type": "array", "items": { "$ref": "#/properties/conditions" }, "title": "子条件", "description": "子条件节点,递归结构" }, "exprs": { "type": "array", "items": { "type": "object", "properties": { "column": { "type": "string", "title": "字段编码" }, "columnResource": { "type": "string", "title": "所属资源", "description": "字段所属资源标识,取值为顶层 resource 或 relations[].code" }, "columnSqlFunc": { "type": "string", "title": "列SQL函数", "description": "对列应用 SQL 函数后再参与比较,拼接为 {func}({columnResource}.{column}) {operator} {value}。\r\n支持 SQL-92 / SQL:1999 / SQL:2003 标准函数及数据库方言函数,如 DATE、UPPER、ROUND。\r\n需要第二参数的函数(如 ROUND、CAST)配合 columnSqlFuncParam 使用。" }, "columnSqlFuncParam": { "type": "string", "title": "列SQL函数参数", "description": "columnSqlFunc 的附加参数,按函数类型用途不同:\r\r通用函数(有 param 时):{func}({columnResource}.{column}, {columnSqlFuncParam}) {operator} {value}\r 示例:ROUND(col, 2) → columnSqlFuncParam=\"2\"\r SUBSTRING(col, 1, 10) → columnSqlFuncParam=\"1, 10\"\r\rJSON 函数(param 为 JSON 路径表达式):\r json_member_of(value 是否是列 JSON 数组的成员):\r 无 param:JSON_CONTAINS({value}, JSON_ARRAY({column}))\r 有 param:JSON_CONTAINS({columnSqlFuncParam}, JSON_ARRAY({column}))\r json_contains(列 JSON 是否包含 value):\r 无 param:JSON_CONTAINS({column}, JSON_ARRAY({value}))\r 有 param:JSON_CONTAINS({columnSqlFuncParam}, JSON_ARRAY({value}))" }, "ignoreEmptyParam": { "type": "boolean", "title": "忽略空参数", "description": "当 valueType=param 且请求参数值为空(空字符串或 null)时,跳过该条件不生成 SQL。用于实现可选过滤项", "default": false }, "operator": { "type": "string", "title": "运算符", "description": "标准 SQL 比较运算符:\r\n= / != / \u003e / \u003e= / \u003c / \u003c=\r\nLIKE:模糊匹配(%keyword%)\r\nIN:包含,value 逗号分隔多值\r\nIS NULL / IS NOT NULL:空值判断,无需 value\r\nREGEXP:正则匹配", "default": "=" }, "value": { "type": "string", "title": "比较值", "description": "比较目标,内容由 valueType 决定。operator 为 IS NULL/IS NOT NULL 时可省略" }, "valueType": { "type": "string", "title": "比较值类型", "description": "先选类型再填 value:\r\nstring:value 填字面量如 '2024-01-01'\r\nfunc:value 填内置函数名 UserID|UserUuid|UserRolesUuid|UserPlatform|UserSaaS\r\nparam:value 填请求参数路径如 body.status\r\nsql:value 填原始SQL如 CURRENT_DATE", "default": "string", "enum": [ "string", "func" ] } }, "title": "_items", "description": "_items", "required": [ "column", "operator" ] }, "title": "条件表达式列表", "description": "当前层的叶子比较列表,每项生成一个 column {operator} value 片段,同层多项以 type 连接" }, "type": { "type": "string", "title": "逻辑连接符", "description": "当前节点的逻辑运算符,将 exprs 各项与 children 各组以 AND 或 OR 连接", "default": "and", "enum": [ "and", "or" ] } }, "title": "树形查询条件", "description": "WHERE 条件树。\rexprs 每项生成一段比较:[{columnSqlFunc}(]{columnResource}.{column}[)] {operator} {value},同层多项以 type(and/or) 连接;\rchildren 为同结构子节点,递归嵌套实现复杂过滤。", "required": [ "exprs", "type" ] }, "fields": { "type": "array", "items": { "oneOf": [ { "type": "string", "title": "字段编码", "description": "字段引用,格式:{columnResource}.{column} 或 {column}" }, { "type": "object", "properties": { "alias": { "type": "string", "title": "别名" }, "expr": { "type": "string", "title": "SQL 表达式", "description": "SQL 表达式:如 COUNT(*) / SUM(amount)\r{column}:字段编码,默认归属顶层 resource\r{columnResource}.{column}:显式指定资源的字段引用" } }, "title": "表达式字段" }, { "type": "object", "properties": { "alias": { "type": "string", "title": "别名" }, "column": { "type": "string", "title": "字段编码" }, "columnResource": { "type": "string", "title": "所属资源", "description": "字段所属资源标识,取值为顶层 resource 或 relations[].code" } }, "title": "资源字段", "required": [ "column" ] } ] }, "title": "查询字段", "description": "查询字段,不传则返回所有字段" }, "groupBy": { "type": "array", "items": { "oneOf": [ { "type": "string", "title": "分组表达式", "description": "SQL 表达式:如 COUNT(*) / SUM(amount)\r{column}:字段编码,默认归属顶层 resource\r{columnResource}.{column}:显式指定资源的字段引用" }, { "type": "object", "properties": { "column": { "type": "string", "title": "字段编码" }, "columnResource": { "type": "string", "title": "所属资源", "description": "字段所属资源标识,取值为顶层 resource 或 relations[].code" } }, "title": "资源字段", "required": [ "column" ] } ] }, "title": "分组规则", "description": "GROUP BY 字段列表,配合 fields 中的聚合字段使用" }, "limit": { "type": "integer", "title": "每页条数", "description": "返回的最大记录数", "default": 30 }, "offset": { "type": "integer", "title": "偏移量", "description": "跳过的记录数", "default": 0 }, "orderBy": { "type": "array", "items": { "oneOf": [ { "type": "string", "title": "SQL 表达式 (ASC)", "description": "SQL 表达式:如 COUNT(*) / SUM(amount)\r{column}:字段编码,默认归属顶层 resource\r{columnResource}.{column}:显式指定资源的字段引用\r默认升序(asc)" }, { "type": "object", "properties": { "direction": { "type": "string", "title": "排序方向", "default": "asc", "enum": [ "asc", "desc" ] }, "expr": { "type": "string", "title": "SQL 表达式", "description": "SQL 表达式:如 COUNT(*) / SUM(amount)\r{column}:字段编码,默认归属顶层 resource\r{columnResource}.{column}:显式指定资源的字段引用" } }, "title": "SQL 表达式排序" }, { "type": "object", "properties": { "column": { "type": "string", "title": "字段编码" }, "columnResource": { "type": "string", "title": "所属资源" }, "direction": { "type": "string", "title": "排序方向", "default": "asc", "enum": [ "asc", "desc" ] } }, "title": "资源字段排序", "required": [ "column", "columnResource" ] } ] }, "title": "排序规则", "description": "排序规则列表,多项按顺序依次应用" }, "relations": { "type": "array", "items": { "type": "object", "properties": { "actuallyField": { "type": "string", "title": "实际资源字段", "description": "目标资源(code)参与 ON 条件的字段" }, "actuallyResource": { "type": "string", "title": "实际资源", "description": "被关联的目标资源编码(相当于 SQL 表名)。JOIN 拼接为:{type} JOIN {actuallyResource} AS {code} ON {code}.{actuallyField} = {relationResource}.{relationField}" }, "code": { "type": "string", "title": "关联标识", "description": "关联唯一标识,同时作为别名:JOIN 时为表别名(AS code),子查询时为结果 JSON 字段的键名" }, "conditions": { "$ref": "#/properties/conditions" }, "groupBy": { "$ref": "#/properties/groupBy" }, "limit": { "$ref": "#/properties/limit" }, "name": { "type": "string", "title": "关联名称", "description": "关联的显示名称" }, "orderBy": { "$ref": "#/properties/orderBy" }, "relationField": { "type": "string", "title": "被关联资源字段", "description": "ON 条件对端资源的字段" }, "relationResource": { "type": "string", "title": "被关联资源", "description": "ON 条件对端的资源编码(通常为主资源或父关联资源)" }, "type": { "type": "string", "title": "关联类型", "description": "关联模式:\r\ninner / left / right:SQL JOIN,将关联资源字段合并到主查询行\r\nhasOne:子查询,关联结果聚合为单个对象(result[code] = {})\r\nhasMany:子查询,关联结果聚合为对象数组(result[code] = [...])", "enum": [ "inner", "left", "right", "hasOne", "hasMany" ] } }, "required": [ "actuallyField", "actuallyResource", "code", "relationField", "relationResource", "type" ] }, "title": "资源关联", "description": "关联配置列表,支持 JOIN(inner / left / right)将关联字段合并到主查询,或子查询(hasOne / hasMany)将关联数据聚合为独立 JSON 字段" } } }