自学内容网 自学内容网

mybatis-plus LambdaQueryWrapper 使用

SQl 语句 

select
*
from
table p
where
p.is_deleted = 0
and (
    (p.product_release_time> "2024-11-13" AND p.product_release_time< "2024-11-15")
        or
            (p.product_release_time> "2024-11-17"AND p.product_release_time< "2024-11-18")
        or
            (p.product_release_time> "2024-11-20" AND p.product_release_time< "2024-11-12")
    )

 Java代码

LambdaQueryWrapper<ProductOperateFlow> queryWrapper = new LambdaQueryWrapper<>();   queryWrapper.eq(ProductOperateFlow::getIsDeleted,SystemConstants.IS_DELETED_FLAG_NORMAL);
queryWrapper.and(wrapper ->{
            wrapper.nested(w-> w
                    .ge(ProductOperateFlow::getProductReleaseTime, sevenDateAgo)
                    .lt(ProductOperateFlow::getProductReleaseTime, sevenDateAgo))
            .or()
            .nested(w->w
                    .ge(ProductOperateFlow::getProductReleaseTime, sevenDateAgo)
                    .lt(ProductOperateFlow::getProductReleaseTime, sevenDateAgo))
            .or()
            .nested(w->w
                    .ge(ProductOperateFlow::getProductReleaseTime, oneDateAfter)
                    .lt(ProductOperateFlow::getProductReleaseTime, oneDateAfter));
        });

QueryWrapper的方法 


原文地址:https://blog.csdn.net/oschina_39971480/article/details/144451170

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!