我正在为管理员创建用户列表。它们将按User实体的所有字段过滤结果。他们将受到的唯一限制是由于数据保护,他们将无法看到具有特定角色组合的用户。
我试图实现这一目标的方法是结合两个规范。
第一个接收来自前端的所有过滤器,并根据用户的值过滤用户。
第二个过滤器使用一个negationalSpecification过滤列表,该规范返回没有角色组合的所有用户:ROLE_USER(所有用户都具有该角色才能登录)和ROLE_FARMER(具有数据保护的那个)。 / p>
问题来了。好像JHipster实现QueryService的方式一样,我不能同时使用两个角色作为取反值。此函数中没有if(filter.getIn()!= null):
/**
* Helper function to return a specification for filtering on one-to-many or many-to-many reference. Usage:
* <pre>
* Specification<Employee> specByEmployeeId = buildReferringEntitySpecification(criteria.getEmployeId(),
* Project_.employees, Employee_.id);
* Specification<Employee> specByEmployeeName = buildReferringEntitySpecification(criteria.getEmployeName(),
* Project_.project, Project_.name);
* </pre>
*
* @param filter the filter object which contains a value, which needs to match or a flag if emptiness is
* checked.
* @param reference the attribute of the static metamodel for the referring entity.
* @param valueField the attribute of the static metamodel of the referred entity, where the equality should be
* checked.
* @param <OTHER> The type of the referenced entity.
* @param <X> The type of the attribute which is filtered.
* @return a Specification
*/
protected <OTHER, X> Specification<ENTITY> buildReferringEntitySpecification(Filter<X> filter,
SetAttribute<ENTITY, OTHER> reference,
SingularAttribute<OTHER, X> valueField) {
if (filter.getEquals() != null) {
return equalsSetSpecification(reference, valueField, filter.getEquals());
} else if (filter.getSpecified() != null) {
return byFieldSpecified(reference, filter.getSpecified());
}
return null;
}
我是JHipster的新手,所以也许我错过了一些东西,但我看到了类似的问题:
Filtering not working for some types and some parameters 任何帮助将不胜感激。