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

View File

@ -8,10 +8,10 @@ import java.util.List;
public interface UrlCateListService { public interface UrlCateListService {
public int selectAndInsertUrlCate(String email , String cateName , String parent); public int selectAndInsertUrlCate(Integer userId , String cateName , String parent,String icon);
public List<UrlCateList> selectUrListByUserId(Integer userId); public List<UrlCateList> selectUrListByUserId(Integer userId);
public String countCateContainUrlNumber(String userId); public String countCateContainUrlNumber(Integer userId);
public JSONArray getUrl(String userId); public JSONArray getUrl(String userId);
public String selectUrListCateByUrlCateId(Integer cateId); public String selectUrListCateByUrlCateId(Integer cateId);

View File

@ -6,7 +6,7 @@ import java.util.List;
public interface UrlListService { public interface UrlListService {
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email ); public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,Integer userId );
public List<UrlList> selectUrList(); public List<UrlList> selectUrList();
public UrlList selectUrListByInput(String input); public UrlList selectUrListByInput(String input);
public UrlList selectUrlListByUrlId(Long urlId); public UrlList selectUrlListByUrlId(Long urlId);

View File

@ -27,22 +27,24 @@ public class UrlCateListServiceImpl implements UrlCateListService {
UrlListDao urlListDao; UrlListDao urlListDao;
@Autowired @Autowired
UserDao userDao; UserDao userDao;
public int selectAndInsertUrlCate(String email , String cateName , String parent ) public int selectAndInsertUrlCate(Integer userId , String cateName , String parent,String icon )
{ {
//找用户ID //找用户ID
User user = userDao.selectByEmail(email);
int userId = user.getId();
//找父标签有没有 //找父标签有没有
UrlCateList cateParent = urlCateListDao.selectCateByNameAnduserId(parent,userId); UrlCateList cateParent = urlCateListDao.selectCateByNameAnduserId(parent,userId);
UrlCateList targetCate = new UrlCateList(); UrlCateList targetCate = new UrlCateList();
//设置属性 //设置属性
targetCate.setName(cateName); targetCate.setName(cateName.substring(1,cateName.length()-1));
targetCate.setUserId(userId); targetCate.setUserId(userId);
Date date = new Date(); Date date = new Date();
targetCate.setCreatetime(date.getTime()); targetCate.setCreatetime(date.getTime());
targetCate.setWeigh(Long.valueOf(0));
targetCate.setStatus(Byte.valueOf(0+""));
targetCate.setNeedLogin(Byte.valueOf(0+""));
targetCate.setIco(icon);
if(cateParent != null) if(cateParent != null)
{ {
targetCate.setRootCateId(cateParent.getId()); targetCate.setRootCateId(cateParent.getId());
@ -85,10 +87,9 @@ public class UrlCateListServiceImpl implements UrlCateListService {
return urlCateListDao.selectByPrimaryKey(id); return urlCateListDao.selectByPrimaryKey(id);
} }
public String countCateContainUrlNumber(String email){ public String countCateContainUrlNumber(Integer userId){
User user = userDao.selectByEmail(email);
int userId = user.getId(); List<UrlCateList> urlCateLists =urlCateListDao.selectUrListByUserId(3);
List<UrlCateList> urlCateLists =urlCateListDao.selectUrListByUserId(userId);
List<UrlList> urlLists = urlListDao.selectUrList(); List<UrlList> urlLists = urlListDao.selectUrList();
HashMap<String,Integer> CateNumber = new HashMap<>(); HashMap<String,Integer> CateNumber = new HashMap<>();
@ -96,24 +97,26 @@ public class UrlCateListServiceImpl implements UrlCateListService {
{ {
CateNumber.put(urlCateList.getName(),0); CateNumber.put(urlCateList.getName(),0);
} }
for(UrlList urlList : urlLists){
Long id = Long.valueOf(urlList.getCateId());
while(id!= 0) for(UrlList urlList : urlLists){
String parentString = urlCateListDao.selectUrListCateByUrlCateId(urlList.getCateId());
String [] strings = parentString.split(",");
for(String str :strings)
{ {
if(str.equals("0")) continue;
for(UrlCateList urlCateList :urlCateLists) for(UrlCateList urlCateList :urlCateLists)
{ {
if(id == Long.valueOf(urlCateList.getId())){ if(urlCateList.getId() == Integer.valueOf(str)){
int cateNum = CateNumber.get(urlCateList.getName())+1; int cateNum = CateNumber.get(urlCateList.getName())+1;
CateNumber.put(urlCateList.getName(),cateNum); CateNumber.put(urlCateList.getName(),cateNum);
id=Long.valueOf(urlCateList.getRootCateId()); System.out.println(urlCateList.getName());
break; break;
} }
} }
} }
} }
Iterator iterator = CateNumber.entrySet().iterator(); Iterator iterator = CateNumber.entrySet().iterator();
while(iterator.hasNext()) { while(iterator.hasNext()) {

View File

@ -25,22 +25,23 @@ public class UrlLiserServiceImpl implements UrlListService {
UrlListDao urlListDao; UrlListDao urlListDao;
@Autowired @Autowired
UserDao userDao; UserDao userDao;
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email) public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,Integer userId)
{ {
//找用户ID
User user = userDao.selectByEmail(email);
int userId = user.getId();
parent = parent.substring(1,parent.length()-1);
UrlCateList urlCateList = urlCateListDao.selectCateByNameAnduserId(parent,userId); UrlCateList urlCateList = urlCateListDao.selectCateByNameAnduserId(parent,userId);
UrlList urlList = new UrlList(); UrlList urlList = new UrlList();
//设置属性 //设置属性
urlList.setCateId(urlCateList.getId()); urlList.setCateId(urlCateList.getId());
urlList.setUrl(url); urlList.setUrl(url);
urlList.setIcon(icon); urlList.setIcon(icon);
urlList.setName(name); urlList.setName(name.substring(1,name.length()-1));
Date date = new Date(); Date date = new Date();
urlList.setCreatetime(date.getTime()); urlList.setCreatetime(date.getTime());
urlList.setViews(Long.valueOf("0")); urlList.setViews(Long.valueOf("0"));
urlList.setIsNeedAgent(Byte.valueOf(0+""));
urlList.setIsAd(Byte.valueOf(0+""));
urlList.setIsTop(Byte.valueOf(0+""));
Byte b = 0; Byte b = 0;
urlList.setNeedLogin(b); urlList.setNeedLogin(b);
int flag = urlListDao.insert(urlList); int flag = urlListDao.insert(urlList);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB