0

我打算使用谷歌云终端为我的Android应用程序,以便查询数据库传达给后端不同的标准get操作。由于谷歌云端点实现了REST,因此它可以映射获取,更新,删除和插入的唯一性。所以,它只允许每个操作的一种方法。实际上,应用程序需要多种获取方式。例如,getByLocation和getByRadius。他们都是获得操作,但他们需要不同的搜索条件。换句话说,我需要一种方式来从应用程序中用不同的标准查询数据库。我怎样才能实现这个?如何实现与谷歌云终端

感谢

回答

0

的典型方法是在你的请求使用的参数,如

/user?location=Boston&radius=10&sortBy=distance 
0

在谷歌云端点您不局限于基本的REST方法:

You are certainly not limited to those basic actions. Adding custom methods gives you much more flexibility, allowing you to perform complex operations. For example, checkForVictory might perform several queries, plus a write, to a database. https://cloud.google.com/solutions/mobile/google-cloud-endpoints-for-android/

你可以有你的方法,如如下:

... 
@ApiMethod(name = "getByLocation") 
public SomeThing getByLocation(@Named("location" String location){ 
    //retrieve from datastore (use Objectify!) 
    return someThing; 
} 

@ApiMethod(name = "getByRadius") 
public SomeThing getByRadius(@Named("radius" String radius){ 
    //retrieve from datastore (use Objectify!) 
    return someThing; 
} 
+0

但我得到 “多种方法与其他相同路径 ”GET网站/ {}“: ”getSite“ 和 ”getByLocation“” –

+0

你所写的正是这种:@ApiMethod(NAME = “getByLocation”)? – yurin

+0

是的。错误消息是错误:任务':backend:appengineEndpointsGetClientLibs'的执行失败。 >有运行端点命令是错误的获取客户端-lib目录下:siteApi.com.example.myapplication.backend.SiteEndpoint:用同样的休息路径“GET网站/ {}”多种方法:“getByLocation”和“getSite” –