zoukankan      html  css  js  c++  java
  • 连表删除例子

    package com.zjdfwl.mall.modular.sys.service.impl;
    
    import com.zjdfwl.mall.modular.sys.model.SysMenu;
    import com.zjdfwl.mall.core.node.MenuNode;
    import com.zjdfwl.mall.core.node.ZTreeNode;
    import com.zjdfwl.mall.modular.sys.dao.SysMenuMapper;
    import com.zjdfwl.mall.modular.sys.service.ISysMenuService;
    import com.baomidou.mybatisplus.mapper.EntityWrapper;
    import com.baomidou.mybatisplus.mapper.Wrapper;
    import com.baomidou.mybatisplus.service.impl.ServiceImpl;
    
    import java.util.List;
    import java.util.Map;
    
    import javax.annotation.Resource;
    
    import org.springframework.stereotype.Service;
    
    /**
     * <p>
     * 菜单表 服务实现类
     * </p>
     *
     * @author stylefeng123
     * @since 2018-04-12
     */
    @Service
    public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
    
        @Resource
        private SysMenuMapper menuMapper;
    
        @Override
        public void delMenu(Long menuId) {
    
            //删除菜单
            this.menuMapper.deleteById(menuId);
    
            //删除关联的relation
            this.menuMapper.deleteRelationByMenu(menuId);
        }
    
        @Override
        public void delMenuContainSubMenus(Long menuId) {
    
            SysMenu menu = menuMapper.selectById(menuId);
    
            //删除当前菜单
            delMenu(menuId);
    
            //删除所有子菜单
            Wrapper<SysMenu> wrapper = new EntityWrapper<>();
            wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%");
            List<SysMenu> menus = menuMapper.selectList(wrapper);
            for (SysMenu temp : menus) {
                delMenu(temp.getId());
            }
        }
    
        @Override
        public List<Map<String, Object>> selectMenus(String condition, String level) {
            return this.baseMapper.selectMenus(condition, level);
        }
    
        @Override
        public List<Long> getMenuIdsByRoleId(Integer roleId) {
            return this.baseMapper.getMenuIdsByRoleId(roleId);
        }
    
        @Override
        public List<ZTreeNode> menuTreeList() {
            return this.baseMapper.menuTreeList();
        }
    
        @Override
        public List<ZTreeNode> menuTreeListByMenuIds(List<Long> menuIds) {
            return this.baseMapper.menuTreeListByMenuIds(menuIds);
        }
    
        @Override
        public int deleteRelationByMenu(Long menuId) {
            return this.baseMapper.deleteRelationByMenu(menuId);
        }
    
        @Override
        public List<String> getResUrlsByRoleId(Integer roleId) {
            return this.baseMapper.getResUrlsByRoleId(roleId);
        }
    
        @Override
        public List<MenuNode> getMenusByRoleIds(List<Integer> roleIds) {
            return this.baseMapper.getMenusByRoleIds(roleIds);
        }
    }
  • 相关阅读:
    单元测试-伪对象、桩对象、模拟对象
    单元测试那些事
    vscode 开发go版本1.14项目
    C#中的 async await
    一手遮天 Android
    一手遮天 Android
    一手遮天 Android
    一手遮天 Android
    一手遮天 Android
    一手遮天 Android
  • 原文地址:https://www.cnblogs.com/dianzan/p/11281933.html
Copyright © 2011-2022 走看看