semi working order info admin page

This commit is contained in:
Tim
2025-06-17 11:52:20 +02:00
parent 9895ccbcd4
commit a98fd3925e
13 changed files with 295 additions and 270 deletions

View File

@@ -41,6 +41,7 @@ public class ControllerPathConfig {
//OrderController
public static final String ORDER_BASE = "/order";
public static final String ORDER_GET_ALL = ORDER_BASE + "/all";
public static final String ORDER_GET_ALL_ADMIN = ORDER_BASE + "/all/all";
//ReviewController
public static final String REVIEW_BASE = "/review";

View File

@@ -16,8 +16,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_BASE;
import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_GET_ALL;
import static de.htwsaar.webshop.config.ControllerPathConfig.*;
import static de.htwsaar.webshop.config.ParameterConfig.*;
import static de.htwsaar.webshop.util.LoggerUtil.logRequest;
@@ -47,7 +46,7 @@ public class OrderController {
return ResponseEntity.ok(orders.stream().map(Order::toModel).toList());
}
@RequestMapping(path = ORDER_GET_ALL, method = RequestMethod.TRACE, produces = "application/json")
@RequestMapping(path = ORDER_GET_ALL_ADMIN, method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<List<OrderModel>> getAll(HttpServletRequest request,
@RequestParam(value = PARAM_EMAIL) String email,
@RequestParam(value = PARAM_SESSION) UUID token) {
@@ -92,10 +91,16 @@ public class OrderController {
@RequestParam(value = PARAM_STATUS) OrderStatus status) {
logRequest(request);
if (orderId == null) {
log.info("[{}] failed to update, empty orderID", request.getRequestURI());
return ResponseEntity.badRequest().build();
}
if (status == null) {
log.info("[{}] failed to update, empty status, orderID {}", request.getRequestURI(), orderId);
return ResponseEntity.badRequest().build();
}
Order order = orderService.getOrderById(orderId);
if (order == null) {
log.info("[{}] failed to update orderID {}", request.getRequestURI(), orderId);
return ResponseEntity.notFound().build();
}
order.setStatus(status);