类似于search_count功能,很遗憾目前并未提供专用的接口用于查数量,不过你可以巧妙利用搜索接口实现你想要的功能。
1. 与数据搜索一样,根据你设置的条件查总数量。返回结果中recordsTotal的值为查询的总条数。
2. 参数调整:除了指定的搜索条件外,设置以下参数可以提高接口查询性能(可选)。
设置start = 0,length = 1,这样就会只查一条数据,减少不必要的数据返回。
设置raw = true,查原始数据,关联对象属性值不填充,加快查询速度。
{
"body": {
"start": 0,
"length": 20,
"sorts": [
{
"property": "code", // 排序字段apiName
"direction": "DESC", // 排序方式,DESC或ASC
"scope": "VALUE" // 排序字段的作用域,目前仅支持VALUE
}
],
"templateApiName": "template_lwyhT",
"filter": {
"field_RCoX9__c": 100,
"field_ICxU8__c": "abc" // 如果多条件精确匹配,该字段可以传数组,例如:["abc","edg","xyz"]
},
"condition": {
"columnType": "VALUE", // 列类型
"dataApiName": "object_SRvLd__c", // 实体ApiName
"fieldApiName": "field_RCoX9__c", // 实体字段ApiName
"dataType": "NUM", // 字段类型
"keyword": "EQ", // 关键字
"params": [
100
], // 条件值
},
"fields": [
"code",
"field_RCoX9__c",
"field_ICxU8__c"
],
"dataIds": [
"6391c806b463873cf8f068cb",
"6391bab134ca192519668f4a"
],
"fuzzy": false, // 是否模糊匹配,默认false
"raw": false, // 是否查原始数据,默认false
"print": false, // 是否以打印格式返回,默认false
"authority": {
"enabled": true, // 是否启用权限条件,默认为true
"returnType": "EXCEPTION" // 无权限时返回类型,默认为抛出异常,也可用EMPTY返回空集合
},
"conditionalFilter": { // ConditionBO过滤条件
"filter": { // 表单字段过滤条件
"template_lwyhT": {
"field_RCoX9__c": 100
}
},
"conditionDefinition": {
"nodes": [
{
"dataSourceType": "VARIABLE",
"leftFieldTemplateId": 41535,
"leftFieldTemplateName": "一一",
"leftFieldTemplateApiName": "template_xrQj9",
"leftFieldId": 284529,
"leftFieldApiName": "field_bYXeY__c",
"leftFieldName": "日期",
"conditionType": "EQ",
"rightShowInfo": "今日",
"rightConstant": "TODAY",
"leftParentheses": "(",
"rightParentheses": ")"
},
{
"dataSourceType": "CONSTANT",
"leftFieldTemplateId": 41535,
"leftFieldTemplateName": "一一",
"leftFieldTemplateApiName": "template_xrQj9",
"leftFieldId": 284530,
"leftFieldApiName": "field_Nf6D9__c",
"leftFieldName": "单选",
"conditionType": "IS_NOT_NULL",
"rightShowInfo": "",
"leftParentheses": "(",
"rightParentheses": ")"
}
],
"logics": [
"OR",
"OR"
],
"joinTable": { // 连表查询参数,非必须
"joinTemplateApiName": "template_sApnS",
"joinTemplateFieldApiName": "field_zxACW__c"
}
},
"fuzzy": false // 是否模糊匹配,默认false
},
"workflow": { // 流程参数,目前给Web端用,查看指定TAB数据
"tab": "ALL",
"staffId": 10040412
},
"parent": {
"templateApiName": "template_JHEHl", // 父表单ApiName
"parentIds": [
"6391b560c5b14224b45be375"
] // 父数据ID
},
"join": {
"joinTables": { // 连表信息
"template_Z6F5g": { // 表单ApiName
"filter": { // 过滤条件
"code": "00000001",
},
"fields": [
"code",
"field_xxxx"
], // 查询字段,可为空,默认查所有字段
"sorts": [ // 排序,可为空,为空按照子表id降序排列
{
"property": "code", // 排序字段apiName
"direction": "DESC", // 排序方式,DESC或ASC
"scope": "VALUE" // 排序字段的作用域,目前仅支持VALUE
}
]
},
"template_O70cG": {
"filter": {
"code": [
"00000001",
"00000002"
]
},
"fields": []
},
},
"flat": false, // 数据是否平铺,默认不平铺
},
"associate": { // 关联列表查询参数
"templateApiName": "template_JHEHl", // 表单ApiName
"dataIds": [
"00000000000"
] // 数据id
},
"defaultSort": {
"enabled": false, // 是否开启,默认关闭。
"view": "ALL" // 视图名称,与工作流参数tab一致
}
}
}
curl --location --request POST '/api/public/metadata-app/v2/data/query/search' \
--header 'Cookie;' \
--header 'Content-Type: application/json' \
--data-raw '{
"body": {
"start": 0,
"length": 20,
"sorts": [
{
"property": "code", // 排序字段apiName
"direction": "DESC", // 排序方式,DESC或ASC
"scope": "VALUE" // 排序字段的作用域,目前仅支持VALUE
}
],
"templateApiName": "template_lwyhT",
"filter": {
"field_RCoX9__c": 100,
"field_ICxU8__c": "abc" // 如果多条件精确匹配,该字段可以传数组,例如:["abc","edg","xyz"]
},
"condition": {
"columnType": "VALUE", // 列类型
"dataApiName": "object_SRvLd__c", // 实体ApiName
"fieldApiName": "field_RCoX9__c", // 实体字段ApiName
"dataType": "NUM", // 字段类型
"keyword": "EQ", // 关键字
"params": [
100
], // 条件值
},
"fields": [
"code",
"field_RCoX9__c",
"field_ICxU8__c"
],
"dataIds": [
"6391c806b463873cf8f068cb",
"6391bab134ca192519668f4a"
],
"fuzzy": false, // 是否模糊匹配,默认false
"raw": false, // 是否查原始数据,默认false
"print": false, // 是否以打印格式返回,默认false
"authority": {
"enabled": true, // 是否启用权限条件,默认为true
"returnType": "EXCEPTION" // 无权限时返回类型,默认为抛出异常,也可用EMPTY返回空集合
},
"conditionalFilter": { // ConditionBO过滤条件
"filter": { // 表单字段过滤条件
"template_lwyhT": {
"field_RCoX9__c": 100
}
},
"conditionDefinition": {
"nodes": [
{
"dataSourceType": "VARIABLE",
"leftFieldTemplateId": 41535,
"leftFieldTemplateName": "一一",
"leftFieldTemplateApiName": "template_xrQj9",
"leftFieldId": 284529,
"leftFieldApiName": "field_bYXeY__c",
"leftFieldName": "日期",
"conditionType": "EQ",
"rightShowInfo": "今日",
"rightConstant": "TODAY",
"leftParentheses": "(",
"rightParentheses": ")"
},
{
"dataSourceType": "CONSTANT",
"leftFieldTemplateId": 41535,
"leftFieldTemplateName": "一一",
"leftFieldTemplateApiName": "template_xrQj9",
"leftFieldId": 284530,
"leftFieldApiName": "field_Nf6D9__c",
"leftFieldName": "单选",
"conditionType": "IS_NOT_NULL",
"rightShowInfo": "",
"leftParentheses": "(",
"rightParentheses": ")"
}
],
"logics": [
"OR",
"OR"
],
"joinTable": { // 连表查询参数,非必须
"joinTemplateApiName": "template_sApnS",
"joinTemplateFieldApiName": "field_zxACW__c"
}
},
"fuzzy": false // 是否模糊匹配,默认false
},
"workflow": { // 流程参数,目前给Web端用,查看指定TAB数据
"tab": "ALL",
"staffId": 10040412
},
"parent": {
"templateApiName": "template_JHEHl", // 父表单ApiName
"parentIds": [
"6391b560c5b14224b45be375"
] // 父数据ID
},
"join": {
"joinTables": { // 连表信息
"template_Z6F5g": { // 表单ApiName
"filter": { // 过滤条件
"code": "00000001",
},
"fields": [
"code",
"field_xxxx"
], // 查询字段,可为空,默认查所有字段
"sorts": [ // 排序,可为空,为空按照子表id降序排列
{
"property": "code", // 排序字段apiName
"direction": "DESC", // 排序方式,DESC或ASC
"scope": "VALUE" // 排序字段的作用域,目前仅支持VALUE
}
]
},
"template_O70cG": {
"filter": {
"code": [
"00000001",
"00000002"
]
},
"fields": []
},
},
"flat": false, // 数据是否平铺,默认不平铺
},
"associate": { // 关联列表查询参数
"templateApiName": "template_JHEHl", // 表单ApiName
"dataIds": [
"00000000000"
] // 数据id
},
"defaultSort": {
"enabled": false, // 是否开启,默认关闭。
"view": "ALL" // 视图名称,与工作流参数tab一致
}
}
}'
{
"code": 0,
"message": "",
"data": {
"list": [
{
"": {}
}
],
"start": 0,
"length": 0,
"recordsTotal": 0
}
}