Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Filter JPA entities directly in database queries. The module converts filter exp
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>jpa</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

Expand Down Expand Up @@ -114,7 +114,7 @@ Filter MongoDB documents using Spring Data MongoDB queries.
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>mongo</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

Expand Down Expand Up @@ -150,7 +150,7 @@ Filter in-memory collections using Java Predicates. Works with any POJO, no data
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>predicate</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

Expand Down Expand Up @@ -222,7 +222,7 @@ Build filter expressions programmatically instead of writing filter strings manu
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>core</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

Expand Down Expand Up @@ -268,7 +268,7 @@ Add automatic Swagger documentation for endpoints with `@Filter` parameters.
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>openapi</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

Expand All @@ -290,15 +290,15 @@ The `page-sort` module provides annotations for pagination, sorting, and field s
<dependency>
<groupId>com.turkraft.springfilter</groupId>
<artifactId>page-sort</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
</dependency>
```

### Basic Usage

```java
@GetMapping("/cars")
Page<Car> search(@Filter Specification<Car> spec, @Page Pageable page) {
Page<Car> search(@Filter Specification<Car> spec, @Pagination Pageable page) {
return repository.findAll(spec, page);
}
```
Expand All @@ -310,7 +310,7 @@ Usage: `?page=0&size=20&sort=-year` (prefix `-` for descending)
```java
@GetMapping("/cars")
Page<Car> search(
@Page(pageParameter = "p", sizeParameter = "limit", sortParameter = "order") Pageable page) {
@Pagination(pageParameter = "p", sizeParameter = "limit", sortParameter = "order") Pageable page) {
return repository.findAll(page);
}
```
Expand Down Expand Up @@ -361,7 +361,7 @@ Use `?fields=id,brand.name,year` to return only specified fields. Uses Jackson's
@GetMapping("/cars")
Page<Car> search(
@Filter Specification<Car> spec,
@Page Pageable page) {
@Pagination Pageable page) {
return repository.findAll(spec, page);
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public String getDescription() {

@Override
public String getExample() {
return "status in ('active', 'pending')";
return "status in ['active', 'pending']";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.github.javafaker.Faker;
import com.turkraft.springfilter.boot.Fields;
import com.turkraft.springfilter.boot.Filter;
import com.turkraft.springfilter.boot.Page;
import com.turkraft.springfilter.boot.Pagination;
import com.turkraft.springfilter.converter.FilterSpecification;
import com.turkraft.springfilter.example.model.Address;
import com.turkraft.springfilter.example.model.Company;
Expand Down Expand Up @@ -170,7 +170,7 @@ public void index(HttpServletResponse response)
@Fields
public List<Industry> getIndustries(
@Filter FilterSpecification<Industry> filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
return industryRepository
.findAll(filter, pageable)
.getContent();
Expand All @@ -180,7 +180,7 @@ public List<Industry> getIndustries(
@Fields
public List<Company> getCompanies(
@Filter FilterSpecification<Company> filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
return companyRepository
.findAll(filter, pageable)
.getContent();
Expand All @@ -190,7 +190,7 @@ public List<Company> getCompanies(
@Fields
public List<Employee> getEmployees(
@Filter FilterSpecification<Employee> filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
return employeeRepository
.findAll(filter, pageable)
.getContent();
Expand All @@ -200,7 +200,7 @@ public List<Employee> getEmployees(
@Fields
public List<Payslip> getPayslips(
@Filter FilterSpecification<Payslip> filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
return payslipRepository
.findAll(filter, pageable)
.getContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.github.javafaker.Faker;
import com.turkraft.springfilter.boot.Fields;
import com.turkraft.springfilter.boot.Filter;
import com.turkraft.springfilter.boot.Page;
import com.turkraft.springfilter.boot.Pagination;
import com.turkraft.springfilter.example.model.Company;
import com.turkraft.springfilter.example.model.Employee;
import com.turkraft.springfilter.example.model.Employee.MaritalStatus;
Expand Down Expand Up @@ -183,7 +183,7 @@ public void index(HttpServletResponse response)
@Fields
public List<Industry> getIndustries(
@Filter(entityClass = Industry.class) Document filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
Query query = new BasicQuery(filter);
query.with(pageable);
return mongoTemplate.find(query, Industry.class);
Expand All @@ -193,7 +193,7 @@ public List<Industry> getIndustries(
@Fields
public List<Company> getCompanies(
@Filter(entityClass = Company.class) Document filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
Query query = new BasicQuery(filter);
query.with(pageable);
return mongoTemplate.find(query, Company.class);
Expand All @@ -203,7 +203,7 @@ public List<Company> getCompanies(
@Fields
public List<Employee> getEmployees(
@Filter(entityClass = Employee.class) Document filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
Query query = new BasicQuery(filter);
query.with(pageable);
return mongoTemplate.find(query, Employee.class);
Expand All @@ -213,7 +213,7 @@ public List<Employee> getEmployees(
@Fields
public List<Payslip> getPayslips(
@Filter(entityClass = Payslip.class) Document filter,
@Page Pageable pageable) {
@Pagination Pageable pageable) {
Query query = new BasicQuery(filter);
query.with(pageable);
return mongoTemplate.find(query, Payslip.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public FilterParameterCustomizer filterParameterCustomizer(
@ConditionalOnMissingBean
@ConditionalOnClass(name = {
"com.turkraft.springfilter.boot.Sort",
"com.turkraft.springfilter.boot.Page",
"com.turkraft.springfilter.boot.Pagination",
"com.turkraft.springfilter.boot.Fields"
})
public PageSortParameterCustomizer pageSortParameterCustomizer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Operation customize(@Nullable Operation operation, @Nullable HandlerMetho
try {

Class<?> sortAnnotation = Class.forName("com.turkraft.springfilter.boot.Sort");
Class<?> pageAnnotation = Class.forName("com.turkraft.springfilter.boot.Page");
Class<?> pageAnnotation = Class.forName("com.turkraft.springfilter.boot.Pagination");

Object sort = parameter.getAnnotation((Class) sortAnnotation);
Object page = parameter.getAnnotation((Class) pageAnnotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.mockito.Mockito.when;

import com.turkraft.springfilter.boot.Fields;
import com.turkraft.springfilter.boot.Page;
import com.turkraft.springfilter.boot.Pagination;
import com.turkraft.springfilter.boot.Sort;
import com.turkraft.springfilter.openapi.introspection.EntityIntrospector;
import com.turkraft.springfilter.openapi.springdoc.PageSortParameterCustomizer;
Expand Down Expand Up @@ -357,18 +357,18 @@ public String withSortAnnotation(@Sort(parameter = "customSort", required = true
}

@GetMapping("/page")
public String withPage(@Page Pageable page) {
public String withPage(@Pagination Pageable page) {
return "ok";
}

@GetMapping("/page-annotation")
public String withPageAnnotation(
@Page(pageParameter = "p", sizeParameter = "s", sortParameter = "order", defaultPage = 1, defaultSize = 50, maxSize = 200) Pageable page) {
@Pagination(pageParameter = "p", sizeParameter = "s", sortParameter = "order", defaultPage = 1, defaultSize = 50, maxSize = 200) Pageable page) {
return "ok";
}

@GetMapping("/page-no-sort")
public String withPageNoSort(@Page(enableSort = false) Pageable page) {
public String withPageNoSort(@Pagination(enableSort = false) Pageable page) {
return "ok";
}

Expand All @@ -388,7 +388,7 @@ public String withFieldsAnnotation() {
@GetMapping("/all")
public String withAllAnnotations(
@Sort org.springframework.data.domain.Sort sort,
@Page Pageable page) {
@Pagination Pageable page) {
return "ok";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PageArgumentResolver(SortParser sortParser) {

@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(Page.class)
return parameter.hasParameterAnnotation(Pagination.class)
&& Pageable.class.isAssignableFrom(parameter.getParameterType());
}

Expand All @@ -30,9 +30,9 @@ public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) {

Page pageAnnotation = parameter.getParameterAnnotation(Page.class);
Pagination pageAnnotation = parameter.getParameterAnnotation(Pagination.class);
if (pageAnnotation == null) {
return PageRequest.of(Page.DEFAULT_PAGE, Page.DEFAULT_SIZE);
return PageRequest.of(Pagination.DEFAULT_PAGE, Pagination.DEFAULT_SIZE);
}

String pageParam = webRequest.getParameter(pageAnnotation.pageParameter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Page {
public @interface Pagination {

String DEFAULT_PAGE_PARAMETER = "page";

Expand Down
Loading