有一种场景,查询时必须满足条件1,同时必须满足条件2或条件3,即 a and b or a and c
表达式写法如下:
LambdaQueryWrapper<AttrValue>productAttrValueQueryWrapper1=new LambdaQueryWrapper<>();
productAttrValueQueryWrapper1.in(!CollectionUtils.isEmpty(spuIds),AttrValue::getSpuId, spuIds).and(qw->qw.in(AttrValue::getAttrName, functions).or().in(AttrValue::getAttrValue, functions));List<AttrValue> AttrValueList = productAttrValueMapper.selectList(productAttrValueQueryWrapper1);
以下写法是错误的,
LambdaQueryWrapper<AttrValue>productAttrValueQueryWrapper1=new LambdaQueryWrapper<>();
productAttrValueQueryWrapper1.in(AttrValue::getSpuId, spuIds);
productAttrValueQueryWrapper1.in(AttrValue::getAttrName, functions).or().in(AttrValue::getAttrValue, functions);
List<AttrValue> AttrValueList = productAttrValueMapper.selectList(productAttrValueQueryWrapper1);