Browse Source

增加getAll

zhouhao 6 years ago
parent
commit
fac2554099

+ 14 - 0
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/BoostDictDefineRepository.java

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author zhouhao
@@ -41,4 +42,17 @@ public class BoostDictDefineRepository extends DefaultDictDefineRepository {
                 .build();
     }
 
+    @Override
+    public List<DictDefine> getAllDefine() {
+        List<DictDefine> all = dictionaryService.select()
+                .stream()
+                .map(dict -> DefaultDictDefine.builder()
+                        .id(dict.getId())
+                        .comments(dict.getDescribe())
+                        .items((List) new ArrayList<>(dict.getItems()))
+                        .build()).collect(Collectors.toList());
+
+        all.addAll(super.getAllDefine());
+        return all;
+    }
 }

+ 7 - 0
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java

@@ -63,6 +63,13 @@ public class DictionaryController implements SimpleGenericEntityController<Dicti
         return dictionaryService;
     }
 
+    @GetMapping("/define/all")
+    @Authorize(merge = false)
+    @ApiOperation("获取数据全部字典定义信息")
+    public ResponseMessage<List<DictDefine>> getAllDefineById() {
+        return ok(repository.getAllDefine());
+    }
+
 
     @GetMapping("/define/{id:.+}")
     @Authorize(merge = false)