优化代码
This commit is contained in:
parent
0f09fce119
commit
550c1b4861
|
@ -1,7 +1,7 @@
|
||||||
package net.maku.system.service.impl;
|
package net.maku.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.constant.Constant;
|
import net.maku.framework.common.constant.Constant;
|
||||||
import net.maku.framework.common.exception.FastException;
|
import net.maku.framework.common.exception.FastException;
|
||||||
|
@ -48,7 +48,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
SysMenuEntity entity = SysMenuConvert.INSTANCE.convert(vo);
|
SysMenuEntity entity = SysMenuConvert.INSTANCE.convert(vo);
|
||||||
|
|
||||||
// 上级菜单不能为自己
|
// 上级菜单不能为自己
|
||||||
if(entity.getId().equals(entity.getPid())){
|
if (entity.getId().equals(entity.getPid())) {
|
||||||
throw new FastException("上级菜单不能为自己");
|
throw new FastException("上级菜单不能为自己");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +78,9 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
List<SysMenuEntity> menuList;
|
List<SysMenuEntity> menuList;
|
||||||
|
|
||||||
// 系统管理员,拥有最高权限
|
// 系统管理员,拥有最高权限
|
||||||
if(user.getSuperAdmin().equals(SuperAdminEnum.YES.getValue())){
|
if (user.getSuperAdmin().equals(SuperAdminEnum.YES.getValue())) {
|
||||||
menuList = baseMapper.getMenuList(type);
|
menuList = baseMapper.getMenuList(type);
|
||||||
}else {
|
} else {
|
||||||
menuList = baseMapper.getUserMenuList(user.getId(), type);
|
menuList = baseMapper.getUserMenuList(user.getId(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,23 +89,23 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getSubMenuCount(Long pid) {
|
public Long getSubMenuCount(Long pid) {
|
||||||
return count(new QueryWrapper<SysMenuEntity>().eq("pid", pid));
|
return count(new LambdaQueryWrapper<SysMenuEntity>().eq(SysMenuEntity::getPid, pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getUserAuthority(UserDetail user) {
|
public Set<String> getUserAuthority(UserDetail user) {
|
||||||
// 系统管理员,拥有最高权限
|
// 系统管理员,拥有最高权限
|
||||||
List<String> authorityList;
|
List<String> authorityList;
|
||||||
if(user.getSuperAdmin().equals(SuperAdminEnum.YES.getValue())) {
|
if (user.getSuperAdmin().equals(SuperAdminEnum.YES.getValue())) {
|
||||||
authorityList = baseMapper.getAuthorityList();
|
authorityList = baseMapper.getAuthorityList();
|
||||||
}else{
|
} else {
|
||||||
authorityList = baseMapper.getUserAuthorityList(user.getId());
|
authorityList = baseMapper.getUserAuthorityList(user.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户权限列表
|
// 用户权限列表
|
||||||
Set<String> permsSet = new HashSet<>();
|
Set<String> permsSet = new HashSet<>();
|
||||||
for(String authority : authorityList){
|
for (String authority : authorityList) {
|
||||||
if(StrUtil.isBlank(authority)){
|
if (StrUtil.isBlank(authority)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
permsSet.addAll(Arrays.asList(authority.trim().split(",")));
|
permsSet.addAll(Arrays.asList(authority.trim().split(",")));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user