如何用LambdaWrapper去实现去重查询
·
如何用LambdaWrapper去实现去重查询
我们知道,LambdaWrapper比较好用,但是LambdaWrapper却不能实现select(String s)
,那只需要进行QueryWrapper与LambdaQueryWrapper的混合使用就可以了,所以巧妙转换很重要
@Override
public Integer getCountAbPressure(String customerId, LocalDateTime firstDay, LocalDateTime lastDay, List<String> list, Integer type) {
QueryWrapper<CustomerBodyMetricsEntity> wrapper = new QueryWrapper<>();
wrapper.select("DISTINCT version")
.lambda()
.eq(CustomerBodyMetricsEntity::getCustomerId, customerId)
.ge(CustomerBodyMetricsEntity::getVersion, DateTimeUtil.dateTimeToTimestamp(firstDay))
.le(CustomerBodyMetricsEntity::getVersion, DateTimeUtil.dateTimeToTimestamp(lastDay))
.in(CustomerBodyMetricsEntity::getMetric, list)
.ne(CustomerBodyMetricsEntity::getLabel, 20);
return this.count(wrapper);
}
QueryWrapper转换成LambdaWrapper,只需要lambda()
方法即可
更多推荐
已为社区贡献2条内容
所有评论(0)