1. LambdaQueryWrapper 和 Wrappers.lambdaQuery (推荐使用) 条件查询
List<ProductInfoEntity> productInfoList = productInfoMapper.selectList(new LambdaQueryWrapper<ProductInfoEntity>()
.eq(ProductInfoEntity::getId, id)
.eq(ProductInfoEntity::getState, 1));
//官方推荐使用这个
List<ProductInfoEntity> productInfoList = this.baseMapper.selectList(Wrappers.lambdaQuery(ProductInfoEntity.class)
.eq(true, ProductInfoEntity::getId, id))
.eq(ProductInfoEntity::getState, 1));
2. LambdaQueryChainWrapper 链式条件查询
List<ProductInfoEntity> productInfoList = new LambdaQueryChainWrapper<>(productInfoMapper)
.eq(ProductInfoEntity::getId, id)
.eq(ProductInfoEntity::getState, 1)
.list();
3. LambdaUpdateWrapper 和 Wrappers.lambdaUpdate (推荐使用) 条件更新
productInfoMapper.update(null, new LambdaUpdateWrapper<ProductInfoEntity>()
.set(ProductInfoEntity::getProductName,"哈哈哈哈哈")
.eq(ProductInfoEntity::getId, id));
//官方推荐使用这个
this.baseMapper.update(null,Wrappers.lambdaUpdate(ProductInfoEntity.class)
.set(ProductInfoEntity::getProductName,"哈哈哈哈哈")
.eq(ProductInfoEntity::getId, id));
4.lambdaUpdateChainWrapper 链式条件更新
new LambdaUpdateChainWrapper<>(productInfoMapper)
.set(ProductInfoEntity::getProductName,"哈哈哈哈哈")
.eq(ProductInfoEntity::getId, id)
.update();