mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-14 22:49:33 +08:00
⚡ 新建blade-starter-tenant与blade-starter-cache
This commit is contained in:
parent
362c4cbc66
commit
d5bfa065ee
@ -51,6 +51,10 @@
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-secure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-log</artifactId>
|
||||
@ -59,6 +63,10 @@
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant</artifactId>
|
||||
</dependency>
|
||||
<!--MyBatis-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
|
@ -26,6 +26,7 @@ import java.util.concurrent.Callable;
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Deprecated
|
||||
public class CacheUtil {
|
||||
|
||||
public static final String SYS_CACHE = "blade:sys";
|
||||
|
27
blade-starter-cache/pom.xml
Normal file
27
blade-starter-cache/pom.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>blade-starter-cache</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<module.name>org.springblade.blade.starter.cache</module.name>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!--Blade-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-tool</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
29
blade-starter-cache/src/main/java/org/springblade/core/cache/config/CacheConfiguration.java
vendored
Normal file
29
blade-starter-cache/src/main/java/org/springblade/core/cache/config/CacheConfiguration.java
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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 org.springblade.core.cache.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
|
||||
/**
|
||||
* Cache配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@EnableCaching
|
||||
@AutoConfiguration
|
||||
public class CacheConfiguration {
|
||||
}
|
51
blade-starter-cache/src/main/java/org/springblade/core/cache/constant/CacheConstant.java
vendored
Normal file
51
blade-starter-cache/src/main/java/org/springblade/core/cache/constant/CacheConstant.java
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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 org.springblade.core.cache.constant;
|
||||
|
||||
/**
|
||||
* 缓存名
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface CacheConstant {
|
||||
|
||||
String BIZ_CACHE = "blade:biz";
|
||||
|
||||
String MENU_CACHE = "blade:menu";
|
||||
|
||||
String USER_CACHE = "blade:user";
|
||||
|
||||
String DICT_CACHE = "blade:dict";
|
||||
|
||||
String FLOW_CACHE = "blade:flow";
|
||||
|
||||
String SYS_CACHE = "blade:sys";
|
||||
|
||||
String RESOURCE_CACHE = "blade:resource";
|
||||
|
||||
String PARAM_CACHE = "blade:param";
|
||||
|
||||
String DEFAULT_CACHE = "default:cache";
|
||||
|
||||
String RETRY_LIMIT_CACHE = "retry:limit:cache";
|
||||
|
||||
String HALF_HOUR = "half:hour";
|
||||
|
||||
String HOUR = "hour";
|
||||
|
||||
String ONE_DAY = "one:day";
|
||||
|
||||
}
|
152
blade-starter-cache/src/main/java/org/springblade/core/cache/utils/CacheUtil.java
vendored
Normal file
152
blade-starter-cache/src/main/java/org/springblade/core/cache/utils/CacheUtil.java
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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 org.springblade.core.cache.utils;
|
||||
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* 缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class CacheUtil {
|
||||
|
||||
public static final String SYS_CACHE = "blade:sys";
|
||||
|
||||
private static CacheManager cacheManager;
|
||||
|
||||
/**
|
||||
* 获取缓存工具
|
||||
*
|
||||
* @return CacheManager
|
||||
*/
|
||||
private static CacheManager getCacheManager() {
|
||||
if (cacheManager == null) {
|
||||
cacheManager = SpringUtil.getBean(CacheManager.class);
|
||||
}
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存对象
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @return Cache
|
||||
*/
|
||||
public static Cache getCache(String cacheName) {
|
||||
return getCacheManager().getCache(cacheName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param keyPrefix 缓存键前缀
|
||||
* @param key 缓存键值
|
||||
* @return Cache
|
||||
*/
|
||||
@Nullable
|
||||
public static Object get(String cacheName, String keyPrefix, Object key) {
|
||||
if (Func.hasEmpty(cacheName, keyPrefix, key)) {
|
||||
return null;
|
||||
}
|
||||
Cache.ValueWrapper wrapper = getCache(cacheName).get(keyPrefix.concat(String.valueOf(key)));
|
||||
return wrapper == null ? null : wrapper.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param keyPrefix 缓存键前缀
|
||||
* @param key 缓存键值
|
||||
* @param type 转换类型
|
||||
* @param <T> 类型
|
||||
* @return Cache
|
||||
*/
|
||||
@Nullable
|
||||
public static <T> T get(String cacheName, String keyPrefix, Object key, @Nullable Class<T> type) {
|
||||
if (Func.hasEmpty(cacheName, keyPrefix, key)) {
|
||||
return null;
|
||||
}
|
||||
return getCache(cacheName).get(keyPrefix.concat(String.valueOf(key)), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param keyPrefix 缓存键前缀
|
||||
* @param key 缓存键值
|
||||
* @param valueLoader 重载对象
|
||||
* @param <T> 类型
|
||||
* @return Cache
|
||||
*/
|
||||
@Nullable
|
||||
public static <T> T get(String cacheName, String keyPrefix, Object key, Callable<T> valueLoader) {
|
||||
if (Func.hasEmpty(cacheName, keyPrefix, key)) {
|
||||
return null;
|
||||
}
|
||||
String cacheKey = keyPrefix.concat(String.valueOf(key));
|
||||
return getCache(cacheName).get(cacheKey, valueLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param keyPrefix 缓存键前缀
|
||||
* @param key 缓存键值
|
||||
* @param value 缓存值
|
||||
*/
|
||||
public static void put(String cacheName, String keyPrefix, Object key, @Nullable Object value) {
|
||||
getCache(cacheName).put(keyPrefix.concat(String.valueOf(key)), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param keyPrefix 缓存键前缀
|
||||
* @param key 缓存键值
|
||||
*/
|
||||
public static void evict(String cacheName, String keyPrefix, Object key) {
|
||||
if (Func.hasEmpty(cacheName, keyPrefix, key)) {
|
||||
return;
|
||||
}
|
||||
getCache(cacheName).evict(keyPrefix.concat(String.valueOf(key)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
*/
|
||||
public static void clear(String cacheName) {
|
||||
if (Func.isEmpty(cacheName)) {
|
||||
return;
|
||||
}
|
||||
getCache(cacheName).clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
36
blade-starter-tenant/pom.xml
Normal file
36
blade-starter-tenant/pom.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>blade-starter-tenant</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<module.name>org.springblade.blade.starter.tenant</module.name>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Blade -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-launch</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-tool</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -13,14 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.StringValue;
|
||||
import org.springblade.core.secure.utils.SecureUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import org.springblade.core.tool.utils.RandomType;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
/**
|
||||
* 租户常量.
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
/**
|
||||
* 租户id生成器
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.boot.tenant;
|
||||
package org.springblade.core.tenant;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.springblade.core.secure.utils.SecureUtil;
|
12
pom.xml
12
pom.xml
@ -89,6 +89,8 @@
|
||||
<module>blade-starter-social</module>
|
||||
<module>blade-starter-swagger</module>
|
||||
<module>blade-starter-transaction</module>
|
||||
<module>blade-starter-cache</module>
|
||||
<module>blade-starter-tenant</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
@ -195,6 +197,11 @@
|
||||
<artifactId>blade-starter-oss</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-transaction</artifactId>
|
||||
@ -210,6 +217,11 @@
|
||||
<artifactId>blade-starter-report</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-cache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-datascope</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user