feig调用jpa没有构造函数解决方式

  • feign调用jpa分页对象,返回值会报错,Page没有构造函数

解决
实现类-map
serviceimpl实现类,查询出Page,转换成Map,传输
new IG().trans(sysDept,current, size);

feign
feign调用,数据转成
new IG().trans(map);

1、自己定义了工具类

/**
 * 转换分页
 */
@Data
public class IG<T> {

  /**
   * 分页转换成Map-传输-feign
   *
   * @param t page对象
   * @param current 当前页
   * @param size 当页条数
   */
  public Map trans(org.springframework.data.domain.Page<T> t, int current, int size) {
    Map map = new HashMap<>();
    map.put("current", current);
    map.put("size", size);
    map.put("total", t.getTotalPages());
    map.put("records", t.getContent());
    return map;
  }
  /**
   * 转换成page分页
   */
  public IGQ<T> trans(Map map) {
    /*页大小*/
    Integer size = (Integer) map.get("size");
    /*总条数*/
    Integer total = (Integer) map.get("total");
    /*当前页*/
    Integer current = (Integer) map.get("current");
    /*页面数据*/
    List<T> records = (List<T>) map.get("records");
    return new IGQ<>(records, total, size, current);
  }
}

@Data
public class IGQ<T> {

  private List<T> records;
  private Integer total = 0;
  private Integer size = 10;
  private Integer current;
  private boolean isSearchCount = true;

  public IGQ(List<T> records, Integer total, Integer size, Integer current) {
    this.records = records;
    this.total = total;
    this.size = size;
    this.current = current;
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值