update customer filter and overview
This commit is contained in:
+31
-1
@@ -1,10 +1,10 @@
|
||||
package de.champonthis.buntspecht.controller;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.web.PagedModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.querydsl.core.QueryResults;
|
||||
import com.querydsl.core.Tuple;
|
||||
|
||||
import de.champonthis.buntspecht.businesslogic.TurnoverManager;
|
||||
import de.champonthis.buntspecht.businesslogic.UserManager;
|
||||
@@ -64,6 +65,35 @@ public class TurnoverController extends BaseController {
|
||||
sort.orElse("created"), descending.orElse(false), filter);
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/overview")
|
||||
@Transactional
|
||||
public Tuple overview(
|
||||
@RequestParam("limit") Optional<Long> limitParameter,
|
||||
@RequestParam("offset") Optional<Long> offsetParameter,
|
||||
@RequestParam("sort") Optional<String> sort,
|
||||
@RequestParam("descending") Optional<Boolean> descending,
|
||||
@RequestParam("from") Optional<Instant> from,
|
||||
@RequestParam("to") Optional<Instant> to,
|
||||
@RequestParam("customer") Optional<String> customer,
|
||||
@RequestParam("motif") Optional<String> motif) {
|
||||
|
||||
TurnoverFilterModel filter = new TurnoverFilterModel();
|
||||
filter.setCreated(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||
filter.setCustomer(customer.orElse(null));
|
||||
filter.setMotif(motif.orElse(null));
|
||||
|
||||
List<Tuple> result = turnoverManager.overview(getCurrentUsername(), limitParameter.orElse(15L),
|
||||
offsetParameter.orElse(0L), sort.orElse("username"),
|
||||
descending.orElse(false), filter).getResults();
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/{id}")
|
||||
@Transactional
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class TurnoverManagementController extends BaseController {
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping("/overview")
|
||||
@Transactional
|
||||
public QueryResults<Tuple> fetchGroup(
|
||||
public QueryResults<Tuple> overview(
|
||||
@RequestParam("username") Optional<String> usernameParameter,
|
||||
@RequestParam("limit") Optional<Long> limitParameter,
|
||||
@RequestParam("offset") Optional<Long> offsetParameter,
|
||||
|
||||
Reference in New Issue
Block a user