diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsPermissionMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsPermissionMapper.java new file mode 100644 index 0000000..17a8695 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsPermissionMapper.java @@ -0,0 +1,27 @@ +package com.teaching.backend.mapper.umsAdmin; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.umsAdmin.UmsPermission; +import com.teaching.backend.model.entity.umsAdmin.UmsRole; +import org.apache.ibatis.annotations.Mapper; + +/** + * 后台角色管理自定义Dao + * Created by macro on 2020/2/2. + */ +@Mapper +public interface UmsPermissionMapper extends BaseMapper { + /** + * 根据后台用户ID获取菜单 + */ +// List getMenuList(@Param("adminId") Long adminId); +// /** +// * 根据角色ID获取菜单 +// */ +// List getMenuListByRoleId(@Param("roleId") Long roleId); +// /** +// * 根据角色ID获取资源 +// */ +// List getResourceListByRoleId(@Param("roleId") Long roleId); +} diff --git a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.java b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.java index 63a5180..8b65d65 100644 --- a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.java @@ -1,9 +1,12 @@ package com.teaching.backend.service.umsAdmin.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.umsAdmin.UmsPermissionMapper; import com.teaching.backend.mapper.umsAdmin.UmsRoleMapper; +import com.teaching.backend.model.entity.umsAdmin.UmsPermission; import com.teaching.backend.model.entity.umsAdmin.UmsRole; import com.teaching.backend.service.umsAdmin.UmsRoleService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @@ -17,6 +20,8 @@ import java.util.stream.Collectors; @Service public class UmsRoleServiceImpl extends ServiceImpl implements UmsRoleService { + @Autowired + private UmsPermissionMapper umsPermissionMapper; @Override public List getPermissionList(String roleId) { Set set = new HashSet<>(); @@ -25,8 +30,12 @@ public class UmsRoleServiceImpl extends ServiceImpl impl UmsRole umsRole = lambdaQuery().eq(UmsRole::getId, role).one(); if(umsRole.getStatus() == 1){ String[] permissions = umsRole.getPermissionId().split(","); - List permissionList = Arrays.stream(permissions).collect(Collectors.toList()); - set.addAll(permissionList); + List permissionNameList = new ArrayList<>(); + for (String permission : permissions) { + UmsPermission umsPermission = umsPermissionMapper.selectById(permission); + permissionNameList.add(umsPermission.getName()); + } + set.addAll(permissionNameList); } } List permissionList = new ArrayList<>(set);