肖海南权限代码修改

master
wenyu441069198 5 months ago
parent dc41ea4fe3
commit 66cf868588
  1. 27
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsPermissionMapper.java
  2. 13
      src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.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<UmsPermission> {
/**
* 根据后台用户ID获取菜单
*/
// List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
// /**
// * 根据角色ID获取菜单
// */
// List<UmsMenu> getMenuListByRoleId(@Param("roleId") Long roleId);
// /**
// * 根据角色ID获取资源
// */
// List<UmsResource> getResourceListByRoleId(@Param("roleId") Long roleId);
}

@ -1,9 +1,12 @@
package com.teaching.backend.service.umsAdmin.impl; package com.teaching.backend.service.umsAdmin.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.mapper.umsAdmin.UmsRoleMapper;
import com.teaching.backend.model.entity.umsAdmin.UmsPermission;
import com.teaching.backend.model.entity.umsAdmin.UmsRole; import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.service.umsAdmin.UmsRoleService; import com.teaching.backend.service.umsAdmin.UmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
@ -17,6 +20,8 @@ import java.util.stream.Collectors;
@Service @Service
public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper, UmsRole> implements UmsRoleService { public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper, UmsRole> implements UmsRoleService {
@Autowired
private UmsPermissionMapper umsPermissionMapper;
@Override @Override
public List<String> getPermissionList(String roleId) { public List<String> getPermissionList(String roleId) {
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
@ -25,8 +30,12 @@ public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper, UmsRole> impl
UmsRole umsRole = lambdaQuery().eq(UmsRole::getId, role).one(); UmsRole umsRole = lambdaQuery().eq(UmsRole::getId, role).one();
if(umsRole.getStatus() == 1){ if(umsRole.getStatus() == 1){
String[] permissions = umsRole.getPermissionId().split(","); String[] permissions = umsRole.getPermissionId().split(",");
List<String> permissionList = Arrays.stream(permissions).collect(Collectors.toList()); List<String> permissionNameList = new ArrayList<>();
set.addAll(permissionList); for (String permission : permissions) {
UmsPermission umsPermission = umsPermissionMapper.selectById(permission);
permissionNameList.add(umsPermission.getName());
}
set.addAll(permissionNameList);
} }
} }
List<String> permissionList = new ArrayList<>(set); List<String> permissionList = new ArrayList<>(set);

Loading…
Cancel
Save