使用LambdaQueryWrapper实现查询
- objectUtils.isNotEmpty为null时不执行apply语句
- 第一个date_format(你的数据库时间字段,’%Y-%m-%d’)
- 第二个date_format(你的实体类获取到的时间,’%Y-%m-%d’)
List<SysOperation> list=sysOperationService.list(new LambdaQueryWrapper<SysOperation>()
.apply(ObjectUtils.isNotEmpty(startTime), "date_format (operation_time,'%Y-%m-%d') >= date_format('" + startTime + "','%Y-%m-%d')")
.apply(ObjectUtils.isNotEmpty(startTime),"date_format (create_time,'%Y-%m-%d') <= date_format('" + endTime + "','%Y-%m-%d')"));