/** * 封装查询条件 * * @param baseQueryDTO * @return */ private Specification<ActivityBase> getSpecification(ActivityBaseQueryDTO baseQueryDTO) { return new Specification<ActivityBase>() { @Override public Predicate toPredicate(Root<ActivityBase> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Predicate predicate = cb.conjunction(); if (StringUtils.isNotEmpty(baseQueryDTO.getQueryActivityName())) { predicate.getExpressions() .add(cb.like(root.get("activityName"), "%" + baseQueryDTO.getQueryActivityName() + "%")); } if (StringUtils.isNotEmpty(baseQueryDTO.getQueryOrgCode())) { predicate.getExpressions().add(cb.equal(root.get("orgCode"), baseQueryDTO.getQueryOrgCode())); } if (baseQueryDTO.getQueryStartDt() != null && baseQueryDTO.getQueryStartDt() != null) { predicate.getExpressions().add(cb.between(root.get("startDt"), baseQueryDTO.getQueryStartDt(), baseQueryDTO.getQueryStartDt())); } if (StringUtils.isNotEmpty(baseQueryDTO.getActivityType())){ predicate.getExpressions().add(cb.equal(root.get("activityType"), baseQueryDTO.getActivityType())); } return predicate; } }; }