This is a simple Spring Boot project using biggates/eaphone-spring-data-query.
The original sample project is darrachequesne/spring-data-jpa-datatables-sample.
(Not verified)
mvn spring-boot:runThe project will start at http://localhost:8080/.
This project shows how to use eaphone-spring-data-query in your project, and a very basic version of JavaScript grid.
The web page contains three parts: request (and examples), raw response and rendered grid.
The page contains one data grid, with some pre-defined searching values.
On the page you can try the following features:
- Search by pre-defined columns
- Restrict the date range by providing a custom criteria
- Change order by any single column
- Pagination
- During the starting process, it inserts
200completely random rows ofOrderitem inOrderRestController#insertSampleData(), plus 2 specificOrderitem, in order to provide at least one search result in pre-defined queries. - The project serves a static web page, displaying a grid using DataTables. The detailed initialization script is in
/index.js.
- An H2 in-memory database is created.
-
This project uses bwaldvogel/mongo-java-server to create an in-memory MongoDB server named
test(seeMongodbSampleApplication$Config). -
The params
startDateandendDateis used to restrict the range of a value. DataTables only handles "match" type of search, which is usually not enough. The criteria andpreFilteringis used to further define a criteria.
If you want to use eaphone-spring-data-query in your own project, these steps must be done:
-
Include the library in your project (it's not in any public Maven repository yet)
-
Declare a spring-data repo, extending
JpaQueryRepository<EntityType, KeyType>orMongoDBQueryRepository<DocumentType, KeyType> -
Create your controller, basically as:
@Autowired private OrderRepo repo; @GetMapping() public QueryOutput<Order> getOrders(@Valid QueryInput input){ return repo.findAll(input); }
-
Write your JavaScript for the datagrid.
