实体类如何实现模糊查询?

Java 未结 1 2135
hnmas
hnmas 剑者 2020-01-31 17:14

目前翻页查询方法默认是这样:

IPage<RegClient> pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(client));
return R.data(RegClientWrapper.build().pageVO(pages));

但Condition.getQueryWrapper 这种方法查询都是等于查询,不能实现模糊匹配,如何实现?

我在 desk下面找到这样的例子,可以自动模糊匹配,但当notice没有映射实体类字段,当notice中的字段名和数据库不对应时,后台生成的数据库字段会出错(默认驼峰转下划线,如果字段没用下划线,生成的字段名就出错了)

public R<IPage<NoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
  IPage<Notice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
  return R.data(NoticeWrapper.build().pageVO(pages));
}

我想在第一种情况实现对实体类的模糊匹配,如何实现?

1条回答
提交回复