service层
/*
* 删除内容分类
*/
TaotaoResult deleteContentCategory(Long id);
service.impl
@Override
public TaotaoResult deleteContentCategory(Long id) {
// TODO Auto-generated method stub
TbContentCategory contentCategory = contentCategoryMapper.selectByPrimaryKey(id);
if (contentCategory.getIsParent()) {
List<EUTreeNode> list = getCategoryList(id);
// 递归删除
for (EUTreeNode tbcontentCategory : list) {
deleteContentCategory(tbcontentCategory.getId());
}
}
if (getCategoryList(contentCategory.getParentId()).size() == 1) {
TbContentCategory parentCategory = contentCategoryMapper
.selectByPrimaryKey(contentCategory.getParentId());
parentCategory.setIsParent(false);
contentCategoryMapper.updateByPrimaryKey(parentCategory);
}
contentCategoryMapper.deleteByPrimaryKey(id);
return TaotaoResult.ok();
}
controller
@RequestMapping("/content/category/delete")
@ResponseBody
public TaotaoResult deleteNode(Long id){
TaotaoResult result=contentCategoryService.deleteContentCategory(id);
return result;
}