【问题标题】:Return only some fields of an entity from restServices in MOQUI FrameWork?MOQUI框架中的restServices只返回实体的一些字段?
【发布时间】:2016-04-23 21:01:49
【问题描述】:

我已经使用 Moqui 框架实现了一个应用程序。 我有 10 个参数的实体。 通过 RestService,使用实体的短别名,我可以获得 JSON 格式的 10 个参数。 但是我只需要显示 4 个参数。 这是我的实际结果:

    "exampleId": "100000",
    "exampleTypeEnumId": "EXT_MADE_UP",
    "description": "Yet another test description",
    "exampleEmail": "example1@test.com",
    "statusId": "EXST_IN_DESIGN",
    "exampleName": "Test Example from JSON File",
    "exampleSize": 123,
    "testTime": "1970-01-01T06:30:00+0000",
    "amount": 200.0,
    "exampleItemSeqId": "02",

这是我想要的结果:

    "description": "Yet another test description",
    "exampleName": "Test Example from JSON File",
    "amount": 200.0,
    "exampleItemSeqId": "02",

【问题讨论】:

    标签: java jakarta-ee moqui


    【解决方案1】:

    通过 Moqui REST API 功能获取有限实体字段的方法有以下三种:

    1. 将自动实体 REST API (/rest/e1) 与视图实体一起使用,该视图实体仅为您想要的字段设置别名
    2. 在服务 REST API XML 文件(通过 /rest/s1 访问)中的 method.entity 元素中使用具有有限字段别名的视图实体
    3. 仅使用所需字段定义服务,并在服务 REST API XML 文件(通过 /rest/s1 访问)的 method.service 元素中使用它

    【讨论】:

    • 感谢您的宝贵建议。我已经实施了第二个选项,它工作正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 1970-01-01
    相关资源
    最近更新 更多