|
|
@@ -0,0 +1,56 @@
|
|
|
+package com.etotem.cfc.controller;
|
|
|
+
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.dto.DimensionNode;
|
|
|
+import com.etotem.cfc.service.DimensionCodeMapper;
|
|
|
+import com.etotem.cfc.service.DimensionRegistryService;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 统一维度注册中心 —— 只读取数入口(新增,不破坏旧接口)。
|
|
|
+ *
|
|
|
+ * <p>GET /api/dimension-registry/tree | /roots | /code/{code} | /map</p>
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/dimension-registry")
|
|
|
+public class DimensionRegistryController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DimensionRegistryService dimensionRegistryService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DimensionCodeMapper dimensionCodeMapper;
|
|
|
+
|
|
|
+ @GetMapping("/tree")
|
|
|
+ public Result<List<DimensionNode>> tree(@RequestParam(required = false) String sourceSystem) {
|
|
|
+ return Result.success(sourceSystem == null || sourceSystem.isEmpty()
|
|
|
+ ? dimensionRegistryService.getTree()
|
|
|
+ : dimensionRegistryService.getTree(sourceSystem));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/roots")
|
|
|
+ public Result<List<DimensionNode>> roots() {
|
|
|
+ return Result.success(dimensionRegistryService.getRoots());
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/code/{code}")
|
|
|
+ public Result<DimensionNode> code(@PathVariable String code) {
|
|
|
+ DimensionNode node = dimensionRegistryService.getNodeByCode(code);
|
|
|
+ if (node == null) {
|
|
|
+ return Result.error("维度节点不存在: " + code);
|
|
|
+ }
|
|
|
+ return Result.success(node);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/map")
|
|
|
+ public Result<String> map(@RequestParam String legacy) {
|
|
|
+ return Result.success(dimensionCodeMapper.resolveToUnified(legacy));
|
|
|
+ }
|
|
|
+}
|