This commit is contained in:
@@ -78,15 +78,16 @@ public class ViolationService {
|
|||||||
LocalDateTime endDate,
|
LocalDateTime endDate,
|
||||||
String status,
|
String status,
|
||||||
int page, int size, String sortDirection) {
|
int page, int size, String sortDirection) {
|
||||||
|
|
||||||
Specification<Violation> spec = (root, query, cb) -> cb.conjunction();
|
Specification<Violation> spec = (root, query, cb) -> cb.conjunction();
|
||||||
|
|
||||||
if (targetFiles != null && !targetFiles.isEmpty()) {
|
if (targetFiles != null && !targetFiles.isEmpty()) {
|
||||||
spec = spec.and((root, query, cb) -> root.get("file").in(targetFiles));
|
spec = spec.and((root, query, cb) -> root.get("fileEntity").in(targetFiles));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startDate != null && endDate != null) {
|
if (startDate != null && endDate != null) {
|
||||||
spec = spec.and((root, query, cb) ->
|
spec = spec.and((root, query, cb) ->
|
||||||
cb.between(root.get("violationDate"), startDate, endDate));
|
cb.between(root.get("createdDate"), startDate, endDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != null && !status.isEmpty()) {
|
if (status != null && !status.isEmpty()) {
|
||||||
@@ -95,7 +96,7 @@ public class ViolationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Sort sort = Sort.by("ASC".equalsIgnoreCase(sortDirection) ?
|
Sort sort = Sort.by("ASC".equalsIgnoreCase(sortDirection) ?
|
||||||
Sort.Direction.ASC : Sort.Direction.DESC, "violationDate");
|
Sort.Direction.ASC : Sort.Direction.DESC, "createdDate");
|
||||||
|
|
||||||
return violationRepository.findAll(spec, PageRequest.of(page, size, sort));
|
return violationRepository.findAll(spec, PageRequest.of(page, size, sort));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user