fix: 修复保存种类属性数据接收问题
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-29 15:20:35 +00:00
parent 01afb31fdc
commit a51427790b

View File

@@ -156,12 +156,16 @@ public class ProductController {
@PostMapping("/categories/{categoryId}/attributes") @PostMapping("/categories/{categoryId}/attributes")
public Result<Void> saveCategoryAttributes( public Result<Void> saveCategoryAttributes(
@PathVariable String categoryId, @PathVariable String categoryId,
@RequestBody List attributes, @RequestBody Map<String, Object> body,
@RequestHeader(value = "X-User-Role", required = false) String role) { @RequestHeader(value = "X-User-Role", required = false) String role) {
if (!"admin".equals(role)) { if (!"admin".equals(role)) {
return Result.error("只有管理员可以操作"); 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(); return Result.success();
} }