|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.bsd.cases.constants.Constants;
|
|
|
|
|
import com.bsd.cases.mapper.CaseCategoryMapper;
|
|
|
|
|
import com.bsd.cases.mapper.CaseContentMapper;
|
|
|
|
|
import com.bsd.cases.model.CaseCategory;
|
|
|
|
|
import com.bsd.cases.model.CaseContent;
|
|
|
|
|
import com.bsd.cases.model.CaseUsers;
|
|
|
|
@ -31,6 +32,8 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CaseCategoryMapper caseCategoryMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private CaseContentMapper caseContentMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 直接获取所有1级2级分级
|
|
|
|
@ -195,18 +198,34 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
|
|
|
|
|
public AjaxResult delCategory(Long categoryId) {
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(categoryId);
|
|
|
|
|
Integer count;
|
|
|
|
|
if (caseCategory.getState() == Constants.STATE_INVALID){
|
|
|
|
|
ajaxResult.setRetmsg("类别已删除,不可重复操作");
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}else {
|
|
|
|
|
if (3 == caseCategory.getLevel()){
|
|
|
|
|
//判断下级有没有文章
|
|
|
|
|
CaseContent findCaseContent = new CaseContent();
|
|
|
|
|
findCaseContent.setState(Constants.STATE_VALID);
|
|
|
|
|
findCaseContent.setCategoryId(categoryId);
|
|
|
|
|
count = caseContentMapper.selectCount(findCaseContent);
|
|
|
|
|
}else {
|
|
|
|
|
CaseCategory findCaseCategory = new CaseCategory();
|
|
|
|
|
findCaseCategory.setState(Constants.STATE_VALID);
|
|
|
|
|
findCaseCategory.setParentId(categoryId);
|
|
|
|
|
count = caseCategoryMapper.selectCount(findCaseCategory);
|
|
|
|
|
}
|
|
|
|
|
if (count>0){
|
|
|
|
|
ajaxResult.setRetmsg("下级目录有内容,不可删除");
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
caseCategory.setState(Constants.STATE_INVALID);
|
|
|
|
|
caseCategory.setUpdateDateTime(new Date());
|
|
|
|
|
caseCategoryMapper.updateByPrimaryKeySelective(caseCategory);
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
ajaxResult.setRetmsg("成功删除类别");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//待确认
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|