mybatis-plus QueryWrapper LambdaQueryWrapper

ContractTemplate::getTemplateCode 转为对应的字段

LambdaQueryWrapper objectLambdaQueryWrapper = Wrappers.lambdaQuery();
        objectLambdaQueryWrapper.eq(searchDto.getTemplateCode() != null, ContractTemplate::getTemplateCode, searchDto.getTemplateCode());

        IPage page = page(MybatisPlusUtil.setPageParams(pageNo, pageSize), objectLambdaQueryWrapper);
      return page

QueryWrapper

QueryWrapper queryWrapper = Wrappers.query();
        queryWrapper.eq(searchDto.getTemplateCode() != null, TemplateConst.COL_TEMPLATE_CODE, searchDto.getTemplateCode())
                .ge(searchDto.getStartDate() != null, TemplateConst.COL_CREATE_TIME, searchDto.getStartDate())
                .lt(searchDto.getEndDate() != null, TemplateConst.COL_CREATE_TIME, DateUtils.addDays(searchDto.getEndDate(), 1))
                .eq(searchDto.getContractCategoryId() != null, TemplateConst.COL_CATEGORY_ID, searchDto.getContractCategoryId())
                .and(i -> i.like(TemplateConst.COL_TEMPLATE_NAME, searchDto.getKeyword()).or().like(TemplateConst.COL_DESCRIPTION, searchDto.getKeyword()))
                .eq(searchDto.getIs_enabled() != null, TemplateConst.COL_IS_ENABLED, searchDto.getIs_enabled())
                // 未标志删除的数据
                .eq(CommonConst.DBColName.DEL_FLAG, CommonConst.IsEnabled.ENABLED.getCode())
                .orderByDesc(TemplateConst.COL_CREATE_TIME)
                ;
        IPage page = page(MybatisPlusUtil.setPageParams(pageNo, pageSize), queryWrapper);
        return MybatisPlusUtil.parsePageDTO(page);

你可能感兴趣的:(java)