Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
upliveapp committed Mar 30, 2019
1 parent 36577d2 commit bb22c84
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,38 @@ private List<Map<String, Object>> getKeys () {
* @return 开关
*/
@GetMapping("tree")
public ResponseEntity<Map<String, Map<String, List<Map<String, Object>>>>> tree() {
public ResponseEntity<List<Map<String, Object>>> tree() {
try {
List<Map<String, Object>> keys = getKeys();
Map<String, Map<String, List<Map<String, Object>>>> tree = new HashMap();
Map<String, Map<String, List<Map<String, Object>>>> otree = new HashMap();
for (Map<String, Object> key : keys) {
String application = String.valueOf(key.get("application"));
if (!tree.containsKey(application)) {
tree.put(application, new HashMap());
if (!otree.containsKey(application)) {
otree.put(application, new HashMap());
}
String name = String.valueOf(key.get("key"));
if (!tree.get(application).containsKey(name)) {
tree.get(application).put(name, new ArrayList());
if (!otree.get(application).containsKey(name)) {
otree.get(application).put(name, new ArrayList());
}
tree.get(application).get(name).add(key);
otree.get(application).get(name).add(key);
}
List<Map<String, Object>> tree = new ArrayList();
for (String application : otree.keySet()) {
Map<String, Object> m0 = new HashMap();
m0.put("text", application);
m0.put("selected", true);
m0.put("opened", true);
Map<String, List<Map<String, Object>>> m1 = otree.get(application);
List<Map<String, Object>> children = new ArrayList();
for (String name : m1.keySet()) {
Map<String, Object> m3 = new HashMap();
m3.put("text", name);
m3.put("selected", true);
m3.put("opened", true);
children.add(m3);
}
m0.put("children", children);
tree.add(m0);
}
return ResponseEntity.ok(tree);
} catch (Throwable e) {
Expand Down

0 comments on commit bb22c84

Please sign in to comment.