【发布时间】:2020-12-02 16:14:24
【问题描述】:
查看来自 specification-argument-resolver 的示例代码,
@Controller
public class SampleController {
@Autowired
CustomerRepository customerRepository;
@RequestMapping("/find")
public List<Customer> findByRegistrationDate(
@And({
@Spec(path = "name", params = "name", spec = Equal.class),
@Spec(path = "registrationDate", params = "registrationDate", spec = GreaterThanOrEqual.class)
}) Specification<Customer> spec) {
return customerRepository.findAll(spec);
}
}
@Entity
public class Customer {
String name;
Date registrationDate;
}
查看specification-argument-resolver的示例代码,示例请求如下所示:
GET /find?name=John®istrationDate=2020-06-19
有没有办法让查询参数反映实际的运算符。
示例:registrationDate>=2020-06-19 而不仅仅是 =
我正在寻找 RSQL 和规范参数解析器之间的混合体。
【问题讨论】:
-
让参数名称实际反映所要求的内容不是更容易(也更合乎逻辑)吗?例如。
registeredAfter或registeredAfterInclusive.
标签: spring-boot spring-data-jpa jpa-2.0