diff --git a/src/main/java/net/mingsoft/cms/action/CategoryAction.java b/src/main/java/net/mingsoft/cms/action/CategoryAction.java index ad7761b6..729253ea 100644 --- a/src/main/java/net/mingsoft/cms/action/CategoryAction.java +++ b/src/main/java/net/mingsoft/cms/action/CategoryAction.java @@ -204,11 +204,9 @@ public class CategoryAction extends BaseAction{ @LogAnn(title = "删除分类", businessType = BusinessTypeEnum.DELETE) @RequiresPermissions("cms:category:del") public ResultData delete(@RequestBody List categorys,HttpServletResponse response, HttpServletRequest request) { - int[] ids = new int[categorys.size()]; for(int i = 0;i categoryList = categoryBiz.queryChilds(_category); + for(CategoryEntity item:categoryList){ + if(item.getId().equals(category.getCategoryId())){ + return ResultData.build().error(getResString("cannot.select.child")); + } + } category.setAppId(BasicUtil.getAppId()); categoryBiz.updateEntity(category); return ResultData.build().success(category); diff --git a/src/main/java/net/mingsoft/cms/biz/ICategoryBiz.java b/src/main/java/net/mingsoft/cms/biz/ICategoryBiz.java index fbb08fc6..32907751 100644 --- a/src/main/java/net/mingsoft/cms/biz/ICategoryBiz.java +++ b/src/main/java/net/mingsoft/cms/biz/ICategoryBiz.java @@ -24,4 +24,6 @@ public interface ICategoryBiz extends IBaseBiz { void saveEntity(CategoryEntity entity); void updateEntity(CategoryEntity entity); + + void delete(int categoryId); } \ No newline at end of file diff --git a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java index bd578ed7..02f2c205 100644 --- a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java +++ b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java @@ -128,4 +128,22 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { super.updateEntity(entity); setChildParentId(entity); } + + @Override + public void delete(int categoryId) { + // TODO Auto-generated method stub + CategoryEntity category = (CategoryEntity) categoryDao.getEntity(categoryId); + //删除父类 + if(category != null){ + category.setCategoryParentId(null); + List childrenList = categoryDao.queryChildren(category); + int[] ids = new int[childrenList.size()]; + for(int i = 0; i < childrenList.size(); i++){ + //删除子类 + ids[i] = Integer.parseInt(childrenList.get(i).getId()); + } + categoryDao.delete(ids); + deleteEntity(categoryId); + } + } } \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/manager/cms/category/form.ftl b/src/main/webapp/WEB-INF/manager/cms/category/form.ftl index 16c6e796..6cc15956 100644 --- a/src/main/webapp/WEB-INF/manager/cms/category/form.ftl +++ b/src/main/webapp/WEB-INF/manager/cms/category/form.ftl @@ -38,7 +38,13 @@ gutter="0" justify="start" align="top"> - + + @@ -63,7 +69,7 @@ gutter="0" justify="start" align="top"> - + - + + - + + - 保存 - 返回 + 返回 @@ -24,7 +23,7 @@ - + - + { if (valid) { that.saveDisabled = true; + if(that.categoryIdOptions.filter(f => f['id'] == that.form.contentCategoryId)[0].categoryType == '2'){ + that.$notify({ + title: '提示', + message: '所属栏目不能为封面', + type: 'error' + }); + that.saveDisabled = false; + return + } var data = JSON.parse(JSON.stringify(that.form)); if(data.contentType !=null){ data.contentType = data.contentType.join(','); @@ -389,6 +397,12 @@ res.data.contentImg = [] } that.form = res.data; + var category = that.categoryIdOptions.filter(f => f['id'] == that.form.contentCategoryId); + if(category.length == 1){ + if(category[0].categoryType == '2'){ + that.returnIsShow = false; + } + } that.changeModel(); } }).catch(function (err) { @@ -401,7 +415,7 @@ ms.http.get(ms.manager + "/cms/category/list.do", {pageSize: 9999}).then(function (res) { if (res.result) { that.contentCategoryIdOptions = ms.util.treeData(res.data.rows, 'id', 'categoryId', 'children'); - that.categoryIdOptions = res.data.rows + that.categoryIdOptions = res.data.rows; that.changeModel(); } }).catch(function (err) {