diff --git a/README.md b/README.md
index d5c8289..97be2ac 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-
+
## SpringBlade微服务开发平台
diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml
index 7278c75..a00e343 100644
--- a/blade-core-boot/pom.xml
+++ b/blade-core-boot/pom.xml
@@ -62,11 +62,6 @@
blade-core-swagger
${blade.tool.version}
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
org.springblade
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java
index 1cf86b3..7cd56b3 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java
+++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java
@@ -26,6 +26,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* 配置类
+ *
* @author Chill
*/
@Slf4j
@@ -41,6 +42,8 @@ public class BladeBootAutoConfiguration {
/**
* 全局变量定义
+ *
+ * @return SystemConstant
*/
@Bean
public SystemConstant fileConst() {
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java
index cae413c..784d414 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java
+++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java
@@ -40,6 +40,8 @@ public class MybatisPlusConfiguration {
/**
* sql 日志
+ *
+ * @return SqlLogInterceptor
*/
@Bean
@ConditionalOnProperty(value = "blade.mybatis-plus.sql-log.enable", matchIfMissing = true)
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java b/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java
index fc7a922..20fa539 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java
+++ b/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java
@@ -99,8 +99,8 @@ public class BladeFileUtil {
/**
* 文本排序转换成枚举
*
- * @param sort
- * @return
+ * @param sort 排序
+ * @return FileSort
*/
public static FileSort of(String sort) {
try {
@@ -228,6 +228,7 @@ public class BladeFileUtil {
* 获取BladeFile封装类
*
* @param files 文件集合
+ * @param dir 路径
* @param path 路径
* @param virtualPath 虚拟路径
* @return BladeFile
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java b/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java
index 6da15fd..769546a 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java
+++ b/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java
@@ -29,7 +29,7 @@ public interface IFileProxy {
*
* @param file 文件
* @param dir 目录
- * @return
+ * @return String
*/
String[] path(File file, String dir);
@@ -38,7 +38,7 @@ public interface IFileProxy {
*
* @param file 文件
* @param path 路径
- * @return
+ * @return File
*/
File rename(File file, String path);
diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml
index 0016aee..43743a9 100644
--- a/blade-core-tool/pom.xml
+++ b/blade-core-tool/pom.xml
@@ -67,6 +67,11 @@
protostuff-runtime
${protostuff.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java
similarity index 88%
rename from blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java
rename to blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java
index 48fb910..0647573 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.core.boot.config;
+package org.springblade.core.tool.config;
-import org.springblade.core.boot.redis.RedisKeySerializer;
+import org.springblade.core.tool.redis.RedisKeySerializer;
+import org.springblade.core.tool.utils.RedisUtil;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.cache.CacheManager;
@@ -78,4 +80,10 @@ public class RedisTemplateConfiguration {
.cacheDefaults(redisCacheConfiguration).build();
}
+ @Bean(name = "redisUtil")
+ @ConditionalOnBean(RedisTemplate.class)
+ public RedisUtil redisUtils(RedisTemplate redisTemplate) {
+ return new RedisUtil(redisTemplate);
+ }
+
}
diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java b/blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java
similarity index 98%
rename from blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java
rename to blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java
index cee1747..a45b027 100644
--- a/blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springblade.core.boot.redis;
+package org.springblade.core.tool.redis;
import org.springframework.cache.interceptor.SimpleKey;
import org.springframework.core.convert.ConversionService;
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java
new file mode 100644
index 0000000..8f67226
--- /dev/null
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java
@@ -0,0 +1,595 @@
+package org.springblade.core.tool.utils;
+
+import lombok.AllArgsConstructor;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Redis工具类
+ *
+ * @author Chill
+ */
+@AllArgsConstructor
+public class RedisUtil {
+
+ private RedisTemplate redisTemplate;
+
+ //=============================common============================
+
+ /**
+ * 指定缓存失效时间
+ *
+ * @param key 键
+ * @param time 时间(秒)
+ * @return boolean
+ */
+ public boolean expire(String key, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.expire(key, time, TimeUnit.SECONDS);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 根据key 获取过期时间
+ *
+ * @param key 键 不能为null
+ * @return 时间(秒) 返回0代表为永久有效
+ */
+ public long getExpire(String key) {
+ return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+ }
+
+ /**
+ * 判断key是否存在
+ *
+ * @param key 键
+ * @return true 存在 false不存在
+ */
+ public boolean hasKey(String key) {
+ try {
+ return redisTemplate.hasKey(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 删除缓存
+ *
+ * @param key 可以传一个值 或多个
+ */
+ @SuppressWarnings("unchecked")
+ public void del(String... key) {
+ if (key != null && key.length > 0) {
+ if (key.length == 1) {
+ redisTemplate.delete(key[0]);
+ } else {
+ redisTemplate.delete(CollectionUtil.arrayToList(key));
+ }
+ }
+ }
+
+ //============================String=============================
+
+ /**
+ * 普通缓存获取
+ *
+ * @param key 键
+ * @return 值
+ */
+ public Object get(String key) {
+ return key == null ? null : redisTemplate.opsForValue().get(key);
+ }
+
+ /**
+ * 普通缓存放入
+ *
+ * @param key 键
+ * @param value 值
+ * @return true成功 false失败
+ */
+ public boolean set(String key, Object value) {
+ try {
+ redisTemplate.opsForValue().set(key, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ }
+
+ /**
+ * 普通缓存放入并设置时间
+ *
+ * @param key 键
+ * @param value 值
+ * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
+ * @return true成功 false 失败
+ */
+ public boolean set(String key, Object value, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+ } else {
+ set(key, value);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 普通缓存放入并设置时间
+ *
+ * @param key 键
+ * @param value 值
+ * @param time 时间
+ * @param timeUnit 时间单位
+ * @return true成功 false 失败
+ */
+ public boolean set(String key, Object value, long time, TimeUnit timeUnit) {
+ try {
+ if (time > 0) {
+ redisTemplate.opsForValue().set(key, value, time, timeUnit);
+ } else {
+ set(key, value);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 递增
+ *
+ * @param key 键
+ * @param delta 要增加几(大于0)
+ * @return long
+ */
+ public long incr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递增因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, delta);
+ }
+
+ /**
+ * 递减
+ *
+ * @param key 键
+ * @param delta 要减少几(小于0)
+ * @return long
+ */
+ public long decr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递减因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, -delta);
+ }
+
+ //================================Map=================================
+
+ /**
+ * HashGet
+ *
+ * @param key 键 不能为null
+ * @param item 项 不能为null
+ * @return 值
+ */
+ public Object hget(String key, String item) {
+ return redisTemplate.opsForHash().get(key, item);
+ }
+
+ /**
+ * 获取hashKey对应的所有键值
+ *
+ * @param key 键
+ * @return 对应的多个键值
+ */
+ public Map