List<TVehcertUploadLog> list = tVehcertUploadLogService.list(new LambdaQueryWrapper<TVehcertUploadLog>().eq(StringUtils.isNotBlank(tVehcertUploadLog.getVin()),TVehcertUploadLog::getVin,tVehcertUploadLog.getVin()) .eq(StringUtils.isNotBlank(tVehcertUploadLog.getVehWzhgzbh()),TVehcertUploadLog::getVehWzhgzbh,tVehcertUploadLog.getVehWzhgzbh()) .like(StringUtils.isNotBlank(tVehcertUploadLog.getBz()),TVehcertUploadLog::getBz,tVehcertUploadLog.getBz()) .eq(StringUtils.isNotBlank(tVehcertUploadLog.getIsValid()),TVehcertUploadLog::getIsValid,tVehcertUploadLog.getIsValid()) .eq(StringUtils.isNotBlank(tVehcertUploadLog.getIsSample()),TVehcertUploadLog::getIsSample,tVehcertUploadLog.getIsSample()) .eq(StringUtils.isNotBlank(tVehcertUploadLog.getCreateBy()),TVehcertUploadLog::getCreateBy,tVehcertUploadLog.getCreateBy()) .ge(tVehcertUploadLog.getParams().containsKey("startTime")&&StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("startTime").toString()), TVehcertUploadLog::getUpDate,tVehcertUploadLog.getParams().containsKey("startTime")&&StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("startTime").toString())?sdf.parse(tVehcertUploadLog.getParams().get("startTime").toString()):"") .le(tVehcertUploadLog.getParams().containsKey("endTime")&&StringUtils.isNotEmpty(tVehcertUploadLog .getParams().get("endTime").toString()),TVehcertUploadLog::getUpDate,tVehcertUploadLog.getParams().containsKey("endTime")&&StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("endTime").toString())?sdfs.parse(tVehcertUploadLog.getParams().get("endTime").toString()+" 23:59:59"):"") );如何再加一个联表查询
时间: 2023-12-14 11:40:19 浏览: 112
要实现联表查询,可以使用`leftJoin`或`innerJoin`等方法来连接关联的表,然后在查询条件中使用关联表的字段。示例代码如下:
```
List<TVehcertUploadLog> list = tVehcertUploadLogService.list(new LambdaQueryWrapper<TVehcertUploadLog>()
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getVin()), TVehcertUploadLog::getVin, tVehcertUploadLog.getVin())
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getVehWzhgzbh()), TVehcertUploadLog::getVehWzhgzbh, tVehcertUploadLog.getVehWzhgzbh())
.like(StringUtils.isNotBlank(tVehcertUploadLog.getBz()), TVehcertUploadLog::getBz, tVehcertUploadLog.getBz())
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getIsValid()), TVehcertUploadLog::getIsValid, tVehcertUploadLog.getIsValid())
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getIsSample()), TVehcertUploadLog::getIsSample, tVehcertUploadLog.getIsSample())
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getCreateBy()), TVehcertUploadLog::getCreateBy, tVehcertUploadLog.getCreateBy())
.ge(tVehcertUploadLog.getParams().containsKey("startTime") && StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("startTime").toString()), TVehcertUploadLog::getUpDate, tVehcertUploadLog.getParams().containsKey("startTime") && StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("startTime").toString()) ? sdf.parse(tVehcertUploadLog.getParams().get("startTime").toString()) : "")
.le(tVehcertUploadLog.getParams().containsKey("endTime") && StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("endTime").toString()), TVehcertUploadLog::getUpDate, tVehcertUploadLog.getParams().containsKey("endTime") && StringUtils.isNotEmpty(tVehcertUploadLog.getParams().get("endTime").toString()) ? sdfs.parse(tVehcertUploadLog.getParams().get("endTime").toString() + " 23:59:59") : "")
.leftJoin(TVehcert.class, TVehcert::getVehId, TVehcertUploadLog::getVehId)
.eq(StringUtils.isNotBlank(tVehcertUploadLog.getVehXh()), TVehcert::getVehXh, tVehcertUploadLog.getVehXh())
);
```
上述代码中,使用了`leftJoin`方法将`TVehcertUploadLog`表与`TVehcert`表关联,关联条件是`TVehcertUploadLog`表的`vehId`字段与`TVehcert`表的`vehId`字段相等。然后在查询条件中使用了`TVehcert`表的`vehXh`字段进行查询。
阅读全文