简体   繁体   English

Moqui 框架为 From 和 To 之间的“年龄”调用休息服务:

[英]Moqui Framework To Call Rest Service for "Age" between From And To:

I've implemented an application using Moqui Framework.I have a field named as "age" in entity.I am trying to get all record from entity where the age between 20 to 25. How to create rest service in order to get the given age between & How to specify the url for this requirement.我已经使用 Moqui 框架实现了一个应用程序。我在实体中有一个名为“年龄”的字段。我试图从年龄在 20 到 25 岁之间的实体中获取所有记录。如何创建休息服务以获得给定的年龄之间 & 如何指定此要求的 url。 This is the url:rest/s1/UserMargen/DetailsOfUser And i am getting as这是 url:rest/s1/UserMargen/DetailsOfUser 我得到

{
    "street": "Bridege",
    "age": 22,
    "city": "kol",
    "username": "Debendu",
    "lastUpdatedStamp": "2016-04-26T12:43:45+0000",
    "userid": "2000"
},
{
    "lastUpdatedStamp": "2016-04-26T12:42:42+0000",
    "userid": "2001",
    "street": "White",
    "username": "rolla",
    "city": "Ban",
    "age": 20
},
{
    "username": "Venkatesh",
    "street": "T-nager",
    "age": 28,
    "userid": "2005",
    "city": "chennai",
    "lastUpdatedStamp": "2016-04-26T12:48:33+0000"
} 

In rest.xml I have Defined as在 rest.xml 我已经定义为

<resource name="DetailsOfUser" >
    <method type="get"><entity name="UserInDetails" operation="list"/></method>
    <method type="post"><service name="UserMargen.UserMargenServices.create#userDetails"/></method>

    <id name="age">
        <method type="get"><entity name="UserInDetails" operation="list"/></method>
    </id></resource> 

If i give /rest/s1/UserMargen/DetailsOfUser/22 it will display which age equals 22. How to get records in between age from 20 to 25 ?如果我给 /rest/s1/UserMargen/DetailsOfUser/22 它将显示哪个年龄等于 22。如何获取 20 到 25 岁之间的记录?

In XML REST API definitions in Moqui Framework the method.entity element behaves the same as for the entity (/rest/e1) and entity master (/rest/m1) interfaces, which behave the same as the search form inputs (either in a XML Screen file or through the EntityFind interface).在 Moqui 框架中的 XML REST API 定义中,method.entity 元素的行为与实体 (/rest/e1) 和实体主 (/rest/m1) 接口的行为相同,它们的行为与搜索表单输入(在XML 屏幕文件或通过 EntityFind 接口)。 For search form inputs you can use the field name plus "_from" and "_thru" suffixes to do a ranged find on numeric or date/time fields.对于搜索表单输入,您可以使用字段名称加上“_from”和“_thru”后缀对数字或日期/时间字段进行范围查找。

If you want the age range values to be in the URL as path parameters you'll need to define an id element with the name age_from and another id element under it with the name age_thru.如果您希望年龄范围值作为路径参数在 URL 中,您需要定义一个名为 age_from 的 id 元素和另一个名为 age_thru 的 id 元素。 A more flexible approach would just be to pass them as URL parameters instead of path elements, ie something like:更灵活的方法是将它们作为 URL 参数而不是路径元素传递,例如:

/rest/s1/UserMargen/DetailsOfUser?age_from=20&age_thru=25

Using this pattern you can pass field values or any of the suffixes supported by EntityFind.searchFormInputs()/searchFormMap(): _op, _not, _ic, _period/_poffset, _from, and _thru.使用此模式,您可以传递字段值或 EntityFind.searchFormInputs()/searchFormMap() 支持的任何后缀:_op、_not、_ic、_period/_poffset、_from 和 _thru。 You can also pass an orderByField parameter which can be a comma-separated list of field names.您还可以传递一个 orderByField 参数,该参数可以是一个以逗号分隔的字段名称列表。 You can also pass pagination parameters like pageIndex, pageSize, or even pageNoLimit to not paginate.您还可以传递诸如 pageIndex、pageSize 甚至 pageNoLimit 之类的分页参数来不分页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM