public void main(String[] args) {
        //修改方法
        String unitId = "1";
        //将UnitCompanyCategory表下UnitId值为1对应的unitCategoryId字段数据改为1
        String categoryId = "1";
        LambdaUpdateWrapper<UnitCompanyCategory> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.set(UnitCompanyCategory::getUnitCategoryId, categoryId);
        lambdaUpdateWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
        this.update(lambdaUpdateWrapper);

        //以下为查和删除方法
        //根据unitId查询一个对象,有多个会报错
        LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
		UnitCompanyCategory unitCompanyCategory = this.getOne(lambdaQueryWrapper);

        //查询UnitCompanyCategory表下unitId为1的数据返回List
        LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
        List<UnitCompanyCategory> list = this.list(lambdaQueryWrapper);

        //删除UnitCompanyCategory表下企业unitId为1的数据
        LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
        baseMapper.delete(lambdaQueryWrapper);
    }
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐