|
@@ -4,6 +4,7 @@ import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.entity.ProductDimensionConfig;
|
|
import com.etotem.cfc.entity.ProductDimensionConfig;
|
|
|
import com.etotem.cfc.service.ProductDimensionConfigService;
|
|
import com.etotem.cfc.service.ProductDimensionConfigService;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -23,8 +24,13 @@ public class DimensionConfigController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private com.etotem.cfc.service.DimensionRegistryService dimensionRegistryService;
|
|
private com.etotem.cfc.service.DimensionRegistryService dimensionRegistryService;
|
|
|
|
|
|
|
|
|
|
+ /** 维度配置列表(TC-A-25-P:admin 守卫,非 admin → 403) */
|
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
|
- public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params) {
|
|
|
|
|
|
|
+ public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.forbidden("无权限");
|
|
|
|
|
+ }
|
|
|
String dimensionType = (String) params.get("dimensionType");
|
|
String dimensionType = (String) params.get("dimensionType");
|
|
|
Integer enabled = (Integer) params.get("enabled");
|
|
Integer enabled = (Integer) params.get("enabled");
|
|
|
int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
@@ -32,8 +38,13 @@ public class DimensionConfigController {
|
|
|
return Result.success(productDimensionConfigService.list(dimensionType, enabled, page, size));
|
|
return Result.success(productDimensionConfigService.list(dimensionType, enabled, page, size));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 维度配置详情(TC-A-25-P:admin 守卫,非 admin → 403) */
|
|
|
@PostMapping("/get")
|
|
@PostMapping("/get")
|
|
|
- public Result<ProductDimensionConfig> get(@RequestParam Long id) {
|
|
|
|
|
|
|
+ public Result<ProductDimensionConfig> get(@RequestParam Long id,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.forbidden("无权限");
|
|
|
|
|
+ }
|
|
|
ProductDimensionConfig config = productDimensionConfigService.getById(id);
|
|
ProductDimensionConfig config = productDimensionConfigService.getById(id);
|
|
|
if (config == null) {
|
|
if (config == null) {
|
|
|
return Result.error("维度配置不存在");
|
|
return Result.error("维度配置不存在");
|
|
@@ -41,21 +52,35 @@ public class DimensionConfigController {
|
|
|
return Result.success(config);
|
|
return Result.success(config);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 保存维度配置(TC-A-25-P:admin 守卫,非 admin → 403) */
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
|
- public Result<ProductDimensionConfig> save(@RequestBody ProductDimensionConfig config) {
|
|
|
|
|
|
|
+ public Result<ProductDimensionConfig> save(@RequestBody ProductDimensionConfig config,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.forbidden("无权限");
|
|
|
|
|
+ }
|
|
|
// 统一维度体系 P0-T4(设计文档 §5.2):admin 写入升级改调注册中心,
|
|
// 统一维度体系 P0-T4(设计文档 §5.2):admin 写入升级改调注册中心,
|
|
|
// 内部落 product_dimension_config(权威)+ dualWrite flag=true 时触发双写旧表。
|
|
// 内部落 product_dimension_config(权威)+ dualWrite flag=true 时触发双写旧表。
|
|
|
return Result.success(dimensionRegistryService.saveConfig(config));
|
|
return Result.success(dimensionRegistryService.saveConfig(config));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 删除维度配置(TC-A-25-P:admin 守卫,非 admin → 403;被引用维度由 Service 拒绝删除) */
|
|
|
@PostMapping("/delete")
|
|
@PostMapping("/delete")
|
|
|
- public Result<Void> delete(@RequestParam Long id) {
|
|
|
|
|
|
|
+ public Result<Void> delete(@RequestParam Long id,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.forbidden("无权限");
|
|
|
|
|
+ }
|
|
|
boolean success = productDimensionConfigService.deleteConfig(id);
|
|
boolean success = productDimensionConfigService.deleteConfig(id);
|
|
|
return success ? Result.success(null) : Result.error("删除失败");
|
|
return success ? Result.success(null) : Result.error("删除失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 维度配置树(TC-A-25-P:admin 守卫,非 admin → 403) */
|
|
|
@PostMapping("/tree")
|
|
@PostMapping("/tree")
|
|
|
- public Result<List<ProductDimensionConfig>> tree() {
|
|
|
|
|
|
|
+ public Result<List<ProductDimensionConfig>> tree(@RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.forbidden("无权限");
|
|
|
|
|
+ }
|
|
|
// 7 body 子节点经 seed(迁移447)入库后,既有 tree() 按 parent_id 自然展开
|
|
// 7 body 子节点经 seed(迁移447)入库后,既有 tree() 按 parent_id 自然展开
|
|
|
return Result.success(productDimensionConfigService.tree());
|
|
return Result.success(productDimensionConfigService.tree());
|
|
|
}
|
|
}
|