Spring Boot Mybatis plus中国人开发的,直接参考官方文档
扫描路径
mybatis多条件查询 @Override public JsonResult getList(BaseQuery query) { if (query == null) { return JsonResult.error("参数错误!"); } if (StringUtils.isEmpty(query.getHospitalNumber())) { return JsonResult.error("没找到医院信息"); } HisOrderMasterQuery hisOrderMasterQuery = (HisOrderMasterQuery) query; // 查询条件 QueryWrapper<HisOrderMaster> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("mark", 1); queryWrapper.eq("hospital_number", query.getHospitalNumber()); if (StringUtils.isNotNull(query.getKeyword())) { queryWrapper.and(wrapper -> wrapper.like("keyword", query.getKeyword()) .or().like("address_detail", query.getKeyword()) .or().like("vis_name", query.getKeyword()) } queryWrapper.orderByDesc("id"); // 获取数据列表 IPage<HisOrderMaster> page = new Page<>(hisOrderMasterQuery.getPage(), hisOrderMasterQuery.getLimit()); IPage<HisOrderMaster> pageData = hisOrderMasterMapper.selectPage(page, queryWrapper); pageData.convert(x -> { HisOrderMasterListVo hisOrderMasterListVo = Convert.convert(HisOrderMasterListVo.class, x); return hisOrderMasterListVo; }); return JsonResult.success(pageData); } 控制台打印sql语句如下: SELECT * FROM SRM_MDM_SUPPLIER_ALL WHERE mark= 1 AND hospital_number = '03426' AND (keyword LIKE '%1183%' OR address_detail LIKE '%1183%' OR vis_name LIKE '%1183%') ORDER BY id DESC