New file |
| | |
| | | package com.dsh.guns.modular.system.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.mapper.MenuMapper; |
| | | import com.dsh.course.model.node.MenuNode; |
| | | import com.dsh.course.model.node.ZTreeNode; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.model.Relation; |
| | | import com.dsh.guns.modular.system.service.IRelationService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.dsh.guns.modular.system.model.Menu; |
| | | import com.dsh.guns.modular.system.service.IMenuService; |
| | | |
| | | /** |
| | | * 菜单服务 |
| | | * |
| | | * @author fengshuonan |
| | | * @date 2017-05-05 22:20 |
| | | */ |
| | | @Service |
| | | public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService { |
| | | |
| | | @Resource |
| | | private MenuMapper menuMapper; |
| | | |
| | | @Override |
| | | public void delMenu(Long menuId) { |
| | | |
| | | //删除菜单 delete menu |
| | | this.menuMapper.deleteById(menuId); |
| | | |
| | | //删除关联的delete relation |
| | | this.menuMapper.deleteRelationByMenu(menuId); |
| | | } |
| | | |
| | | @Override |
| | | public void delMenuContainSubMenus(Long menuId) { |
| | | |
| | | Menu menu = menuMapper.selectById(menuId); |
| | | |
| | | //删除当前菜单 dele current menu |
| | | delMenu(menuId); |
| | | |
| | | //删除所有子菜单 delete all sub menu |
| | | QueryWrapper<Menu> wrapper = new QueryWrapper<>(); |
| | | wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%"); |
| | | List<Menu> menus = menuMapper.selectList(wrapper); |
| | | for (Menu 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); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private IRelationService relationService; |
| | | @Override |
| | | public List<ZTreeNode> menuTreeList() { |
| | | List<ZTreeNode> zTreeNodes = this.baseMapper.menuTreeList(); |
| | | if(UserExt.getUser().getObjectType()==3){ |
| | | List<Relation> list = relationService.list(new LambdaQueryWrapper<Relation>().eq(Relation::getRoleid, 3)); |
| | | List<Long> collect = list.stream().map(Relation::getMenuid).collect(Collectors.toList()); |
| | | zTreeNodes= zTreeNodes.stream().filter(e -> collect.contains(e.getId())).collect(Collectors.toList()); |
| | | } |
| | | return zTreeNodes; |
| | | } |
| | | |
| | | @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<String> roleIds) { |
| | | return this.baseMapper.getMenusByRoleIds(roleIds); |
| | | } |
| | | } |