mirror of https://gitee.com/maxjhandsome/pig
Merge branch 'master' into dev
# Conflicts: # pig-upms/pig-upms-biz/src/main/resources/spy.properties
This commit is contained in:
commit
e8c5b1a8b7
|
@ -122,7 +122,7 @@ public class MenuController {
|
|||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_menu_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return R.ok(sysMenuService.removeMenuById(id));
|
||||
return sysMenuService.removeMenuById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -50,7 +51,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
* @param id 菜单ID
|
||||
* @return true成功,false失败
|
||||
*/
|
||||
Boolean removeMenuById(Integer id);
|
||||
R removeMenuById(Integer id);
|
||||
|
||||
/**
|
||||
* 更新菜单信息
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package com.pig4cloud.pig.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||
|
@ -31,12 +32,12 @@ import com.pig4cloud.pig.admin.service.SysMenuService;
|
|||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -71,16 +72,19 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
|
||||
public Boolean removeMenuById(Integer id) {
|
||||
public R removeMenuById(Integer id) {
|
||||
// 查询父节点为当前节点的节点
|
||||
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query()
|
||||
.lambda().eq(SysMenu::getParentId, id));
|
||||
Assert.isNull(menuList,"菜单含有下级不能删除");
|
||||
|
||||
if (CollUtil.isNotEmpty(menuList)) {
|
||||
return R.failed("菜单含有下级不能删除");
|
||||
}
|
||||
|
||||
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query()
|
||||
.lambda().eq(SysRoleMenu::getMenuId, id));
|
||||
//删除当前菜单及其子菜单
|
||||
return this.removeById(id);
|
||||
return R.ok(this.removeById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue