refactor: 优化部分配置,移除过期类
This commit is contained in:
parent
1dd1be9f23
commit
af9ed39dd8
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
<artifactId>continew-admin</artifactId>
|
<artifactId>continew-admin</artifactId>
|
||||||
@ -59,7 +58,6 @@
|
|||||||
<artifactId>continew-starter-json-jackson</artifactId>
|
<artifactId>continew-starter-json-jackson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- ################ Spring Boot 相关 ################ -->
|
|
||||||
<!-- Java 邮件支持 -->
|
<!-- Java 邮件支持 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
<artifactId>continew-admin</artifactId>
|
<artifactId>continew-admin</artifactId>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
<artifactId>continew-admin</artifactId>
|
<artifactId>continew-admin</artifactId>
|
||||||
|
@ -1,154 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package top.charles7c.cnadmin.auth.config.satoken;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.dao.SaTokenDao;
|
|
||||||
import cn.dev33.satoken.util.SaFoxUtil;
|
|
||||||
|
|
||||||
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sa-Token 持久层本地 Redis 适配(参考:Sa-Token/sa-token-plugin/sa-token-dao-redisx/SaTokenDaoOfRedis.java)
|
|
||||||
*
|
|
||||||
* @author Lion Li(<a href="https://gitee.com/dromara/RuoYi-Vue-Plus">RuoYi-Vue-Plus</a>)
|
|
||||||
* @author Charles7c
|
|
||||||
* @since 2022/12/28 22:55
|
|
||||||
*/
|
|
||||||
public class SaTokenRedisDaoImpl implements SaTokenDao {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(String key) {
|
|
||||||
return RedisUtils.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(String key, String value, long timeout) {
|
|
||||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 判断是否为永不过期
|
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
RedisUtils.set(key, value);
|
|
||||||
} else {
|
|
||||||
RedisUtils.set(key, value, Duration.ofSeconds(timeout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(String key, String value) {
|
|
||||||
long expire = getTimeout(key);
|
|
||||||
// -2:无此键
|
|
||||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.set(key, value, expire);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String key) {
|
|
||||||
RedisUtils.delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getTimeout(String key) {
|
|
||||||
long timeout = RedisUtils.getTimeToLive(key);
|
|
||||||
return timeout < 0 ? timeout : timeout / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTimeout(String key, long timeout) {
|
|
||||||
// 判断是否想要设置为永久
|
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
long expire = getTimeout(key);
|
|
||||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
// 如果其已经被设置为永久,则不作任何处理
|
|
||||||
} else {
|
|
||||||
// 如果尚未被设置为永久,那么再次 set 一次
|
|
||||||
this.set(key, this.get(key), timeout);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RedisUtils.expire(key, Duration.ofSeconds(timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getObject(String key) {
|
|
||||||
return RedisUtils.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setObject(String key, Object object, long timeout) {
|
|
||||||
if (0 == timeout || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 判断是否为永不过期
|
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
RedisUtils.set(key, object);
|
|
||||||
} else {
|
|
||||||
RedisUtils.set(key, object, Duration.ofSeconds(timeout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateObject(String key, Object object) {
|
|
||||||
long expire = getObjectTimeout(key);
|
|
||||||
// -2:无此键
|
|
||||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.setObject(key, object, expire);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteObject(String key) {
|
|
||||||
RedisUtils.delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getObjectTimeout(String key) {
|
|
||||||
long timeout = RedisUtils.getTimeToLive(key);
|
|
||||||
return timeout < 0 ? timeout : timeout / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateObjectTimeout(String key, long timeout) {
|
|
||||||
// 判断是否想要设置为永久
|
|
||||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
long expire = getObjectTimeout(key);
|
|
||||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
|
||||||
// 如果其已经被设置为永久,则不作任何处理
|
|
||||||
} else {
|
|
||||||
// 如果尚未被设置为永久,那么再次 set 一次
|
|
||||||
this.setObject(key, this.getObject(key), timeout);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RedisUtils.expire(key, Duration.ofSeconds(timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) {
|
|
||||||
Collection<String> keys = RedisUtils.keys(String.format("%s*%s*", prefix, keyword));
|
|
||||||
List<String> list = new ArrayList<>(keys);
|
|
||||||
return SaFoxUtil.searchList(list, start, size, sortType);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
<artifactId>continew-admin</artifactId>
|
<artifactId>continew-admin</artifactId>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.charles7c.continew</groupId>
|
<groupId>top.charles7c.continew</groupId>
|
||||||
<artifactId>continew-admin</artifactId>
|
<artifactId>continew-admin</artifactId>
|
||||||
|
@ -104,10 +104,10 @@ sa-token:
|
|||||||
## 扩展配置
|
## 扩展配置
|
||||||
extension:
|
extension:
|
||||||
enabled: true
|
enabled: true
|
||||||
# 自定义缓存实现
|
|
||||||
dao-impl: top.charles7c.cnadmin.auth.config.satoken.SaTokenRedisDaoImpl
|
|
||||||
# 权限认证实现
|
# 权限认证实现
|
||||||
permission-impl: top.charles7c.cnadmin.auth.config.satoken.SaTokenPermissionImpl
|
permission-impl: top.charles7c.cnadmin.auth.config.satoken.SaTokenPermissionImpl
|
||||||
|
# 持久层配置
|
||||||
|
dao.type: redis
|
||||||
|
|
||||||
--- ### MyBatis Plus 配置
|
--- ### MyBatis Plus 配置
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
2
pom.xml
2
pom.xml
@ -39,7 +39,7 @@
|
|||||||
<easyexcel.version>3.3.2</easyexcel.version>
|
<easyexcel.version>3.3.2</easyexcel.version>
|
||||||
<ip2region.version>3.1.5.1</ip2region.version>
|
<ip2region.version>3.1.5.1</ip2region.version>
|
||||||
|
|
||||||
<!-- Maven Plugin Versions -->
|
<!-- Maven Plugin Versions -->
|
||||||
<spotless.version>2.40.0</spotless.version>
|
<spotless.version>2.40.0</spotless.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user