Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
224b5e5db7
|
@ -16,6 +16,7 @@ import net.mingsoft.basic.util.PinYinUtil;
|
||||||
import net.mingsoft.basic.util.StringUtil;
|
import net.mingsoft.basic.util.StringUtil;
|
||||||
import net.mingsoft.cms.biz.ICategoryBiz;
|
import net.mingsoft.cms.biz.ICategoryBiz;
|
||||||
import net.mingsoft.cms.entity.CategoryEntity;
|
import net.mingsoft.cms.entity.CategoryEntity;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -180,7 +181,7 @@ public class CategoryAction extends BaseAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param category 分类实体
|
* @param categorys 分类实体
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "批量删除分类列表接口")
|
@ApiOperation(value = "批量删除分类列表接口")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
|
@ -295,12 +296,35 @@ public class CategoryAction extends BaseAction {
|
||||||
@ApiOperation(value = "批量更新模版")
|
@ApiOperation(value = "批量更新模版")
|
||||||
@GetMapping("/updateTemplate")
|
@GetMapping("/updateTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResultData updateTemplate(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){
|
@RequiresPermissions("cms:category:update")
|
||||||
|
public ResultData updateTemplate(@ModelAttribute @ApiIgnore CategoryEntity category){
|
||||||
//父栏目是列表
|
if (category ==null || StringUtils.isEmpty(category.getId())) {
|
||||||
|
return ResultData.build().error(getResString("err.error", this.getResString("id")));
|
||||||
//父栏目是封面
|
}
|
||||||
|
category = categoryBiz.getById(category.getId());
|
||||||
|
category.setCategoryParentId(null);
|
||||||
|
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();
|
return ResultData.build().success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "复制栏目")
|
||||||
|
@GetMapping("/copyCategory")
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("cms:category:save")
|
||||||
|
public ResultData copyCategory(@ModelAttribute @ApiIgnore CategoryEntity category){
|
||||||
|
if (category == null || StringUtils.isEmpty(category.getId())) {
|
||||||
|
return ResultData.build().error(getResString("err.error", this.getResString("id")));
|
||||||
|
}
|
||||||
|
categoryBiz.copyCategory(category);
|
||||||
|
return ResultData.build().success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,6 @@ public interface ICategoryBiz extends IBaseBiz<CategoryEntity> {
|
||||||
void update(CategoryEntity entity);
|
void update(CategoryEntity entity);
|
||||||
|
|
||||||
void delete(String categoryId);
|
void delete(String categoryId);
|
||||||
|
|
||||||
|
void copyCategory(CategoryEntity entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
||||||
Assert.notNull(entity);
|
Assert.notNull(entity);
|
||||||
CategoryEntity categoryEntity = getById(entity.getId());
|
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())){
|
if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){
|
||||||
CategoryEntity parent = getById(categoryEntity.getCategoryId());
|
CategoryEntity parent = getById(categoryEntity.getCategoryId());
|
||||||
|
@ -244,4 +244,41 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
||||||
}
|
}
|
||||||
entity.setTopId("0");
|
entity.setTopId("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copyCategory(CategoryEntity category) {
|
||||||
|
String oldId = category.getId();
|
||||||
|
//先保存被复制第一层栏目,因为第一层栏目不需要变更父级栏目
|
||||||
|
category = getById(oldId);
|
||||||
|
//id、拼音和路径按照原来的业务逻辑生成
|
||||||
|
category.setId(null);
|
||||||
|
category.setCategoryPinyin(null);
|
||||||
|
category.setCategoryPath(null);
|
||||||
|
saveEntity(category);
|
||||||
|
//传入简要被复制子栏目的id和复制后的生成的id,复制的子栏目全部使用
|
||||||
|
recursionCopyChilds(oldId, category.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 递归复制子栏目
|
||||||
|
* @param oldParentId:被复制的父级栏目id(需要数据库原来存在该数据)
|
||||||
|
* @param newParentId:复制栏目后新父级的id(新插入数据的id)
|
||||||
|
* */
|
||||||
|
private void recursionCopyChilds(String oldParentId, String newParentId) {
|
||||||
|
CategoryEntity _category = new CategoryEntity();
|
||||||
|
_category.setCategoryId(oldParentId);
|
||||||
|
List<CategoryEntity> childs = query(_category);
|
||||||
|
for (CategoryEntity child : childs) {
|
||||||
|
String childId = child.getId();
|
||||||
|
//id、拼音和路径按照原来的业务逻辑生成
|
||||||
|
child.setId(null);
|
||||||
|
child.setCategoryPinyin(null);
|
||||||
|
child.setCategoryPath(null);
|
||||||
|
child.setCategoryId(newParentId);
|
||||||
|
saveEntity(child);
|
||||||
|
//如果该栏目下还有子栏目则继续复制该栏目里的子栏目
|
||||||
|
recursionCopyChilds(childId, child.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,12 @@
|
||||||
<@shiro.hasPermission name="cms:category:save">
|
<@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>
|
<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>
|
||||||
|
<@shiro.hasPermission name="cms:category:save">
|
||||||
|
<el-link type="primary" :underline="false" @click="copyCategory(scope.row.id)">克隆</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.id)">应用子栏目</el-link>-->
|
||||||
|
<#-- </@shiro.hasPermission>-->
|
||||||
<@shiro.hasPermission name="cms:category:update">
|
<@shiro.hasPermission name="cms:category:update">
|
||||||
<el-link type="primary" :underline="false" @click="save(scope.row.id)">编辑</el-link>
|
<el-link type="primary" :underline="false" @click="save(scope.row.id)">编辑</el-link>
|
||||||
</@shiro.hasPermission>
|
</@shiro.hasPermission>
|
||||||
|
@ -143,6 +149,54 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//复制栏目
|
||||||
|
copyCategory: function(id) {
|
||||||
|
var that = this;
|
||||||
|
ms.http.get(ms.manager + "/cms/category/copyCategory.do", {
|
||||||
|
id: 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);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//应用子栏目模板
|
||||||
|
updateTemplate: function(id) {
|
||||||
|
var that = this;
|
||||||
|
ms.http.get(ms.manager + "/cms/category/updateTemplate.do", {
|
||||||
|
id: 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) {
|
getDictLabel: function (v) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
Loading…
Reference in New Issue