This commit is contained in:
2023-12-24 22:28:39 +08:00
parent f7269cc5e2
commit 564848513f
17 changed files with 42 additions and 37 deletions

View File

@@ -53,15 +53,15 @@ public class UrlAndCateController {
UserDao userDao;
//处理JSON
@RequestMapping("/disposeJson")
public String disposeJson(@RequestBody String data2 ,String email)
public String disposeJson(@RequestBody String data2 ,Integer userId)
{
String jsonString;
//先转换成ObjectMapper类型
ObjectNode objectNode = objectMapper.createObjectNode();
try {
JsonNode rootNode = objectMapper.readTree(data2);
disposeBookmarkFunction1(rootNode,"top",email);
countCateContainUrlNumber(email);
disposeBookmarkFunction1(rootNode,"top",userId);
countCateContainUrlNumber(userId);
HashMap<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "查询成功");
@@ -71,23 +71,24 @@ public class UrlAndCateController {
}
return jsonString;
}
public void disposeBookmarkFunction1(JsonNode rootNode,String parent,String email)
public void disposeBookmarkFunction1(JsonNode rootNode,String parent,Integer userId)
{
for(int i=0;i<rootNode.size();i++)
{
JsonNode sonNode = rootNode.get(i);
if(String.valueOf(sonNode.get("folder")).equals("true")){
urlCateListService.selectAndInsertUrlCate(email,String.valueOf(sonNode.get("name")),parent);
if(String.valueOf(sonNode.get("type")).equals("\"folder\"")){
System.out.println(1);
urlCateListService.selectAndInsertUrlCate(userId,String.valueOf(sonNode.get("name")),parent,String.valueOf(sonNode.get("icon")));
JsonNode children = sonNode.get("children");
disposeBookmarkFunction1(children, String.valueOf(sonNode.get("name")),email);
disposeBookmarkFunction1(children, String.valueOf(sonNode.get("name")),userId);
}else{
String name = String.valueOf(sonNode.get("name"));
String url = String.valueOf(sonNode.get("url"));
String adddata = String.valueOf(sonNode.get("adddata"));
urlListService.selectCateAndInsertUrl(parent,name,"123",url,email);
System.out.println(name +"---" + url + "---" + adddata + "---" + parent );
String url = String.valueOf(sonNode.get("href"));
String icon = String.valueOf(sonNode.get("icon"));
urlListService.selectCateAndInsertUrl(parent,name,icon , url,userId);
System.out.println(name +"---" + url + "---" + parent );
}
}
@@ -283,11 +284,11 @@ public class UrlAndCateController {
}
public String countCateContainUrlNumber(String email){
public String countCateContainUrlNumber(Integer userId){
HashMap<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "查询成功");
result.put("data",urlCateListService.countCateContainUrlNumber(email));
result.put("data",urlCateListService.countCateContainUrlNumber(userId));
String jsonString = JSONObject.toJSONString(result);
return jsonString;
}
@@ -630,7 +631,7 @@ public class UrlAndCateController {
}
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getUserEmail());
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getId());
result.put("code", 200);
result.put("msg", "处理成功");
return JSONObject.toJSONString(result);