使用QueryRecord
组件完成json数组内容的分页
select * from flowfile order by createDate desc limit ${pageSize} offset ${pageSize:multiply(${pageNo:minus(1)})}
pageSize和pageNo参数来自http请求,可以快速实时响应http请求的分页查询。
读取器设置schema
{
"type": "record",
"name": "diy",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "processId",
"type": "string"
},
{
"name": "processName",
"type": "string"
},
{
"name": "promoterName",
"type": "string"
},
{
"name": "moduleId",
"type": "string"
},
{
"name": "moduleName",
"type": "string"
},
{
"name": "nodeId",
"type": "string"
},
{
"name": "startTime",
"type": "string"
},
{
"name": "stayTime",
"type": "string"
},
{
"name": "isRead",
"type": "string"
},
{
"name": "processAppUrl",
"type": "string"
},
{
"name": "processWebUrl",
"type": "string"
},
{
"name": "type",
"type": "string"
},
{
"name": "status",
"type": "string"
},
{
"name": "securityKey",
"type": "string"
},
{
"name": "userId",
"type": "string"
},
{
"name": "userName",
"type": "string"
},
{
"name": "systemUserId",
"type": "string"
},
{
"name": "pictureUrl",
"type": "string"
},
{
"name": "createDate",
"type": "string"
}
]
}
设置器的schema
由于不过滤属性名,所以使用继承的
衍生出计算页数的语句:
"pages": ${merge.count:replaceEmpty(${executesql.row.count}):toDecimal():divide(${pageSize},4):math("ceil"):toNumber()}
MergeContent
组件在QueryRecord
组件之前,最后补充总页数和当前页码等信息:
,
"total": ${merge.count},
"size": 3,
"current": ${pageNo},
"searchCount": true,
"pages": ${merge.count:replaceEmpty(${executesql.row.count}):toDecimal():divide(${pageSize},4):math("ceil"):toNumber()}
}
}
网友评论