|
|
|
|
@ -2,6 +2,7 @@ package edu.ncst.award.service.impl.system; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import edu.ncst.award.exception.BusinessException; |
|
|
|
|
import edu.ncst.award.exception.CodeMsg; |
|
|
|
|
import edu.ncst.award.mapper.system.ResourceMapper; |
|
|
|
|
@ -11,6 +12,7 @@ import edu.ncst.award.vo.ListResultVO; |
|
|
|
|
import edu.ncst.award.vo.Query; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.val; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
|
|
@ -28,12 +30,16 @@ import java.lang.reflect.Modifier; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements IResourceService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ResourceMapper resourceMapper; |
|
|
|
|
// @Autowired
|
|
|
|
|
// private IResourceService iResourceService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 欲扫描的包路径
|
|
|
|
|
private static final String SCAN_PACKAGE = "edu.ncst.equmanager.controller"; |
|
|
|
|
@ -42,12 +48,12 @@ public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
* 重新导入接口元信息 |
|
|
|
|
*/ |
|
|
|
|
@Caching( |
|
|
|
|
evict = { |
|
|
|
|
@CacheEvict(cacheNames = "permitAllResourceList"), |
|
|
|
|
@CacheEvict(cacheNames = "userScopeResourceList"), |
|
|
|
|
@CacheEvict(cacheNames = "permitAllResourceURLs"), |
|
|
|
|
@CacheEvict(cacheNames = "userScopeResourceURLs") |
|
|
|
|
} |
|
|
|
|
evict = { |
|
|
|
|
@CacheEvict(cacheNames = "permitAllResourceList"), |
|
|
|
|
@CacheEvict(cacheNames = "userScopeResourceList"), |
|
|
|
|
@CacheEvict(cacheNames = "permitAllResourceURLs"), |
|
|
|
|
@CacheEvict(cacheNames = "userScopeResourceURLs") |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
@Transactional |
|
|
|
|
@Override |
|
|
|
|
@ -159,7 +165,7 @@ public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ApiOperation operationAnnotation = method.getAnnotation(ApiOperation.class); |
|
|
|
|
// LoginUserScope scopeAnnotation = method.getAnnotation(LoginUserScope.class);
|
|
|
|
|
// LoginUserScope scopeAnnotation = method.getAnnotation(LoginUserScope.class);
|
|
|
|
|
PermitAll permitAllAnnotation = method.getAnnotation(PermitAll.class); |
|
|
|
|
|
|
|
|
|
if (operationAnnotation == null || operationAnnotation.hidden()) { |
|
|
|
|
@ -213,8 +219,8 @@ public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
!Objects.equals(newResource.getLabel(), oldResource.getLabel()) || |
|
|
|
|
!Objects.equals(newResource.getMethod(), oldResource.getMethod()) || |
|
|
|
|
!Objects.equals(newResource.getPermitAll(), oldResource.getPermitAll()) || |
|
|
|
|
!Objects.equals(newResource.getUrl(), oldResource.getUrl()) || |
|
|
|
|
!Objects.equals(newResource.getUserScope(), oldResource.getUserScope()); |
|
|
|
|
!Objects.equals(newResource.getUrl(), oldResource.getUrl()); |
|
|
|
|
// || !Objects.equals(newResource.getUserScope(), oldResource.getUserScope());
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -274,6 +280,7 @@ public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 扫描指定包下的所有类 |
|
|
|
|
* |
|
|
|
|
* @return 类对象列表 |
|
|
|
|
*/ |
|
|
|
|
private List<Class<?>> findClassLocal() { |
|
|
|
|
@ -354,11 +361,15 @@ public class ResourceServiceImpl implements IResourceService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取多个角色能够访问的资源列表 |
|
|
|
|
* |
|
|
|
|
* @return 返回一组路径 {”/api“,"/api/project"} |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<String> getRolesResourceList(List<String> roleNames) { |
|
|
|
|
//resourceMapper.getRolesResourceUrls(roleNames);
|
|
|
|
|
return null; |
|
|
|
|
val strings = new ArrayList<String>(); |
|
|
|
|
roleNames.forEach(roleName -> list(new QueryWrapper<Resource>().eq("name", roleName)).forEach(Resource -> strings.add(Resource.getUrl()))); |
|
|
|
|
System.out.println("hello"); |
|
|
|
|
return strings; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|