QueryWrapper<StFloodcollR> queryWrapper = new QueryWrapper<>(); queryWrapper.select("*,(SELECT u1.real_name FROM `user` u1 WHERE CREATEDBY = u1.id ) AS createdUser,(SELECT u2.real_name FROM `user` u2 WHERE MODIFYBY = u2.id ) AS modifyUser"); PageHelper.startPage(pageNo, pageSize); if (!StringUtils.isEmpty(lunTime)) { queryWrapper.ge("LUNTIME", TimeUtil.getStartOfDay(lunTime)); queryWrapper.le("LUNTIME", TimeUtil.getEndOfDay(lunTime)); }
第一步:在StFloodcollR实体类中 加入两个
第二步:在查询语句中加入
queryWrapper.select("*,(SELECT u1.real_name FROM `user` u1 WHERE CREATEDBY = u1.id ) AS createdUser,(SELECT u2.real_name FROM `user` u2 WHERE MODIFYBY = u2.id ) AS modifyUser");