From 25cfb72798d73a9c80aed43e05058bbdee34a417 Mon Sep 17 00:00:00 2001 From: xierz Date: Mon, 23 Nov 2020 11:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=AD=90=E6=A0=8F=E7=9B=AE?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mingsoft/cms/action/CategoryAction.java | 21 ++++++++++----- .../cms/biz/impl/CategoryBizImpl.java | 2 +- .../WEB-INF/manager/cms/category/index.ftl | 27 +++++++++++++++++++ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/mingsoft/cms/action/CategoryAction.java b/src/main/java/net/mingsoft/cms/action/CategoryAction.java index 5d7eb8fb..1b35298b 100644 --- a/src/main/java/net/mingsoft/cms/action/CategoryAction.java +++ b/src/main/java/net/mingsoft/cms/action/CategoryAction.java @@ -27,6 +27,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.Optional; /** * 分类管理控制层 @@ -180,7 +181,7 @@ public class CategoryAction extends BaseAction { } /** - * @param category 分类实体 + * @param categorys 分类实体 */ @ApiOperation(value = "批量删除分类列表接口") @PostMapping("/delete") @@ -295,12 +296,18 @@ public class CategoryAction extends BaseAction { @ApiOperation(value = "批量更新模版") @GetMapping("/updateTemplate") @ResponseBody - public ResultData updateTemplate(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){ - - //父栏目是列表 - - //父栏目是封面 - + public ResultData updateTemplate(@ModelAttribute @ApiIgnore CategoryEntity category){ + category = categoryBiz.getById(category.getId()); + List childs = categoryBiz.queryChilds(category); + //更新与父节点相同类型的子栏目的模板内容 + for (int i =0; i < childs.size(); i++) { + if (childs.get(i).getCategoryType().equals(category.getCategoryType())) { + childs.get(i).setCategoryUrl(category.getCategoryUrl()); + childs.get(i).setCategoryListUrl(category.getCategoryListUrl()); + categoryBiz.updateEntity(childs.get(i)); + } + } return ResultData.build().success(); } + } 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 4edf39be..89e7f193 100644 --- a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java +++ b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java @@ -202,7 +202,7 @@ public class CategoryBizImpl extends BaseBizImpl i Assert.notNull(entity); CategoryEntity categoryEntity = getById(entity.getId()); //如果父级不为空并且修改了父级则需要更新父级 - if(!entity.getCategoryId().equals(categoryEntity.getCategoryId())){ + if(entity.getCategoryId() != null && !entity.getCategoryId().equals(categoryEntity.getCategoryId())){ //更新旧的父级 if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){ CategoryEntity parent = getById(categoryEntity.getCategoryId()); diff --git a/src/main/webapp/WEB-INF/manager/cms/category/index.ftl b/src/main/webapp/WEB-INF/manager/cms/category/index.ftl index 2e404c36..0de11ccd 100644 --- a/src/main/webapp/WEB-INF/manager/cms/category/index.ftl +++ b/src/main/webapp/WEB-INF/manager/cms/category/index.ftl @@ -75,6 +75,9 @@ <@shiro.hasPermission name="cms:category:save"> 子栏目 + <@shiro.hasPermission name="cms:category:update"> + 应用子栏目 + <@shiro.hasPermission name="cms:category:update"> 编辑 @@ -143,6 +146,30 @@ } }, methods: { + //应用子栏目模板 + updateTemplate: function(row) { + var that = this; + ms.http.get(ms.manager + "/cms/category/updateTemplate.do", { + id: row.id + }).then(function (res) { + if (res.result) { + that.$notify({ + title: '成功', + message: '应用成功', + type: 'success' + }); + that.list(); + } else { + that.$notify({ + title: '失败', + message: res.msg, + type: 'warning' + }); + } + }).catch(function (err) { + console.log(err); + }); + }, //根据字典数据值获取字典标签名 getDictLabel: function (v) { var that = this;