This commit is contained in:
Redkale
2017-03-17 16:07:41 +08:00
parent 14274c8d04
commit 3439fab690
2 changed files with 12 additions and 5 deletions

View File

@@ -76,9 +76,9 @@ public class HelloService implements Service {
return source.find(HelloEntity.class, id);
}
//查询单个
@RestMapping(name = "findone")
public HelloEntity findOneHello(AsyncHandler handler, @RestParam(name = "#") int id) { //通过 /pipes/hello/find/1234、/pipes/hello/jsfind/1234 查询对象
//异步查询单个
@RestMapping(name = "asyncfind")
public HelloEntity findHello(AsyncHandler handler, @RestParam(name = "#") int id) { //通过 /pipes/hello/find/1234、/pipes/hello/jsfind/1234 查询对象
if (source != null) source.find(handler, HelloEntity.class, id);
HelloEntity rs = new HelloEntity();
rs.setHelloname("Hello名称");

View File

@@ -38,8 +38,8 @@ public class _DynHelloRestServlet1 extends SimpleRestServlet {
//headers.put(Rest.REST_HEADER_RESOURCE_NAME, "my-res");
String url = "http://127.0.0.1:" + port + "/pipes/hello/update?entity={}&bean2={}";
System.out.println(Utility.postHttpContent(url, headers, null));
url = "http://127.0.0.1:" + port + "/pipes/hello/findone/1234";
url = "http://127.0.0.1:" + port + "/pipes/hello/asyncfind/1234";
System.out.println(Utility.postHttpContent(url, headers, null));
}
@@ -125,4 +125,11 @@ public class _DynHelloRestServlet1 extends SimpleRestServlet {
resp.finishJson(bean);
}
@AuthIgnore
@WebMapping(url = "/hello/asyncfind/")
public void asyncfind(HttpRequest req, HttpResponse resp) throws IOException {
HelloService service = _servicemap == null ? _service : _servicemap.get(req.getHeader(Rest.REST_HEADER_RESOURCE_NAME, ""));
int id = Integer.parseInt(req.getRequstURILastPath());
service.findHello(resp.createAsyncHandler(), id);
}
}