springcloud中使用fegin调用,不同参数类型传参问题

1.单参数,基本数据类型的

    @GetMapping("/findInfoById")
    @ApiOperation(value = "根据id查询信息")
    public InfoDto getInfoDto(@ApiParam(name = "id", value = "ID") @RequestParam(value = "id") Long id);

2.多参数,基本数据类型

   @GetMapping("/getcount")
   public String getcount(
           @RequestParam("id") Long id,
          @RequestParam("type") Integer type);

3.多参数,基本数据类型+list

  @GetMapping("/getCountBySellers")
  public List<ProductCountDto> getCountBySellers(
          @RequestParam(value = "startTime", required = false) @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd HH:mm:ss") String startTime,
          @RequestParam(value = "endTime", required = false) @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd HH:mm:ss") String endTime,
          @RequestParam("ids") List<Long> ids,
          @RequestParam("sort")  Integer sort,
          @RequestParam("sellerId") Long sellerId);

4.自定义类型

 @PostMapping("/add")
   public int add(@RequestBody UserDto userDto)

5.自定义类型+基本数据类型

  @PostMapping("/add")
    public int add(@RequestBody UserDto userDto, @RequestParam("sellerId") Long sellerId);

注意:参数中不能使用一个以上的@RequestBody,传递多个自定义实体,使用@RequestBody DTO1 dto1+@RequestParam DTO2 dto2也是不行的,可将其中一个实体转成string类型尝试。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值