feat:提交角色授权
This commit is contained in:
@@ -10,6 +10,8 @@ import com.tiesheng.util.service.cache.TsCacheHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class TsCacheService {
|
||||
|
||||
@@ -63,6 +65,17 @@ public class TsCacheService {
|
||||
tsCacheHandler.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取key
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public Set<String> keys(String pattern) {
|
||||
return tsCacheHandler.keys(pattern);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 图形验证码
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.tiesheng.util.service.cache;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface TsCacheHandler {
|
||||
|
||||
String name();
|
||||
@@ -14,4 +16,6 @@ public interface TsCacheHandler {
|
||||
|
||||
void remove(String key);
|
||||
|
||||
Set<String> keys(String prefix);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
@@ -51,5 +53,10 @@ public class TsCacheRedisHandler implements TsCacheHandler {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keys(String prefix) {
|
||||
return redisTemplate.keys(prefix + "*");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.tiesheng.util.service.cache;
|
||||
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.cache.impl.TimedCache;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class, TsCacheTimedHandler.class})
|
||||
public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
@@ -63,5 +67,11 @@ public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
getTimedCache().remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keys(String prefix) {
|
||||
return getTimedCache().keySet().stream().filter(key -> StrUtil.startWith(key, prefix))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.tiesheng.util.service.role;
|
||||
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface TsAuthorityHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 添加所有的权限
|
||||
*
|
||||
* @param groupAuthority
|
||||
* @param pointAuthorityList
|
||||
* @return
|
||||
*/
|
||||
void addRoleAuthority(RoleAuthority groupAuthority, List<RoleAuthority> pointAuthorityList);
|
||||
|
||||
|
||||
/**
|
||||
* 获取权限列表
|
||||
*
|
||||
* @param tokenBean
|
||||
* @return
|
||||
*/
|
||||
List<String> getAuthorities(TokenBean tokenBean);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user