001
Posted 岁月峥嵘走过
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了001相关的知识,希望对你有一定的参考价值。
package me.zhengjie;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class EladminSystemApplicationTests {
private final static List<String> managerList = ListUtil.toList("User","Role","Timing","Menu");
private final static List<String> guesterList = ListUtil.toList("Dept");
private final static HashMap<String,List<String>> hashMap = new HashMap<String,List<String>>(){{
put("manager",managerList);
put("guester",guesterList);
}};
@Value(value="classpath:menu.json")
private Resource resource;
@Test
public void contextLoads() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
StringBuffer message=new StringBuffer();
String line = null;
while((line = br.readLine()) != null) {
message.append(line);
}
String defaultString=message.toString();
String result=defaultString.replaceAll(" ", "");
JSONArray objects = JSON.parseArray(result);
JSONArray children = objects.getJSONObject(0).getJSONArray("children");
JSONArray jResult = new JSONArray();
List<String> manager = hashMap.get("manager");
children.forEach(i ->{
JSONObject json = (JSONObject) i;
for (String key :manager){
if (key.equals(json.getString("name"))){
System.out.println("add - " + key);
}else {
jResult.add(json);
}
}
});
System.out.println(jResult.toJSONString());
// List<String> manager = hashMap.get("manager");
//
// JSONArray jResult = null;
// for (String key :manager){
// jResult = children.stream().filter(i -> {
// JSONObject json = (JSONObject)i;
// String name = json.getString("name");
// System.out.println(name + " === " + key);
// if (name.equals(key)){
// return false;
// }else {
// return true;
// }
// }).collect(Collectors.toCollection(JSONArray::new));
// }
//
// System.out.println(manager.toString());
// System.out.println(jResult);
}
public static void main(String[] args) {
}
}
以上是关于001的主要内容,如果未能解决你的问题,请参考以下文章
3Dmax导入Unity中 动画名字如何更改 图中动画名字Take001Unity里不能改 max怎么改