diff --git a/src/main/java/com/example/building/controller/ProductController.java b/src/main/java/com/example/building/controller/ProductController.java index 3a36f4d..669e867 100644 --- a/src/main/java/com/example/building/controller/ProductController.java +++ b/src/main/java/com/example/building/controller/ProductController.java @@ -156,12 +156,16 @@ public class ProductController { @PostMapping("/categories/{categoryId}/attributes") public Result saveCategoryAttributes( @PathVariable String categoryId, - @RequestBody List attributes, + @RequestBody Map body, @RequestHeader(value = "X-User-Role", required = false) String role) { if (!"admin".equals(role)) { return Result.error("只有管理员可以操作"); } - categoryAttributeService.saveAttributes(categoryId, attributes); + List attrs = (List) body.get("attributes"); + if (attrs == null) { + attrs = (List) body.get("list"); + } + categoryAttributeService.saveAttributes(categoryId, attrs); return Result.success(); }