更新时间:2024-08-19 GMT+08:00
分享

Select

功能介绍

指定需要的属性及查询条件,返回指定属性的结果集。

入参

POST http://{Endpoint}/rdm_{appID}_app/services/dynamic/api/{entityName}/select/pageSize/curPage
{
    "params": {
        "selectedField": [
            {
                "name": "属性名称",
                "nameAs": "属性别名"
            }

        ],
        "sorts": [
            {
                "sort": "DESC",
                "orderBy": "属性名称"
            }

        ],
        "filter": {
            "joiner": "and",
            "conditions": [
                {
                    "conditionName": "属性名称",
                    "operator": "=",
                    "conditionValues": [
                        "属性值"
                    ]
                }
            ]
        }
    }
}
  • {Endpoint}表示数据建模引擎所在域名或IP地址,{appID}表示应用ID,{entityName}表示实体的英文名称。
  • 在URL上填写待查询的页码(curPage)和每页可显示的数据量(pageSize)。
  • 在JSON代码中的设置sorts字段、filter字段和SelectedField字段。
    • sorts:填写需要按哪个字段进行排序,可填写模型自身属性、参考对象的属性、扩展属性及分类属性,也可为空。
    • filter:填写过滤条件,可为空。
    • SelectedField:填写需要输出的字段和别名。JSON参数格式为“参数名称.参数值”如果填写的字段为JSON类型,SelectedField的“name”参数需要填写为“JSON类型字段的英文名称.JSON参数的名称”例如,需要输出的JSON类型字段为“partJSON”存在一条数据[{"city":"shenzhen"}],SelectedField填写示例如下:
      "selectedField": [
            {
              "name": "partJSON.city",
              "nameAs": "partJSON"
            }
          ]

出参

指定属性的结果集。

示例1

示例场景

有一个数据实体(People),先按名称倒序排序,再按年龄倒序排序。而后根据性别为男性进行过滤,且“SelectedField”字段只选择输出名称和年龄,别名为“nameAsName”“nameAsAge”

入参示例

POST http://dme.cn-north-4.huaweicloud.com/rdm_01a2b2c4764d4e00f123g345fd9baa9f_app/services/dynamic/api/People/select/20/1
{
    "params": {
        "selectedField": [
            {
                "name": "name",
                "nameAs": "nameAsName"
            },
            {
                "name": "age",
                "nameAs": "nameAsAge"
            }
        ],
        "sorts": [
            {
                "sort": "DESC",
                "orderBy": "name"
            },
            {
                "sort": "DESC",
                "orderBy": "age"
            }
        ],
        "filter": {
            "joiner": "and",
            "conditions": [
                {
                    "conditionName": "gender",
                    "operator": "=",
                    "conditionValues": [
                        "男"
                    ]
                }
            ]
        }
    }
}

出参示例

{
    "result": "SUCCESS",
    "data": [
        {
            "nameAsAge": 20,
            "nameAsName": "李四"
        },
        {
            "nameAsAge": 18,
            "nameAsName": "张三"
        }
    ],
    "errors": [],
    "pageInfo": {
        "curPage": 1,
        "pageSize": 20,
        "totalRows": 0,
        "totalPages": 0
    }
}

示例2

示例场景

有一个数据实体(XxDMETest),该实体包含一个参考对象类型的属性(testDme)。而后根据testDme的ID,查询该属性ID的所有信息,并按ID倒序排序。

入参示例

POST https://dme.cn-north-4.huaweicloud.com/rdm_01a2b2c4764d4e00f123g345fd9baa9f_app/services/dynamic/api/XxDMETest/select/20/1
{
    "params": {
        "selectedField": [
            {
                "name" : "testDme"
            }
        ],
        "orderBy": "id",
        "sort": "DESC",
        "isNeedTotal": true,
        "filter": {
            "conditions": [
                {
                    "conditionName": "id",
                    "operator": "=",
                    "conditionValues": [
                        "507612209518485504"
                    ]
                }
            ],
            "joiner": "and"
        }
    }
}

出参示例

{
    "result": "SUCCESS",
    "data": [
        {
            "testDme": {
                "id": "111",
                "creator": "XDM_Developer 93172bbfd0f64437956d4c9de1234567",
                "modifier": "XDM_Developer 93172bbfd0f64437956d4c9de1234567",
                "createTime": "2023-06-06T07:32:59.629+0000",
                "lastUpdateTime": "2023-06-06T07:32:59.629+0000",
                "rdmVersion": 1,
                "rdmDeleteFlag": 0,
                "rdmExtensionType": "XxxDME",
                "tenant": {
                    "id": "-1",
                    "creator": "xdmAdmin",
                    "modifier": "xdmAdmin",
                    "createTime": "2023-02-08T06:38:48.567+0000",
                    "lastUpdateTime": "2023-02-08T06:38:48.567+0000",
                    "rdmVersion": 1,
                    "rdmDeleteFlag": 0,
                    "rdmExtensionType": "Tenant",
                    "tenant": null,
                    "className": "Tenant",
                    "name": "basicTenant",
                    "description": "默认租户",
                    "kiaguid": null,
                    "securityLevel": "internal",
                    "code": "basicTenant",
                    "disableFlag": false,
                    "dataSource": "DefaultDataSource"
                },
                "className": "XxxDME"
            }
        }
    ],
    "errors": [],
    "pageInfo": {
        "curPage": 1,
        "pageSize": 20,
        "totalRows": 1,
        "totalPages": 1
    }
}

相关文档