FastQuery 1.0.46 发布,支持构建极简的 RESTful

栏目: 软件资讯 · 发布时间: 7年前

内容简介:FastQuery 1.0.46 发布,更新如下: FastQuery支持JAX-RS注解,不需实现类,便能构建极简的RESTful.不得不简单的设计,可见一斑. @Path("userInfo") public interface UserInfoDBService extends QueryReposito...

FastQuery 1.0.46 发布,更新如下:

FastQuery支持JAX-RS注解,不需实现类,便能构建极简的RESTful.不得不简单的设计,可见一斑.

@Path("userInfo")
public interface UserInfoDBService extends QueryRepository {

      // 查询并实现分页
	@Path("findAll")
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Query(value = "select id,name,age from `userinfo` where 1", countField = "id")
	Page<Map<String, Object>> findAll(@QueryParam("pageIndex") @PageIndex int pageIndex,
			                          @QueryParam("pageSize")  @PageSize  int pageSize);
   
}

没错, 不用去写任何实现类, 访问http://<your host>/rest/userInfo/findAll?pageIndex=1&pageSize=5, 就可以看到效果。

DB接口不仅能当做WEB Service,同时也是一个DB接口。

当然,如果不喜欢太简单,可以把DB接口注入到JAX-RS Resource类中:

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;

@Path("hi")
public class Hi {

	@Inject
	private UserInfoDBService db;
	
	@GET
	@Produces({"text/html"})
	public String hi() {
	      // use db...
	      return "hi";
	}
}

详细文档请参阅: 


【声明】文章转载自:开源中国社区 [http://www.oschina.net]


以上所述就是小编给大家介绍的《FastQuery 1.0.46 发布,支持构建极简的 RESTful》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Linux Command Line

The Linux Command Line

William E. Shotts Jr. / No Starch Press, Incorporated / 2012-1-17 / USD 39.95

You've experienced the shiny, point-and-click surface of your Linux computer-now dive below and explore its depths with the power of the command line. The Linux Command Line takes you from your very ......一起来看看 《The Linux Command Line》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试