应用子栏目模板

This commit is contained in:
xierz 2020-11-23 11:05:21 +08:00
parent 3582314e47
commit 25cfb72798
3 changed files with 42 additions and 8 deletions

View File

@ -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<CategoryEntity> 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();
}
}

View File

@ -202,7 +202,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> 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());

View File

@ -75,6 +75,9 @@
<@shiro.hasPermission name="cms:category:save">
<el-link type="primary" :underline="false" @click="save(scope.row.id, scope.row.id)"><i class="el-icon-plus"></i>子栏目</el-link>
</@shiro.hasPermission>
<@shiro.hasPermission name="cms:category:update">
<el-link type="primary" :underline="false" v-if="scope.row.categoryType == '1' || scope.row.categoryType == '2'" @click="updateTemplate(scope.row)">应用子栏目</el-link>
</@shiro.hasPermission>
<@shiro.hasPermission name="cms:category:update">
<el-link type="primary" :underline="false" @click="save(scope.row.id)">编辑</el-link>
</@shiro.hasPermission>
@ -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;