dangdangdotcom / dubbox

Dubbox now means Dubbo eXtensions, and it adds features like RESTful remoting, Kyro/FST serialization, etc to the Dubbo service framework.
http://dangdangdotcom.github.io/dubbox
Apache License 2.0
4.89k stars 2.06k forks source link

rest对接口泛型貌似有问题 #119

Open fnet123 opened 8 years ago

fnet123 commented 8 years ago

1 2 3

代码如下------------------------------------

业务接口: @Path("clientCommentService") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) public interface ClientCommentService extends CrudService<ClientComment, Integer> {

/**
 * 查询 通知信息接口
 * @param valueOf
 * @return
 */
@POST
@Path("showComment")
ClientComment showComment(@QueryParam("valueOf") Integer valueOf);

业务接口父类: @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public interface CrudService<T, ID> {

/**
 * 根据主键删除
 * @param sid
 * @return
 */
@POST
@Path("deleteByPrimaryKey")
int deleteByPrimaryKey(@QueryParam("sid") ID sid);

/**
 * 根据主键删除,返回删除的对象
 * @param sid
 * @return
 */
@POST
@Path("deleteByPrimaryKeyT")
T deleteByPrimaryKeyT(@QueryParam("sid") ID sid);

....

业务接口实现类: @Service(version = "1.0.0", protocol = {"dubbo", "rest"}) @org.springframework.stereotype.Service public class ClientCommentServiceImpl extends CrudServiceImpl<ClientComment, Integer> implements ClientCommentService {

@Autowired
private ClientCommentMapper clientCommentMapper;

protected ClientCommentMapper getClientCommentMapper() {
    return getCrudMapper();
}

@Override
public ClientComment showComment(Integer lessonId) {
    // TODO Auto-generated method stub
    return clientCommentMapper.showComment(lessonId);
}

}

fnet123 commented 8 years ago

补充: 通过在java代码中注入接口,使用”dubbo消费端调用dubbo服务端“,会产生以上问题。 但是通过http方式,使用"非dubbo的消费端调用dubbo的REST服务",是没有问题的。

li-shen commented 8 years ago

这个当然不行 你发出到客户端的接口的范型应该指定具体类