You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.7 KiB
1.7 KiB
通用列表查询方法
请求参数:
{
"method":"xxx/xxx/list",
"params":{
"page":1,
"limit":10,
"field":[
"id","name"
],
"and":{
"id":["1","2"],
"name":["name1","name2"]
},
"or":{
"id":["1","2"],
"name":["name1","name2"]
},
"like":{
"id":["1","2"],
"name":["name1","name2"]
},
"orderby":[
{"id":"asc"},
{"name":"desc"},
{"created_at":"desc"}
],
"where":[{
"field":"job_id",
"operator":"=",
"value":"2"
},{
"field":"departments",
"operator":"find_in_set",
"value":[1,2]
},]
}
}
参数说明:
- page: 分页记录,默认不填为1,page不能小于1(小于1的数均会改写成1)
- limit: 每页显示的记录数,默认不填为10,当limit小于0时 会返回所有数据记录
- field: 自定义需要查询的字段,不填默认返回所有记录
- and: 与运算条件。示例中会生成如下sql查询语句: select ..... where id in(1,2) and name in ("name1","name2")
- or: 或运算条件。示例中会生成如下sql查询语句: select ..... where id in(1,2) or name in ("name1","name2")
- like: 模糊查询条件。
- orderby: 排序 根据数组顺序区分 首序、次序
- where: 自定义where条件 传入condition对象 的数组
- condition.field 指定字段
- condition.operator 操作符 例:= != > >= < <= in notin 等 特殊操作符: find_in_set:一对多关联查询 例如:
{
"field": "departments",
"operator": "find_in_set",
"value": [1]
}
- condition.value 值
成功返回参数:
{
"result":{
"count":100,
"rows":[
{},{},{}
]
}
}
参数说明:
- count: 总记录数
- rows: 查询出的记录数组