删除网站分类

This commit is contained in:
cyk
2023-12-24 18:19:32 +08:00
parent 74df52c3aa
commit 6fdbb36e6b
9 changed files with 77 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.lovenav.dao.UserDao;
import com.lovenav.entity.UrlCateList;
import com.lovenav.entity.UrlList;
import com.lovenav.service.UrlCateListService;
@@ -48,8 +49,8 @@ public class UrlAndCateController {
@Autowired
UrlListService urlListService;
@Autowired
UserDao userDao;
//处理JSON
@RequestMapping("/disposeJson")
public String disposeJson(@RequestBody String data2 ,String email)
@@ -605,18 +606,31 @@ public class UrlAndCateController {
}
@RequestMapping("/deleteCateByCateId")
public String deleteCateByCateId(String cateId)
public String deleteCateByCateId(Integer Id,String userId)
{
int flag = 0;
HashMap<String, Object> result = new HashMap<>();
if(flag == 1)
{
Set<Integer> parentList = new HashSet<>();
parentList.add(Integer.valueOf(Id));
List<String> stringList = urlCateListService.selectChildrenByCateId(Id);
String childrenString= String.join(",", stringList);
String [] strings = childrenString.split(",");
Set<String> set = new HashSet<>(Arrays.asList(strings));
for(String child : set){
if(child.equals("")) {
urlListService.deleteByCateId(Long.valueOf(Id));
urlCateListService.deleteByPrimaryKey(Id);
}else{
urlListService.deleteByCateId(Long.valueOf(child));
urlCateListService.deleteByPrimaryKey(Integer.valueOf(child));
}
}
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getUserEmail());
result.put("code", 200);
result.put("msg", "处理成功");
}else{
result.put("code", 500);
result.put("msg", "处理失败");
}
return JSONObject.toJSONString(result);
}