Merge branch 'main' of github.com:FlorianSpeicher04/webshop
This commit is contained in:
@@ -13,9 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static de.htwsaar.webshop.config.ControllerPathConfig.ARTICLE_BASE;
|
import static de.htwsaar.webshop.config.ControllerPathConfig.*;
|
||||||
import static de.htwsaar.webshop.config.ControllerPathConfig.ARTICLE_GET_ALL;
|
|
||||||
import static de.htwsaar.webshop.config.ControllerPathConfig.ARTICLE_GET_ALL_WITH_IMAGE;
|
|
||||||
import static de.htwsaar.webshop.config.ParameterConfig.PARAM_UUID;
|
import static de.htwsaar.webshop.config.ParameterConfig.PARAM_UUID;
|
||||||
import static de.htwsaar.webshop.util.LoggerUtil.logRequest;
|
import static de.htwsaar.webshop.util.LoggerUtil.logRequest;
|
||||||
|
|
||||||
@@ -67,12 +65,19 @@ public class ArticleController {
|
|||||||
@RequestParam(value = PARAM_UUID) UUID uuid,
|
@RequestParam(value = PARAM_UUID) UUID uuid,
|
||||||
@RequestBody Article article) {
|
@RequestBody Article article) {
|
||||||
logRequest(request);
|
logRequest(request);
|
||||||
if (uuid == null || uuid.toString().isEmpty() || articleService.findByUUID(uuid) == null) {
|
if (uuid == null || uuid.toString().isEmpty()) {
|
||||||
|
log.warn("[{}] got null UUID", request.getRequestURI());
|
||||||
|
return ResponseEntity.badRequest().body(false);
|
||||||
|
}
|
||||||
|
if (articleService.findByUUID(uuid) == null) {
|
||||||
|
log.warn("[{}] got invalid UUID {}", request.getRequestURI(), uuid);
|
||||||
return ResponseEntity.badRequest().body(false);
|
return ResponseEntity.badRequest().body(false);
|
||||||
}
|
}
|
||||||
article.setId(articleService.findByUUID(uuid).getId());
|
article.setId(articleService.findByUUID(uuid).getId());
|
||||||
|
if (articleService.update(article) != null) {
|
||||||
return ResponseEntity.ok(articleService.save(article) != null);
|
return ResponseEntity.internalServerError().body(false);
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = ARTICLE_BASE, method = RequestMethod.DELETE, produces = "application/json")
|
@RequestMapping(path = ARTICLE_BASE, method = RequestMethod.DELETE, produces = "application/json")
|
||||||
|
|||||||
Reference in New Issue
Block a user