处理角色禁用问题

This commit is contained in:
TinyAnts 2022-09-16 10:23:08 +08:00
parent bdf1303854
commit 33ba157244
1 changed files with 16 additions and 0 deletions

View File

@ -5,8 +5,10 @@ import com.mdd.admin.config.AdminConfig;
import com.mdd.admin.service.system.ISystemAuthPermService;
import com.mdd.common.entity.system.SystemAuthMenu;
import com.mdd.common.entity.system.SystemAuthPerm;
import com.mdd.common.entity.system.SystemAuthRole;
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
import com.mdd.common.mapper.system.SystemAuthPermMapper;
import com.mdd.common.mapper.system.SystemAuthRoleMapper;
import com.mdd.common.utils.ArrayUtil;
import com.mdd.common.utils.RedisUtil;
import com.mdd.common.utils.StringUtil;
@ -30,6 +32,9 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
@Resource
SystemAuthMenuMapper systemAuthMenuMapper;
@Resource
SystemAuthRoleMapper systemAuthRoleMapper;
/**
* 根据角色ID获取菜单ID
*
@ -39,11 +44,22 @@ public class SystemAuthPermServiceImpl implements ISystemAuthPermService {
@Override
public List<Integer> selectMenuIdsByRoleId(Integer roleId) {
List<Integer> menus = new LinkedList<>();
SystemAuthRole systemAuthRole = systemAuthRoleMapper.selectOne(new QueryWrapper<SystemAuthRole>()
.eq("id", roleId)
.eq("is_disable", 0)
.last("limit 1"));
if (StringUtil.isNull(systemAuthRole)) {
return menus;
}
List<SystemAuthPerm> systemAuthPerms = systemAuthPermMapper.selectList(
new QueryWrapper<SystemAuthPerm>().eq("role_id", roleId));
for (SystemAuthPerm systemAuthPerm : systemAuthPerms) {
menus.add(systemAuthPerm.getMenuId());
}
return menus;
}