SpringCloud Feign Get请求传对象参数_zhuyu19911016520-CSDN博客_feign get请求传对象

沙海 2021年4月27日11:45:50Java评论35字数 1284阅读4分16秒阅读模式
摘要

SpringCloud Feign Get请求传对象参数

文章源自JAVA秀-https://www.javaxiu.com/20980.html

SpringCloud Feign Get请求传对象参数

文章源自JAVA秀-https://www.javaxiu.com/20980.html

SpringCloud Feign Get请求传对象参数_zhuyu19911016520-CSDN博客_feign get请求传对象文章源自JAVA秀-https://www.javaxiu.com/20980.html

闪耀的瞬间
2020-06-22 15:15:43
SpringCloud Feign Get请求传对象参数_zhuyu19911016520-CSDN博客_feign get请求传对象
1876

SpringCloud Feign Get请求传对象参数_zhuyu19911016520-CSDN博客_feign get请求传对象文章源自JAVA秀-https://www.javaxiu.com/20980.html

收藏

2

文章源自JAVA秀-https://www.javaxiu.com/20980.html

分类专栏:
SpringCloud实战
SpringBoot 项目开发
文章标签:
springcloud 文章源自JAVA秀-https://www.javaxiu.com/20980.html

版权 文章源自JAVA秀-https://www.javaxiu.com/20980.html

文章源自JAVA秀-https://www.javaxiu.com/20980.html

前置说明,有A、B两个服务,A服务调用B服务,B服务接口是Get类型,接受参数对象文章源自JAVA秀-https://www.javaxiu.com/20980.html

feign get请求传对象参数分两种情况文章源自JAVA秀-https://www.javaxiu.com/20980.html

  • 1.版本在2.1之前,如我springboot是2.0.6.RELEASE,springcloud是Finchley.SR2版本,则A服务使用Map map替代对象传给B服务
//A-service
@ApiOperation(value = "查询xx", httpMethod = "GET")
@GetMapping("/maps")
public ReturnEntity getOrgPositionInMap(OrganizationMapQO organizationMapQO) {
    HashMap map = new HashMap(BeanMap.create(organizationMapQO));
    ReturnEntity returnEntity =  sysLoginFeignClient.getOrgPositionInMap(map);
    return returnEntity;
}
//feign-service
@ResponseBody
@GetMapping(value = "/organizations/maps", consumes = MediaType.APPLICATION_PROBLEM_JSON_UTF8_VALUE, produces = "application/json")
ReturnEntity getOrgPositionInMap(@RequestParam Map map);

//B-service
@ApiOperation(value = "查询xx",  httpMethod = "GET")
@GetMapping("/maps")
public List<OrganizationMapVO> getOrgPositionInMap(OrganizationMapQO organizationMapQO) {
    return sysDeptService.getOrgPositionInMap(organizationMapQO);
}
12345678910111213141516171819
  • 2.版本在2.1之后,在feign-service中使用@SpringQueryMap
//feign-service
@ResponseBody
@GetMapping(value = "/organizations/maps", consumes = MediaType.APPLICATION_PROBLEM_JSON_UTF8_VALUE, produces = "application/json")
ReturnEntity getOrgPositionInMap(@SpringQueryMap OrganizationMapQO organizationMapQO);
1234
文章源自JAVA秀-https://www.javaxiu.com/20980.html

文章源自JAVA秀-https://www.javaxiu.com/20980.html

文章源自JAVA秀-https://www.javaxiu.com/20980.html

继续阅读
速蛙云 - 极致体验,强烈推荐!!!购买套餐就免费送各大视频网站会员!快速稳定、独家福利社、流媒体稳定解锁!速度快,全球上网、视频、游戏加速、独立IP均支持!基础套餐性价比很高!这里不多说,我一直正在使用,推荐购买:https://www.javaxiu.com/59919.html
weinxin
资源分享QQ群
本站是JAVA秀团队的技术分享社区, 会经常分享资源和教程; 分享的时代, 请别再沉默!
沙海
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定