在spring-data-rest应用程序中验证请求参数

我正在使用spring-data-rest公开REST API,并且不想编写自定义控制器。为了对多个字段启用过滤,我正在使用QueryDsl并希望验证请求参数。我没有看到可以触发验证的任何钩子。 我唯一的选择是在QuerydslBinderCustomizer的定制方法中添加手动验证代码。

下面是我的存储库类的样子

公共接口TestRepository扩展了PagingAndSortingRepository,         QuerydslPredicateExecutor,QuerydslBinderCustomizer {

@Override
default void customize(QuerydslBindings bindings,QTest test) {
    bindings.excludeUnlistedProperties(true);
    bindings.including(test.name,test.number);

    bindings.bind(test.name).first((StringPath path,String value) -> {
        return path.containsIgnoreCase(value);
    });
    bindings.bind(test.number).first((StringPath path,String value) -> {
        return path.containsIgnoreCase(value);
    });
}

}

wenhong1314 回答:在spring-data-rest应用程序中验证请求参数

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3021133.html

大家都在问