| | |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.TreeBuildUtils; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu, SysMenu> implements ISysMenuService { |
| | | public class SysMenuServiceImpl implements ISysMenuService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | private final SysMenuMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | |
| | | List<SysMenu> menuList = null; |
| | | // 管理员显示所有菜单信息 |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = list(new LambdaQueryWrapper<SysMenu>() |
| | | menuList = baseMapper.selectList(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) |
| | |
| | | */ |
| | | @Override |
| | | public SysMenu selectMenuById(Long menuId) { |
| | | return getById(menuId); |
| | | return baseMapper.selectById(menuId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean hasChildByMenuId(Long menuId) { |
| | | long result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId)); |
| | | return result > 0; |
| | | return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean checkMenuExistRole(Long menuId) { |
| | | long result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId)); |
| | | return result > 0; |
| | | return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkMenuNameUnique(SysMenu menu) { |
| | | Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | long count = count(new LambdaQueryWrapper<SysMenu>() |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(SysMenu::getParentId, menu.getParentId()) |
| | | .ne(SysMenu::getMenuId, menuId)); |
| | | if (count > 0) { |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |