|
@@ -2,15 +2,12 @@ package com.fjhx.xmhjc.service.column.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.fjhx.xmhjc.entity.column.dto.ColumnArticleSelectDto;
|
|
|
-import com.fjhx.xmhjc.entity.column.po.ColumnMenu;
|
|
|
import com.fjhx.xmhjc.entity.column.po.ColumnMenuSub;
|
|
|
import com.fjhx.xmhjc.entity.column.vo.ColumnArticleVo;
|
|
|
-import com.fjhx.xmhjc.entity.product.po.ProductCategory;
|
|
|
import com.fjhx.xmhjc.mapper.column.ColumnMenuSubMapper;
|
|
|
import com.fjhx.xmhjc.service.column.ColumnArticleService;
|
|
|
import com.fjhx.xmhjc.service.column.ColumnMenuSubService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.ruoyi.common.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.xmhjc.entity.column.vo.ColumnMenuSubVo;
|
|
@@ -88,6 +85,22 @@ public class ColumnMenuSubServiceImpl extends ServiceImpl<ColumnMenuSubMapper, C
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Boolean checkDeleteByMenu(Long id) {
|
|
|
+ //查询子栏目
|
|
|
+ ColumnMenuSubSelectDto columnMenuSubSelectDto = new ColumnMenuSubSelectDto();
|
|
|
+ columnMenuSubSelectDto.setColumnId(id);
|
|
|
+ List<ColumnMenuSubVo> list = getList(columnMenuSubSelectDto);
|
|
|
+ //验证是否有文章
|
|
|
+ long count = list.stream().filter(x -> {
|
|
|
+ return !checkDelete(x.getId());
|
|
|
+ }).count();
|
|
|
+ if (count == 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Boolean checkDelete(Long id) {
|
|
|
ColumnArticleSelectDto columnArticleSelectDto = new ColumnArticleSelectDto();
|
|
|
columnArticleSelectDto.setSubId(id);
|
|
@@ -101,14 +114,15 @@ public class ColumnMenuSubServiceImpl extends ServiceImpl<ColumnMenuSubMapper, C
|
|
|
@Transactional
|
|
|
public void handleColumnMenuSub(Long id, List<ColumnMenuSub> columnMenuSubList) {
|
|
|
//获取已有子栏目
|
|
|
- IWrapper<ColumnMenuSub> wrapper = getWrapper();
|
|
|
- wrapper.eq("cms", ColumnMenuSub::getColumnId,id);
|
|
|
- List<ColumnMenuSubVo> list = this.baseMapper.getList(wrapper);
|
|
|
+ ColumnMenuSubSelectDto dto = new ColumnMenuSubSelectDto();
|
|
|
+ dto.setColumnId(id);
|
|
|
+ List<ColumnMenuSubVo> list = getList(dto);
|
|
|
+
|
|
|
//用于删除子栏目
|
|
|
Map<Long, ColumnMenuSubVo> map = list.stream().collect(Collectors.toMap(ColumnMenuSub::getId, Function.identity()));
|
|
|
|
|
|
//新增修改
|
|
|
- columnMenuSubList.stream().forEach(sub ->{
|
|
|
+ columnMenuSubList.forEach(sub ->{
|
|
|
sub.setColumnId(id);
|
|
|
//判断新增修改
|
|
|
if (Objects.isNull(sub.getId())){
|
|
@@ -125,6 +139,8 @@ public class ColumnMenuSubServiceImpl extends ServiceImpl<ColumnMenuSubMapper, C
|
|
|
//TODO判断文章
|
|
|
if (checkDelete(key)){
|
|
|
this.removeById(key);
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException(value.getName()+"存在文章,删除失败!如不想显示请禁用");
|
|
|
}
|
|
|
});
|
|
|
|