删除网站分类

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);
}

View File

@@ -31,4 +31,7 @@ public interface UrlCateListDao {
public List<UrlCateList> selectUrListByUserId(Integer userId);
public String selectUrListCateByUrlCateId(Integer cateId);
public List<String> selectChildrenByCateId(Integer id);
}

View File

@@ -31,5 +31,5 @@ public interface UrlListDao {
public List<UrlList> selectUrListByNeedLogin();
public int deleteByCateId(Long id);
}

View File

@@ -20,4 +20,9 @@ public interface UrlCateListService {
public int insertSelective(UrlCateList urlCateList);
public int updateByUrlCateList(UrlCateList urlCateList);
public List<String> selectChildrenByCateId(Integer id);
public int deleteByPrimaryKey(Integer id);
}

View File

@@ -15,4 +15,7 @@ public interface UrlListService {
public List<UrlList> selectUrListByNeedLogin();
public int insertUrlByUser(UrlList urlList);
public int deleteByPrimaryKey(Long id);
public int deleteByCateId(Long id);
}

View File

@@ -72,6 +72,14 @@ public class UrlCateListServiceImpl implements UrlCateListService {
{
return urlCateListDao.updateByPrimaryKeySelective(urlCateList);
}
public List<String> selectChildrenByCateId(Integer id)
{
return urlCateListDao.selectChildrenByCateId(id);
}
public UrlCateList selectByPrimaryKey(Integer id)
{
return urlCateListDao.selectByPrimaryKey(id);
@@ -145,4 +153,8 @@ public class UrlCateListServiceImpl implements UrlCateListService {
}
return jsonArray;
}
public int deleteByPrimaryKey(Integer id){
return urlCateListDao.deleteByPrimaryKey(id);
}
}

View File

@@ -79,4 +79,12 @@ public class UrlLiserServiceImpl implements UrlListService {
}
}
public int deleteByPrimaryKey(Long id){
return urlListDao.deleteByPrimaryKey(id);
}
public int deleteByCateId(Long id)
{
return urlListDao.deleteByCateId(id);
}
}