富查询功能是平台提供给开发者,用于将查询内容做进一步延伸的功能。API请求参数中有如图所示字段,表示该接口支持富查询功能。

以查询用户列表接口为例,未添加富查询字段时,请求参数为GET /account-manage/v1/user
响应参数:
{
"total": 2,
"results": [{
"verification": {
"identityVerified": false,
"cellphoneVerified": false,
"emailVerified": false
},
"changePw": false,
"companies": [
"5e1d63c608584a0038******",
"5e1c1e659238d50038******"
],
"aclGroups": [
"rc:hub:aclgroup:16f8******",
"rc:hub:aclgroup:59f3******",
"rc:hub:aclgroup:25e7******",
"rc:hub:aclgroup:262b******"
],
"departments": [
"5e65e84d08704a0038******",
"5e65e885a3a822003e******",
"5e65e89108704a0038******",
"5e65e89da3a822003e******",
"5ebd211bf746c3003f******"
],
"roles": [],
"username": "admin_chen",
"cellphone": "183148*****",
"createdAt": "2020-01-14T06:46:31.088Z",
"updatedAt": "2020-07-27T09:55:19.684Z",
"metadata": {
"userDetails": {
"pictureUrl": "/static/images/avatar/user.png",
"sex": "M",
"birthday": "2020/03/10",
"detailAddress": ""
}
},
"updatedBy": "1",
"mainCompany": "5e1d63c608584a0038******",
"displayName": "Ceshi@12******",
"id": "5e1d63c708584a00385******"
},
{
"verification": {
"identityVerified": false,
"cellphoneVerified": false,
"emailVerified": false
},
"changePw": true,
"companies": ["5e1d63c608584a0038******"],
"aclGroups": [],
"departments": [
"5e65e84d08704a0038******",
"5e65e885a3a822003e******",
"5e65e89108704a0038******",
"5e65e89da3a822003e******"
],
"roles": [],
"displayName": "王树根",
"metadata": {
"userDetails": {
"pictureUrl": ""
},
"createdClient": "web_app",
"createdCompany": "5e1d63c608584a00385******"
},
"email": "******@rootcloud.com",
"username": "rc_15958436******",
"mainCompany": "5e1d63c608584a003******",
"createdBy": "5e1d63c708584a0038******",
"createdAt": "2020-07-27T09:54:15.832Z",
"updatedAt": "2020-07-28T06:58:56.643Z",
"updatedBy": "5e1d63c708584a003******",
"id": "4b4******"
}]
}查出用户列表中总共有2个用户,并列举了每个用户的详细信息。若需要查询其中一个机构下的用户列表,可以将需要查询的机构ID作为富查询字段进行查找,机构对应的字段为departments,请求参数为GET /account-manage/v1/user?filter={"where":{"departments":"5e65e84d08704a00******"}},此时可以查出该机构下共有1个用户,并列举了用户的详细信息。
响应参数:
{
"total": 1,
"results": [{
"verification": {
"identityVerified": false,
"cellphoneVerified": false,
"emailVerified": false
},
"changePw": false,
"companies": [
"5e1d63c608584a003******",
"5e1c1e659238d5003******"
],
"aclGroups": [
"rc:hub:aclgroup:16f8******",
"rc:hub:aclgroup:59f******",
"rc:hub:aclgroup:25e******",
"rc:hub:aclgroup:262******"
],
"departments": [
"5e65e84d08704a003******",
"5e65e885a3a822003******",
"5e65e89108704a003******",
"5e65e89da3a822003******",
"5ebd211bf746c3003******"
],
"roles": [],
"username": "admin_chen",
"cellphone": "183148******",
"createdAt": "2020-01-14T06:46:31.088Z",
"updatedAt": "2020-07-27T09:55:19.684Z",
"metadata": {
"userDetails": {
"pictureUrl": "/static/images/avatar/user.png",
"sex": "M",
"birthday": "2020/03/10",
"detailAddress": ""
}
},
"updatedBy": "1",
"mainCompany": "5e1d63c608584a******",
"displayName": "Ceshi@1******",
"id": "5e1d63c708584a003******"
}]
}富查询支持MongoDB的全部查询语法,具体请参见Query文档。下表中列举了部分常用的MongoDB查询语法,以如下用户数据为例:
{ _id: "001", roles: [ "a", "b" ] }
{ _id: "002", roles: [ "a", "c" ] }
{ _id: "003, roles: [ "a", "d" ] }
{ _id: "004", roles: [ "c", "b" ] }
{ _id: "005", roles: [ "e", "b" ] }
{ _id: "066", roles: [ "n", "m" ] }
{ _id: "666", roles: [ "n", "m" ] }
{ _id: "", roles: [ "n", "m" ] }同时,富查询也支持语法嵌套使用,例如,查询不在任何机构或归属某个机构的用户时,可以添加富查询语句:
{
"where": {
"departments" {
"$or": [{
"$size": 0
},
{
"$elemMatch": {
"$eq": "xxxxxxx"
}
}]
}
}
}