工业数字模型驱动引擎-运算符相关示例:多字段排序

时间:2024-11-22 17:25:14

多字段排序

多字段排序一般使用“sorts”字段表示,其结构如下:

{
    "sorts": [
            {
                "sort": "DESC",
                "orderBy": "description"
            },
            {
                "sort": "ASC",
                "orderBy": "name"
            }
        ]
}

使用“sorts”字段后,将按照其列表顺序进行排序。如上所示,对象会先按照“description”进行倒序排序,再按照“name”进行正序排序。

“services/api/SZAPITEST202211280329/find/20/1”的URI为例,使用如下接口进行多字段排序。

  • Find接口:
    {
        "params": {
            "sorts": [
                {
                    "sort": "DESC",
                    "orderBy": "description"
                },
                {
                    "sort": "ASC",
                    "orderBy": "name"
                }
            ],
            "filter": {
                "joiner": "and",
                "conditions": [
                    {
                        "conditionName": "description",
                        "operator": "=",
                        "conditionValues": [
                            "a"
                        ]
                    },
                    {
                        "conditionName": "rdmDeleteFlag",
                        "operator": "=",
                        "conditionValues": [
                            "0"
                        ]
                    }
                ]
            }
        }
    }
  • Query接口:
    {
        "params": {
            "sorts": [
                {
                    "sort": "DESC",
                    "orderBy": "description"
                },
                {
                    "sort": "ASC",
                    "orderBy": "name"
                }
            ],
            "filter": {
                "joiner": "and",
                "conditions": [
                    {
                        "conditionName": "description",
                        "operator": "=",
                        "conditionValues": [
                            "a"
                        ]
                    },
                    {
                        "conditionName": "rdmDeleteFlag",
                        "operator": "=",
                        "conditionValues": [
                            "0"
                        ]
                    }
                ]
            }
        }
    }
  • Select接口:
    {
        "params": {
            "selectedField": [
                {
                    "name": "name",
                    "nameAs": "nameAsName"
                },
                {
                    "name": "description",
                    "nameAs": "nameAsDescription"
                },
                {
                    "name": "creator"
                },
                {
                    "name": "id"
                }
            ],
            "sorts": [
                {
                    "sort": "DESC",
                    "orderBy": "name"
                },
                {
                    "sort": "asc",
                    "orderBy": "id"
                }
            ],
            "filter": {
                "joiner": "and",
                "conditions": [
                    {
                        "conditionName": "description",
                        "operator": "=",
                        "conditionValues": [
                            "a"
                        ]
                    }
                ]
            }
        }
    }
support.huaweicloud.com/bestpractice-idme/idme_bestpractice_0024.html