public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String username;
@OneToMany(mappedBy = "user")
private Set<Login> login;
}
public class Login {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private LocalDateTime loginTime;
@ManyToOne
private User user;
}
@RepositoryRestResource(collectionResourceRel = "user", path = "user")
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
List<User> findAll();
// List<User> List<User> findByLogin_LoginTimeGreaterThanEqualAndLogin_LoginTimeLessThanEqual(@Param("loginTime") LocalDate start, @Param("loginTime") LocalDate end); }
我想找到dateTime
大于或等于提供的start
参数值且小于或等于提供的end
参数值的所有唯一用户。
http://localhost:8080/api/users?start=YYYYMMDD&end=YYMMDD
当我尝试
curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/hal+json' -d '2018-06-19' 'http://localhost:8080/test/user/search/findAllByLogin_LoginTimeGreaterThanEqualAndLogin_LoginTimeLessThanEqual
我知道
“值不能为空!”
我正在使用1.5.4-RELEASE