代码之家  ›  专栏  ›  技术社区  ›  opensas

如何在REST中传递复杂的查询?

  •  6
  • opensas  · 技术社区  · 17 年前

    <xml>
      <service>account</service>
      <resource>invoice</resource>
      <action>query</action>
      <parameters>
        <page>1</page>
        <page_len>10</page_len>
        <order>date</order>
        <fields>*</fields>
        <conditions>
          <date>2009-01-01..2009-01-31</date>
          <customer_id>24</customer_id>
        </conditions>
      </parameters>
    </xml>
    

    http://account/invoice/?_page=1&_page_len=10&_order=date&_fields=*&date=2009-01-01..2009-01-31&customer_id=24
    

    [...]
        <_order>date</_order>
        <_fields>*</_fields>
        <date>2009-01-01..2009-01-31</date>
        <customer_id>24</customer_id>
    [...]
    

    2 回复  |  直到 14 年前
        1
  •  6
  •   Jasiu    17 年前

    <conditions>
      <date>2009-01-01..2009-01-31</date>
      <customer_id>24</customer_id>
    </conditions>
    

    GET /customers/24/invoices?start_date=2009-01-01&end_date=2009-01-31
    

    想想你的资源之间的关系。假设我们有一个与Foo相关的资源类型Bar,通过一对多关系。在这种情况下,你可以这样问这种关系: GET /foo/123/bar

        2
  •  0
  •   James Black    17 年前