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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Dynamic Programming

Dynamic Programming

Richard Bellman / Dover Publications / 2003-03-04 / USD 19.95

An introduction to the mathematical theory of multistage decision processes, this text takes a "functional equation" approach to the discovery of optimum policies. The text examines existence and uniq......一起来看看 《Dynamic Programming》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具