From 45df1673158d274adfd4916a817f840ffede2885 Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Mon, 8 May 2023 10:47:44 +0800 Subject: [PATCH] =?UTF-8?q?cn.skcks.matrix.v2.config=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20casbin=20=E6=9D=83=E9=99=90=E6=A3=80=E6=9F=A5=20=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=BA=A7=E5=88=AB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sk-matrix-service/.idea/compiler.xml | 4 +- .../sk-matrix-service/.idea/encodings.xml | 1 + .../matrix/v2/utils/json/JsonResponse.java | 8 + .../matrix/v2/utils/redis/RedisUtil.java | 476 +++++++++--------- backend/java/sk-matrix-service/model/pom.xml | 60 +++ .../main/java/cn/skcks/matrix/v2/Main.java | 7 + backend/java/sk-matrix-service/pom.xml | 1 + .../cn/skcks/matrix/v2/config/WebConfig.java | 37 +- .../starter/src/main/resources/logback.xml | 54 ++ 9 files changed, 406 insertions(+), 242 deletions(-) create mode 100644 backend/java/sk-matrix-service/model/pom.xml create mode 100644 backend/java/sk-matrix-service/model/src/main/java/cn/skcks/matrix/v2/Main.java create mode 100644 backend/java/sk-matrix-service/starter/src/main/resources/logback.xml diff --git a/backend/java/sk-matrix-service/.idea/compiler.xml b/backend/java/sk-matrix-service/.idea/compiler.xml index ee9777e..509a652 100644 --- a/backend/java/sk-matrix-service/.idea/compiler.xml +++ b/backend/java/sk-matrix-service/.idea/compiler.xml @@ -20,9 +20,10 @@ - + + @@ -37,6 +38,7 @@ + diff --git a/backend/java/sk-matrix-service/.idea/encodings.xml b/backend/java/sk-matrix-service/.idea/encodings.xml index cc254ad..1e3f8eb 100644 --- a/backend/java/sk-matrix-service/.idea/encodings.xml +++ b/backend/java/sk-matrix-service/.idea/encodings.xml @@ -8,6 +8,7 @@ + diff --git a/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/json/JsonResponse.java b/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/json/JsonResponse.java index 59ea51a..11b1555 100644 --- a/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/json/JsonResponse.java +++ b/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/json/JsonResponse.java @@ -38,10 +38,18 @@ public class JsonResponse { return JsonResponse.build(data, ResponseStatus.INTERNAL_SERVER_ERROR.getCode(), message); } + public static JsonResponse build(ResponseStatus status) { + return new JsonResponse<>(status.getCode(), status.getMessage(),null); + } + public static JsonResponse build(T data, ResponseStatus status) { return new JsonResponse<>(status.getCode(), status.getMessage(), data); } + public static JsonResponse build(ResponseStatus status,String message) { + return new JsonResponse<>(status.getCode(), message, null); + } + public static JsonResponse build(T data, int status, String msg) { return new JsonResponse<>(status, msg, data); } diff --git a/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/redis/RedisUtil.java b/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/redis/RedisUtil.java index 281acd2..6c256c0 100644 --- a/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/redis/RedisUtil.java +++ b/backend/java/sk-matrix-service/common/src/main/java/cn/skcks/matrix/v2/utils/redis/RedisUtil.java @@ -75,10 +75,10 @@ public class RedisUtil implements ApplicationContextAware { * @return 删除是否成功 */ public static boolean delete(String key) { - log.info("delete(...) => key -> {}", key); + log.debug("delete(...) => key -> {}", key); // 返回值只可能为true/false, 不可能为null Boolean result = redisTemplate.delete(key); - log.info("delete(...) => result -> {}", result); + log.debug("delete(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -96,9 +96,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 删除了的key-value个数 */ public static long delete(Collection keys) { - log.info("delete(...) => keys -> {}", keys); + log.debug("delete(...) => keys -> {}", keys); Long count = redisTemplate.delete(keys); - log.info("delete(...) => count -> {}", count); + log.debug("delete(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -116,9 +116,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 序列化后的value值 */ public static byte[] dump(String key) { - log.info("dump(...) =>key -> {}", key); + log.debug("dump(...) =>key -> {}", key); byte[] result = redisTemplate.dump(key); - log.info("dump(...) => result -> {}", result); + log.debug("dump(...) => result -> {}", result); return result; } @@ -148,7 +148,7 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException 如果redis中已存在同样的key, 且replace为false时,抛出此异常 */ public static void restore(String key, byte[] value, long timeout, TimeUnit unit, boolean replace) { - log.info("restore(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, replace -> {}", + log.debug("restore(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, replace -> {}", key, value, timeout, unit, replace); redisTemplate.restore(key, value, timeout, unit, replace); } @@ -160,9 +160,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 是否存在对应的key-value */ public static boolean hasKey(String key) { - log.info("hasKey(...) => key -> {}", key); + log.debug("hasKey(...) => key -> {}", key); Boolean result = redisTemplate.hasKey(key); - log.info("hasKey(...) => result -> {}", result); + log.debug("hasKey(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -181,9 +181,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 操作是否成功 */ public static boolean expire(String key, long timeout, TimeUnit unit) { - log.info("expire(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); + log.debug("expire(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); Boolean result = redisTemplate.expire(key, timeout, unit); - log.info("expire(...) => result is -> {}", result); + log.debug("expire(...) => result is -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -201,9 +201,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 操作是否成功 */ public static boolean expireAt(String key, Date date) { - log.info("expireAt(...) => key -> {}, date -> {}", key, date); + log.debug("expireAt(...) => key -> {}, date -> {}", key, date); Boolean result = redisTemplate.expireAt(key, date); - log.info("expireAt(...) => result is -> {}", result); + log.debug("expireAt(...) => result is -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -222,9 +222,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 匹配pattern的key的集合。 可能为null。 */ public static Set keys(String pattern) { - log.info("keys(...) => pattern -> {}", pattern); + log.debug("keys(...) => pattern -> {}", pattern); Set keys = redisTemplate.keys(pattern); - log.info("keys(...) => keys -> {}", keys); + log.debug("keys(...) => keys -> {}", keys); return keys; } @@ -241,9 +241,9 @@ public class RedisUtil implements ApplicationContextAware { * 注: 若目标db下,已存在相同的key, 那么move会失败,返回false。 */ public static boolean move(String key, int dbIndex) { - log.info("move(...) => key -> {}, dbIndex -> {}", key, dbIndex); + log.debug("move(...) => key -> {}, dbIndex -> {}", key, dbIndex); Boolean result = redisTemplate.move(key, dbIndex); - log.info("move(...) =>result -> {}", result); + log.debug("move(...) =>result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -260,9 +260,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 操作是否成功 */ public static boolean persist(String key) { - log.info("persist(...) => key -> {}", key); + log.debug("persist(...) => key -> {}", key); Boolean result = redisTemplate.persist(key); - log.info("persist(...) => result -> {}", result); + log.debug("persist(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -295,9 +295,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 过期时间(单位unit) */ public static long getExpire(String key, TimeUnit unit) { - log.info("getExpire(...) =>key -> {}, unit is -> {}", key, unit); + log.debug("getExpire(...) =>key -> {}, unit is -> {}", key, unit); Long result = redisTemplate.getExpire(key, unit); - log.info("getExpire(...) => result -> {}", result); + log.debug("getExpire(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -313,7 +313,7 @@ public class RedisUtil implements ApplicationContextAware { */ public static String randomKey() { String result = redisTemplate.randomKey(); - log.info("randomKey(...) => result is -> {}", result); + log.debug("randomKey(...) => result is -> {}", result); return result; } @@ -332,7 +332,7 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException 若oldKey不存在时, 抛出此异常 */ public static void rename(String oldKey, String newKey) { - log.info("rename(...) => oldKey -> {}, newKey -> {}", oldKey, newKey); + log.debug("rename(...) => oldKey -> {}, newKey -> {}", oldKey, newKey); redisTemplate.rename(oldKey, newKey); } @@ -347,9 +347,9 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException 若oldKey不存在时, 抛出此异常 */ public static boolean renameIfAbsent(String oldKey, String newKey) { - log.info("renameIfAbsent(...) => oldKey -> {}, newKey -> {}", oldKey, newKey); + log.debug("renameIfAbsent(...) => oldKey -> {}, newKey -> {}", oldKey, newKey); Boolean result = redisTemplate.renameIfAbsent(oldKey, newKey); - log.info("renameIfAbsent(...) => result -> {}", result); + log.debug("renameIfAbsent(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -365,9 +365,9 @@ public class RedisUtil implements ApplicationContextAware { * @return key对应的value的数据类型 */ public static DataType type(String key) { - log.info("type(...) => key -> {}", key); + log.debug("type(...) => key -> {}", key); DataType result = redisTemplate.type(key); - log.info("type(...) => result -> {}", result); + log.debug("type(...) => result -> {}", result); return result; } } @@ -391,7 +391,7 @@ public class RedisUtil implements ApplicationContextAware { * @param value key对应的value */ public static void set(String key, String value) { - log.info("set(...) => key -> {}, value -> {}", key, value); + log.debug("set(...) => key -> {}, value -> {}", key, value); redisTemplate.opsForValue().set(key, value); } @@ -415,9 +415,9 @@ public class RedisUtil implements ApplicationContextAware { * @return set是否成功 */ public static boolean setBit(String key, long offset, boolean value) { - log.info("setBit(...) => key -> {}, offset -> {}, value -> {}", key, offset, value); + log.debug("setBit(...) => key -> {}, offset -> {}, value -> {}", key, offset, value); Boolean result = redisTemplate.opsForValue().setBit(key, offset, value); - log.info("setBit(...) => result -> {}", result); + log.debug("setBit(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -435,7 +435,7 @@ public class RedisUtil implements ApplicationContextAware { * @param unit timeout的单位 */ public static void setEx(String key, String value, long timeout, TimeUnit unit) { - log.info("setEx(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}", + log.debug("setEx(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}", key, value, timeout, unit); redisTemplate.opsForValue().set(key, value, timeout, unit); } @@ -449,9 +449,9 @@ public class RedisUtil implements ApplicationContextAware { * @return set是否成功 */ public static boolean setIfAbsent(String key, String value) { - log.info("setIfAbsent(...) => key -> {}, value -> {}", key, value); + log.debug("setIfAbsent(...) => key -> {}, value -> {}", key, value); Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value); - log.info("setIfAbsent(...) => result -> {}", result); + log.debug("setIfAbsent(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -469,9 +469,9 @@ public class RedisUtil implements ApplicationContextAware { * @return set是否成功 */ public static boolean setIfAbsent(String key, String value, long timeout, TimeUnit unit) { - log.info("setIfAbsent(...) => key -> {}, value -> {}, key -> {}, value -> {}", key, value, timeout, unit); + log.debug("setIfAbsent(...) => key -> {}, value -> {}, key -> {}, value -> {}", key, value, timeout, unit); Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, timeout, unit); - log.info("setIfAbsent(...) => result -> {}", result); + log.debug("setIfAbsent(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -498,7 +498,7 @@ public class RedisUtil implements ApplicationContextAware { * @param offset 起始位置 */ public static void setRange(String key, String replaceValue, long offset) { - log.info("setRange(...) => key -> {}, replaceValue -> {}, offset -> {}", key, replaceValue, offset); + log.debug("setRange(...) => key -> {}, replaceValue -> {}, offset -> {}", key, replaceValue, offset); redisTemplate.opsForValue().set(key, replaceValue, offset); } @@ -512,9 +512,9 @@ public class RedisUtil implements ApplicationContextAware { * @return value的长度 */ public static long size(String key) { - log.info("size(...) => key -> {}", key); + log.debug("size(...) => key -> {}", key); Long result = redisTemplate.opsForValue().size(key); - log.info("size(...) => result -> {}", result); + log.debug("size(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -529,7 +529,7 @@ public class RedisUtil implements ApplicationContextAware { * @param maps key-value 集 */ public static void multiSet(Map maps) { - log.info("multiSet(...) => maps -> {}", maps); + log.debug("multiSet(...) => maps -> {}", maps); redisTemplate.opsForValue().multiSet(maps); } @@ -549,9 +549,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 操作是否成功 */ public static boolean multiSetIfAbsent(Map maps) { - log.info("multiSetIfAbsent(...) => maps -> {}", maps); + log.debug("multiSetIfAbsent(...) => maps -> {}", maps); Boolean result = redisTemplate.opsForValue().multiSetIfAbsent(maps); - log.info("multiSetIfAbsent(...) => result -> {}", result); + log.debug("multiSetIfAbsent(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -571,9 +571,9 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException key对应的value值不支持增/减操作时 */ public static long incrBy(String key, long increment) { - log.info("incrBy(...) => key -> {}, increment -> {}", key, increment); + log.debug("incrBy(...) => key -> {}, increment -> {}", key, increment); Long result = redisTemplate.opsForValue().increment(key, increment); - log.info("incrBy(...) => result -> {}", result); + log.debug("incrBy(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -597,9 +597,9 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException key对应的value值不支持增/减操作时 */ public static double incrByFloat(String key, double increment) { - log.info("incrByFloat(...) => key -> {}, increment -> {}", key, increment); + log.debug("incrByFloat(...) => key -> {}, increment -> {}", key, increment); Double result = redisTemplate.opsForValue().increment(key, increment); - log.info("incrByFloat(...) => result -> {}", result); + log.debug("incrByFloat(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -616,9 +616,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 追加后, 整个value的长度 */ public static int append(String key, String value) { - log.info("append(...) => key -> {}, value -> {}", key, value); + log.debug("append(...) => key -> {}, value -> {}", key, value); Integer result = redisTemplate.opsForValue().append(key, value); - log.info("append(...) => result -> {}", result); + log.debug("append(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -633,9 +633,9 @@ public class RedisUtil implements ApplicationContextAware { * 注: 若key不存在, 则返回null。 */ public static String get(String key) { - log.info("get(...) => key -> {}", key); + log.debug("get(...) => key -> {}", key); String result = redisTemplate.opsForValue().get(key); - log.info("get(...) => result -> {} ", result); + log.debug("get(...) => result -> {} ", result); return result; } @@ -651,9 +651,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 截取后的字符串 */ public static String getRange(String key, long start, long end) { - log.info("getRange(...) => kry -> {}", key); + log.debug("getRange(...) => kry -> {}", key); String result = redisTemplate.opsForValue().get(key, start, end); - log.info("getRange(...) => result -> {} ", result); + log.debug("getRange(...) => result -> {} ", result); return result; } @@ -667,9 +667,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 旧的value值 */ public static String getAndSet(String key, String newValue) { - log.info("getAndSet(...) => key -> {}, value -> {}", key, newValue); + log.debug("getAndSet(...) => key -> {}, value -> {}", key, newValue); String oldValue = redisTemplate.opsForValue().getAndSet(key, newValue); - log.info("getAndSet(...) => oldValue -> {}", oldValue); + log.debug("getAndSet(...) => oldValue -> {}", oldValue); return oldValue; } @@ -688,9 +688,9 @@ public class RedisUtil implements ApplicationContextAware { * @return offset位置对应的bit的值(true - 1, false - 0) */ public static boolean getBit(String key, long offset) { - log.info("getBit(...) => key -> {}, offset -> {}", key, offset); + log.debug("getBit(...) => key -> {}, offset -> {}", key, offset); Boolean result = redisTemplate.opsForValue().getBit(key, offset); - log.info("getBit(...) => result -> {}", result); + log.debug("getBit(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -706,9 +706,9 @@ public class RedisUtil implements ApplicationContextAware { * @return value值集合 */ public static List multiGet(Collection keys) { - log.info("multiGet(...) => keys -> {}", keys); + log.debug("multiGet(...) => keys -> {}", keys); List result = redisTemplate.opsForValue().multiGet(keys); - log.info("multiGet(...) => result -> {}", result); + log.debug("multiGet(...) => result -> {}", result); return result; } } @@ -735,7 +735,7 @@ public class RedisUtil implements ApplicationContextAware { * @param entryValue 要向hash中增加的键值对里的 值 */ public static void hPut(String key, String entryKey, String entryValue) { - log.info("hPut(...) => key -> {}, entryKey -> {}, entryValue -> {}", key, entryKey, entryValue); + log.debug("hPut(...) => key -> {}, entryKey -> {}, entryValue -> {}", key, entryKey, entryValue); redisTemplate.opsForHash().put(key, entryKey, entryValue); } @@ -749,7 +749,7 @@ public class RedisUtil implements ApplicationContextAware { * @param maps 要向hash中增加的键值对集 */ public static void hPutAll(String key, Map maps) { - log.info("hPutAll(...) => key -> {}, maps -> {}", key, maps); + log.debug("hPutAll(...) => key -> {}, maps -> {}", key, maps); redisTemplate.opsForHash().putAll(key, maps); } @@ -763,10 +763,10 @@ public class RedisUtil implements ApplicationContextAware { * @return 操作是否成功。 */ public static boolean hPutIfAbsent(String key, String entryKey, String entryValue) { - log.info("hPutIfAbsent(...) => key -> {}, entryKey -> {}, entryValue -> {}", + log.debug("hPutIfAbsent(...) => key -> {}, entryKey -> {}, entryValue -> {}", key, entryKey, entryValue); Boolean result = redisTemplate.opsForHash().putIfAbsent(key, entryKey, entryValue); - log.info("hPutIfAbsent(...) => result -> {}", result); + log.debug("hPutIfAbsent(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -784,9 +784,9 @@ public class RedisUtil implements ApplicationContextAware { * @return key对应的hash里的entryKey对应的entryValue值 */ public static Object hGet(String key, String entryKey) { - log.info("hGet(...) => key -> {}, entryKey -> {}", key, entryKey); + log.debug("hGet(...) => key -> {}, entryKey -> {}", key, entryKey); Object entryValue = redisTemplate.opsForHash().get(key, entryKey); - log.info("hGet(...) => entryValue -> {}", entryValue); + log.debug("hGet(...) => entryValue -> {}", entryValue); return entryValue; } @@ -799,9 +799,9 @@ public class RedisUtil implements ApplicationContextAware { * @return key对应的hash。 */ public static Map hGetAll(String key) { - log.info("hGetAll(...) => key -> {}", key); + log.debug("hGetAll(...) => key -> {}", key); Map result = redisTemplate.opsForHash().entries(key); - log.info("hGetAll(...) => result -> {}", result); + log.debug("hGetAll(...) => result -> {}", result); return result; } @@ -817,9 +817,9 @@ public class RedisUtil implements ApplicationContextAware { * @return hash中对应entryKeys的对应entryValue集 */ public static List hMultiGet(String key, Collection entryKeys) { - log.info("hMultiGet(...) => key -> {}, entryKeys -> {}", key, entryKeys); + log.debug("hMultiGet(...) => key -> {}, entryKeys -> {}", key, entryKeys); List entryValues = redisTemplate.opsForHash().multiGet(key, entryKeys); - log.info("hMultiGet(...) => entryValues -> {}", entryValues); + log.debug("hMultiGet(...) => entryValues -> {}", entryValues); return entryValues; } @@ -840,9 +840,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 删除了对应hash中多少个entry */ public static long hDelete(String key, Object... entryKeys) { - log.info("hDelete(...) => key -> {}, entryKeys -> {}", key, entryKeys); + log.debug("hDelete(...) => key -> {}, entryKeys -> {}", key, entryKeys); Long count = redisTemplate.opsForHash().delete(key, entryKeys); - log.info("hDelete(...) => count -> {}", count); + log.debug("hDelete(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -860,9 +860,9 @@ public class RedisUtil implements ApplicationContextAware { * @return hash中是否存在entryKey对应的entry. */ public static boolean hExists(String key, String entryKey) { - log.info("hDelete(...) => key -> {}, entryKeys -> {}", key, entryKey); + log.debug("hDelete(...) => key -> {}, entryKeys -> {}", key, entryKey); Boolean exist = redisTemplate.opsForHash().hasKey(key, entryKey); - log.info("hDelete(...) => exist -> {}", exist); + log.debug("hDelete(...) => exist -> {}", exist); return exist; } @@ -882,10 +882,10 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException key对应的value值不支持增/减操作时 */ public static long hIncrBy(String key, Object entryKey, long increment) { - log.info("hIncrBy(...) => key -> {}, entryKey -> {}, increment -> {}", + log.debug("hIncrBy(...) => key -> {}, entryKey -> {}, increment -> {}", key, entryKey, increment); Long result = redisTemplate.opsForHash().increment(key, entryKey, increment); - log.info("hIncrBy(...) => result -> {}", result); + log.debug("hIncrBy(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -910,10 +910,10 @@ public class RedisUtil implements ApplicationContextAware { * @throws RedisSystemException key对应的value值不支持增/减操作时 */ public static double hIncrByFloat(String key, Object entryKey, double increment) { - log.info("hIncrByFloat(...) => key -> {}, entryKey -> {}, increment -> {}", + log.debug("hIncrByFloat(...) => key -> {}, entryKey -> {}, increment -> {}", key, entryKey, increment); Double result = redisTemplate.opsForHash().increment(key, entryKey, increment); - log.info("hIncrByFloat(...) => result -> {}", result); + log.debug("hIncrByFloat(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -929,9 +929,9 @@ public class RedisUtil implements ApplicationContextAware { * @return hash中的所有entryKey */ public static Set hKeys(String key) { - log.info("hKeys(...) => key -> {}", key); + log.debug("hKeys(...) => key -> {}", key); Set entryKeys = redisTemplate.opsForHash().keys(key); - log.info("hKeys(...) => entryKeys -> {}", entryKeys); + log.debug("hKeys(...) => entryKeys -> {}", entryKeys); return entryKeys; } @@ -944,9 +944,9 @@ public class RedisUtil implements ApplicationContextAware { * @return hash中的所有entryValue */ public static List hValues(String key) { - log.info("hValues(...) => key -> {}", key); + log.debug("hValues(...) => key -> {}", key); List entryValues = redisTemplate.opsForHash().values(key); - log.info("hValues(...) => entryValues -> {}", entryValues); + log.debug("hValues(...) => entryValues -> {}", entryValues); return entryValues; } @@ -959,9 +959,9 @@ public class RedisUtil implements ApplicationContextAware { * @return (key对应的)hash中, entry的个数 */ public static long hSize(String key) { - log.info("hSize(...) => key -> {}", key); + log.debug("hSize(...) => key -> {}", key); Long count = redisTemplate.opsForHash().size(key); - log.info("hSize(...) => count -> {}", count); + log.debug("hSize(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -987,9 +987,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 匹配到的(key对应的)hash中的entry */ public static Cursor> hScan(String key, ScanOptions options) { - log.info("hScan(...) => key -> {}, options -> {}", key, JSONUtil.toJsonStr(options)); + log.debug("hScan(...) => key -> {}, options -> {}", key, JSONUtil.toJsonStr(options)); Cursor> cursor = redisTemplate.opsForHash().scan(key, options); - log.info("hScan(...) => cursor -> {}", JSONUtil.toJsonStr(cursor)); + log.debug("hScan(...) => cursor -> {}", JSONUtil.toJsonStr(cursor)); return cursor; } } @@ -1022,9 +1022,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 推入后,(key对应的)list的size */ public static long lLeftPush(String key, String item) { - log.info("lLeftPush(...) => key -> {}, item -> {}", key, item); + log.debug("lLeftPush(...) => key -> {}, item -> {}", key, item); Long size = redisTemplate.opsForList().leftPush(key, item); - log.info("lLeftPush(...) => size -> {}", size); + log.debug("lLeftPush(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1042,9 +1042,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 推入后,(key对应的)list的size */ public static long lLeftPushAll(String key, String... items) { - log.info("lLeftPushAll(...) => key -> {}, items -> {}", key, items); + log.debug("lLeftPushAll(...) => key -> {}, items -> {}", key, items); Long size = redisTemplate.opsForList().leftPushAll(key, items); - log.info("lLeftPushAll(...) => size -> {}", size); + log.debug("lLeftPushAll(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1062,9 +1062,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 推入后,(key对应的)list的size */ public static long lLeftPushAll(String key, Collection items) { - log.info("lLeftPushAll(...) => key -> {}, items -> {}", key, items); + log.debug("lLeftPushAll(...) => key -> {}, items -> {}", key, items); Long size = redisTemplate.opsForList().leftPushAll(key, items); - log.info("lLeftPushAll(...) => size -> {}", size); + log.debug("lLeftPushAll(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1080,9 +1080,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 推入后,(key对应的)list的size */ public static long lLeftPushIfPresent(String key, String item) { - log.info("lLeftPushIfPresent(...) => key -> {}, item -> {}", key, item); + log.debug("lLeftPushIfPresent(...) => key -> {}, item -> {}", key, item); Long size = redisTemplate.opsForList().leftPushIfPresent(key, item); - log.info("lLeftPushIfPresent(...) => size -> {}", size); + log.debug("lLeftPushIfPresent(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1100,9 +1100,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 推入后,(key对应的)list的size */ public static long lLeftPush(String key, String pivot, String item) { - log.info("lLeftPush(...) => key -> {}, pivot -> {}, item -> {}", key, pivot, item); + log.debug("lLeftPush(...) => key -> {}, pivot -> {}, item -> {}", key, pivot, item); Long size = redisTemplate.opsForList().leftPush(key, pivot, item); - log.info("lLeftPush(...) => size -> {}", size); + log.debug("lLeftPush(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1113,9 +1113,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPush(String, String)}类比即可, 不过是从list右侧推入元素 */ public static long lRightPush(String key, String item) { - log.info("lRightPush(...) => key -> {}, item -> {}", key, item); + log.debug("lRightPush(...) => key -> {}, item -> {}", key, item); Long size = redisTemplate.opsForList().rightPush(key, item); - log.info("lRightPush(...) => size -> {}", size); + log.debug("lRightPush(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1126,9 +1126,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPushAll(String, String...)}类比即可, 不过是从list右侧推入元素 */ public static long lRightPushAll(String key, String... items) { - log.info("lRightPushAll(...) => key -> {}, items -> {}", key, items); + log.debug("lRightPushAll(...) => key -> {}, items -> {}", key, items); Long size = redisTemplate.opsForList().rightPushAll(key, items); - log.info("lRightPushAll(...) => size -> {}", size); + log.debug("lRightPushAll(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1139,9 +1139,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPushAll(String, Collection)}类比即可, 不过是从list右侧推入元素 */ public static long lRightPushAll(String key, Collection items) { - log.info("lRightPushAll(...) => key -> {}, items -> {}", key, items); + log.debug("lRightPushAll(...) => key -> {}, items -> {}", key, items); Long size = redisTemplate.opsForList().rightPushAll(key, items); - log.info("lRightPushAll(...) => size -> {}", size); + log.debug("lRightPushAll(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1152,9 +1152,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPushIfPresent(String, String)}类比即可, 不过是从list右侧推入元素 */ public static long lRightPushIfPresent(String key, String item) { - log.info("lRightPushIfPresent(...) => key -> {}, item -> {}", key, item); + log.debug("lRightPushIfPresent(...) => key -> {}, item -> {}", key, item); Long size = redisTemplate.opsForList().rightPushIfPresent(key, item); - log.info("lRightPushIfPresent(...) => size -> {}", size); + log.debug("lRightPushIfPresent(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1165,9 +1165,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPush(String, String, String)}类比即可, 不过是从list右侧推入元素 */ public static long lRightPush(String key, String pivot, String item) { - log.info("lLeftPush(...) => key -> {}, pivot -> {}, item -> {}", key, pivot, item); + log.debug("lLeftPush(...) => key -> {}, pivot -> {}, item -> {}", key, pivot, item); Long size = redisTemplate.opsForList().rightPush(key, pivot, item); - log.info("lLeftPush(...) => size -> {}", size); + log.debug("lLeftPush(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1185,9 +1185,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 移出的那个元素 */ public static String lLeftPop(String key) { - log.info("lLeftPop(...) => key -> {}", key); + log.debug("lLeftPop(...) => key -> {}", key); String item = redisTemplate.opsForList().leftPop(key); - log.info("lLeftPop(...) => item -> {}", item); + log.debug("lLeftPop(...) => item -> {}", item); return item; } @@ -1207,9 +1207,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 移出的那个元素 */ public static String lLeftPop(String key, long timeout, TimeUnit unit) { - log.info("lLeftPop(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); + log.debug("lLeftPop(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); String item = redisTemplate.opsForList().leftPop(key, timeout, unit); - log.info("lLeftPop(...) => item -> {}", item); + log.debug("lLeftPop(...) => item -> {}", item); return item; } @@ -1217,9 +1217,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPop(String)}类比即可, 不过是从list右侧移出元素 */ public static String lRightPop(String key) { - log.info("lRightPop(...) => key -> {}", key); + log.debug("lRightPop(...) => key -> {}", key); String item = redisTemplate.opsForList().rightPop(key); - log.info("lRightPop(...) => item -> {}", item); + log.debug("lRightPop(...) => item -> {}", item); return item; } @@ -1227,9 +1227,9 @@ public class RedisUtil implements ApplicationContextAware { * 与{@link ListOps#lLeftPop(String, long, TimeUnit)}类比即可, 不过是从list右侧移出元素 */ public static String lRightPop(String key, long timeout, TimeUnit unit) { - log.info("lRightPop(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); + log.debug("lRightPop(...) => key -> {}, timeout -> {}, unit -> {}", key, timeout, unit); String item = redisTemplate.opsForList().rightPop(key, timeout, unit); - log.info("lRightPop(...) => item -> {}", item); + log.debug("lRightPop(...) => item -> {}", item); return item; } @@ -1248,10 +1248,10 @@ public class RedisUtil implements ApplicationContextAware { * @return 移动的这个元素 */ public static String lRightPopAndLeftPush(String sourceKey, String destinationKey) { - log.info("lRightPopAndLeftPush(...) => sourceKey -> {}, destinationKey -> {}", + log.debug("lRightPopAndLeftPush(...) => sourceKey -> {}, destinationKey -> {}", sourceKey, destinationKey); String item = redisTemplate.opsForList().rightPopAndLeftPush(sourceKey, destinationKey); - log.info("lRightPopAndLeftPush(...) => item -> {}", item); + log.debug("lRightPopAndLeftPush(...) => item -> {}", item); return item; } @@ -1274,10 +1274,10 @@ public class RedisUtil implements ApplicationContextAware { */ public static String lRightPopAndLeftPush(String sourceKey, String destinationKey, long timeout, TimeUnit unit) { - log.info("lRightPopAndLeftPush(...) => sourceKey -> {}, destinationKey -> {}, timeout -> {}," + log.debug("lRightPopAndLeftPush(...) => sourceKey -> {}, destinationKey -> {}, timeout -> {}," + " unit -> {}", sourceKey, destinationKey, timeout, unit); String item = redisTemplate.opsForList().rightPopAndLeftPush(sourceKey, destinationKey, timeout, unit); - log.info("lRightPopAndLeftPush(...) => item -> {}", item); + log.debug("lRightPopAndLeftPush(...) => item -> {}", item); return item; } @@ -1292,7 +1292,7 @@ public class RedisUtil implements ApplicationContextAware { * @param item 要替换成的值 */ public static void lSet(String key, long index, String item) { - log.info("lSet(...) => key -> {}, index -> {}, item -> {}", key, index, item); + log.debug("lSet(...) => key -> {}, index -> {}, item -> {}", key, index, item); redisTemplate.opsForList().set(key, index, item); } @@ -1306,9 +1306,9 @@ public class RedisUtil implements ApplicationContextAware { * @return list中索引index对应的item */ public static String lIndex(String key, long index) { - log.info("lIndex(...) => key -> {}, index -> {}", key, index); + log.debug("lIndex(...) => key -> {}, index -> {}", key, index); String item = redisTemplate.opsForList().index(key, index); - log.info("lIndex(...) => item -> {}", item); + log.debug("lIndex(...) => item -> {}", item); return item; } @@ -1327,9 +1327,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 对应的元素集合 */ public static List lRange(String key, long start, long end) { - log.info("lRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("lRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); List result = redisTemplate.opsForList().range(key, start, end); - log.info("lRange(...) => result -> {}", result); + log.debug("lRange(...) => result -> {}", result); return result; } @@ -1341,9 +1341,9 @@ public class RedisUtil implements ApplicationContextAware { * @see ListOps#lRange(String, long, long) */ public static List lWholeList(String key) { - log.info("lWholeList(...) => key -> {}", key); + log.debug("lWholeList(...) => key -> {}", key); List result = redisTemplate.opsForList().range(key, 0, -1); - log.info("lWholeList(...) => result -> {}", result); + log.debug("lWholeList(...) => result -> {}", result); return result; } @@ -1356,9 +1356,9 @@ public class RedisUtil implements ApplicationContextAware { * @return list的size。 */ public static long lSize(String key) { - log.info("lSize(...) => key -> {}", key); + log.debug("lSize(...) => key -> {}", key); Long size = redisTemplate.opsForList().size(key); - log.info("lSize(...) => size -> {}", size); + log.debug("lSize(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1382,9 +1382,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 实际删除了的item的个数 */ public static long lRemove(String key, long expectCount, String item) { - log.info("lRemove(...) => key -> {}, expectCount -> {}, item -> {}", key, expectCount, item); + log.debug("lRemove(...) => key -> {}, expectCount -> {}, item -> {}", key, expectCount, item); Long actualCount = redisTemplate.opsForList().remove(key, expectCount, item); - log.info("lRemove(...) => actualCount -> {}", actualCount); + log.debug("lRemove(...) => actualCount -> {}", actualCount); if (actualCount == null) { throw new RedisOpsResultIsNullException(); } @@ -1405,7 +1405,7 @@ public class RedisUtil implements ApplicationContextAware { * @param end 要删除的item集的结尾项的索引 */ public static void lTrim(String key, long start, long end) { - log.info("lTrim(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("lTrim(...) => key -> {}, start -> {}, end -> {}", key, start, end); redisTemplate.opsForList().trim(key, start, end); } @@ -1434,9 +1434,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 此次添加操作, 添加到set中的元素的个数 */ public static long sAdd(String key, String... items) { - log.info("sAdd(...) => key -> {}, items -> {}", key, items); + log.debug("sAdd(...) => key -> {}, items -> {}", key, items); Long count = redisTemplate.opsForSet().add(key, items); - log.info("sAdd(...) => count -> {}", count); + log.debug("sAdd(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -1454,9 +1454,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 实际删除了的个数 */ public static long sRemove(String key, Object... items) { - log.info("sRemove(...) => key -> {}, items -> {}", key, items); + log.debug("sRemove(...) => key -> {}, items -> {}", key, items); Long count = redisTemplate.opsForSet().remove(key, items); - log.info("sRemove(...) => count -> {}", count); + log.debug("sRemove(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -1475,9 +1475,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 移出的项 */ public static String sPop(String key) { - log.info("sPop(...) => key -> {}", key); + log.debug("sPop(...) => key -> {}", key); String popItem = redisTemplate.opsForSet().pop(key); - log.info("sPop(...) => popItem -> {}", popItem); + log.debug("sPop(...) => popItem -> {}", popItem); return popItem; } @@ -1496,9 +1496,9 @@ public class RedisUtil implements ApplicationContextAware { */ public static boolean sMove(String sourceKey, String item, String destinationKey) { Boolean result = redisTemplate.opsForSet().move(sourceKey, item, destinationKey); - log.info("sMove(...) => sourceKey -> {}, destinationKey -> {}, item -> {}", + log.debug("sMove(...) => sourceKey -> {}, destinationKey -> {}, item -> {}", sourceKey, destinationKey, item); - log.info("sMove(...) => result -> {}", result); + log.debug("sMove(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -1514,9 +1514,9 @@ public class RedisUtil implements ApplicationContextAware { * @return (key对应的)set中的元素个数 */ public static long sSize(String key) { - log.info("sSize(...) => key -> {}", key); + log.debug("sSize(...) => key -> {}", key); Long size = redisTemplate.opsForSet().size(key); - log.info("sSize(...) => size -> {}", size); + log.debug("sSize(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1533,9 +1533,9 @@ public class RedisUtil implements ApplicationContextAware { * @return (key对应的)set中是否含有item */ public static boolean sIsMember(String key, Object item) { - log.info("sSize(...) => key -> {}, size -> {}", key, item); + log.debug("sSize(...) => key -> {}, size -> {}", key, item); Boolean result = redisTemplate.opsForSet().isMember(key, item); - log.info("sSize(...) => result -> {}", result); + log.debug("sSize(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -1553,9 +1553,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item交集 */ public static Set sIntersect(String key, String otherKey) { - log.info("sIntersect(...) => key -> {}, otherKey -> {}", key, otherKey); + log.debug("sIntersect(...) => key -> {}, otherKey -> {}", key, otherKey); Set intersectResult = redisTemplate.opsForSet().intersect(key, otherKey); - log.info("sIntersect(...) => intersectResult -> {}", intersectResult); + log.debug("sIntersect(...) => intersectResult -> {}", intersectResult); return intersectResult; } @@ -1570,9 +1570,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item交集 */ public static Set sIntersect(String key, Collection otherKeys) { - log.info("sIntersect(...) => key -> {}, otherKeys -> {}", key, otherKeys); + log.debug("sIntersect(...) => key -> {}, otherKeys -> {}", key, otherKeys); Set intersectResult = redisTemplate.opsForSet().intersect(key, otherKeys); - log.info("sIntersect(...) => intersectResult -> {}", intersectResult); + log.debug("sIntersect(...) => intersectResult -> {}", intersectResult); return intersectResult; } @@ -1591,10 +1591,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)Set后, 该set对应的size */ public static long sIntersectAndStore(String key, String otherKey, String storeKey) { - log.info("sIntersectAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", + log.debug("sIntersectAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); Long size = redisTemplate.opsForSet().intersectAndStore(key, otherKey, storeKey); - log.info("sIntersectAndStore(...) => size -> {}", size); + log.debug("sIntersectAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1611,9 +1611,9 @@ public class RedisUtil implements ApplicationContextAware { * 注: 求交集的部分,详见{@link SetOps#sIntersect(String, Collection)} */ public static long sIntersectAndStore(String key, Collection otherKeys, String storeKey) { - log.info("sIntersectAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); + log.debug("sIntersectAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); Long size = redisTemplate.opsForSet().intersectAndStore(key, otherKeys, storeKey); - log.info("sIntersectAndStore(...) => size -> {}", size); + log.debug("sIntersectAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1630,9 +1630,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item并集 */ public static Set sUnion(String key, String otherKey) { - log.info("sUnion(...) => key -> {}, otherKey -> {}", key, otherKey); + log.debug("sUnion(...) => key -> {}, otherKey -> {}", key, otherKey); Set unionResult = redisTemplate.opsForSet().union(key, otherKey); - log.info("sUnion(...) => unionResult -> {}", unionResult); + log.debug("sUnion(...) => unionResult -> {}", unionResult); return unionResult; } @@ -1646,9 +1646,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item并集 */ public static Set sUnion(String key, Collection otherKeys) { - log.info("sUnion(...) => key -> {}, otherKeys -> {}", key, otherKeys); + log.debug("sUnion(...) => key -> {}, otherKeys -> {}", key, otherKeys); Set unionResult = redisTemplate.opsForSet().union(key, otherKeys); - log.info("sUnion(...) => unionResult -> {}", unionResult); + log.debug("sUnion(...) => unionResult -> {}", unionResult); return unionResult; } @@ -1667,10 +1667,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)Set后, 该set对应的size */ public static long sUnionAndStore(String key, String otherKey, String storeKey) { - log.info("sUnionAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", + log.debug("sUnionAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); Long size = redisTemplate.opsForSet().unionAndStore(key, otherKey, storeKey); - log.info("sUnionAndStore(...) => size -> {}", size); + log.debug("sUnionAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1692,10 +1692,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)Set后, 该set对应的size */ public static long sUnionAndStore(String key, Collection otherKeys, String storeKey) { - log.info("sUnionAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", + log.debug("sUnionAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); Long size = redisTemplate.opsForSet().unionAndStore(key, otherKeys, storeKey); - log.info("sUnionAndStore(...) => size -> {}", size); + log.debug("sUnionAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1713,10 +1713,10 @@ public class RedisUtil implements ApplicationContextAware { * @return item差集 */ public static Set sDifference(String key, String otherKey) { - log.info("sDifference(...) => key -> {}, otherKey -> {}", + log.debug("sDifference(...) => key -> {}, otherKey -> {}", key, otherKey); Set differenceResult = redisTemplate.opsForSet().difference(key, otherKey); - log.info("sDifference(...) => differenceResult -> {}", differenceResult); + log.debug("sDifference(...) => differenceResult -> {}", differenceResult); return differenceResult; } @@ -1733,9 +1733,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item差集 */ public static Set sDifference(String key, Collection otherKeys) { - log.info("sDifference(...) => key -> {}, otherKeys -> {}", key, otherKeys); + log.debug("sDifference(...) => key -> {}, otherKeys -> {}", key, otherKeys); Set differenceResult = redisTemplate.opsForSet().difference(key, otherKeys); - log.info("sDifference(...) => differenceResult -> {}", differenceResult); + log.debug("sDifference(...) => differenceResult -> {}", differenceResult); return differenceResult; } @@ -1754,10 +1754,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)Set后, 该set对应的size */ public static long sDifferenceAndStore(String key, String otherKey, String storeKey) { - log.info("sDifferenceAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", + log.debug("sDifferenceAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); Long size = redisTemplate.opsForSet().differenceAndStore(key, otherKey, storeKey); - log.info("sDifferenceAndStore(...) => size -> {}", size); + log.debug("sDifferenceAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1779,10 +1779,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)Set后, 该set对应的size */ public static long sDifferenceAndStore(String key, Collection otherKeys, String storeKey) { - log.info("sDifferenceAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", + log.debug("sDifferenceAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); Long size = redisTemplate.opsForSet().differenceAndStore(key, otherKeys, storeKey); - log.info("sDifferenceAndStore(...) => size -> {}", size); + log.debug("sDifferenceAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -1798,9 +1798,9 @@ public class RedisUtil implements ApplicationContextAware { * @return (key对应的)set */ public static Set sMembers(String key) { - log.info("sMembers(...) => key -> {}", key); + log.debug("sMembers(...) => key -> {}", key); Set members = redisTemplate.opsForSet().members(key); - log.info("sMembers(...) => members -> {}", members); + log.debug("sMembers(...) => members -> {}", members); return members; } @@ -1811,9 +1811,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 随机获取到的项 */ public static String sRandomMember(String key) { - log.info("sRandomMember(...) => key -> {}", key); + log.debug("sRandomMember(...) => key -> {}", key); String randomItem = redisTemplate.opsForSet().randomMember(key); - log.info("sRandomMember(...) => randomItem -> {}", randomItem); + log.debug("sRandomMember(...) => randomItem -> {}", randomItem); return randomItem; } @@ -1828,9 +1828,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 随机获取到的项集 */ public static List sRandomMembers(String key, long count) { - log.info("sRandomMembers(...) => key -> {}, count -> {}", key, count); + log.debug("sRandomMembers(...) => key -> {}, count -> {}", key, count); List randomItems = redisTemplate.opsForSet().randomMembers(key, count); - log.info("sRandomMembers(...) => randomItems -> {}", randomItems); + log.debug("sRandomMembers(...) => randomItems -> {}", randomItems); return randomItems; } @@ -1845,9 +1845,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 随机获取到的项集 */ public static Set sDistinctRandomMembers(String key, long count) { - log.info("sDistinctRandomMembers(...) => key -> {}, count -> {}", key, count); + log.debug("sDistinctRandomMembers(...) => key -> {}, count -> {}", key, count); Set distinctRandomItems = redisTemplate.opsForSet().distinctRandomMembers(key, count); - log.info("sDistinctRandomMembers(...) => distinctRandomItems -> {}", distinctRandomItems); + log.debug("sDistinctRandomMembers(...) => distinctRandomItems -> {}", distinctRandomItems); return distinctRandomItems; } @@ -1870,9 +1870,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 匹配到的(key对应的)set中的项 */ public static Cursor sScan(String key, ScanOptions options) { - log.info("sScan(...) => key -> {}, options -> {}", key, JSONUtil.toJsonStr(options)); + log.debug("sScan(...) => key -> {}, options -> {}", key, JSONUtil.toJsonStr(options)); Cursor cursor = redisTemplate.opsForSet().scan(key, options); - log.info("sScan(...) => cursor -> {}", JSONUtil.toJsonStr(cursor)); + log.debug("sScan(...) => cursor -> {}", JSONUtil.toJsonStr(cursor)); return cursor; } } @@ -1912,9 +1912,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 是否添加成功 */ public static boolean zAdd(String key, String item, double score) { - log.info("zAdd(...) => key -> {}, item -> {}, score -> {}", key, item, score); + log.debug("zAdd(...) => key -> {}, item -> {}, score -> {}", key, item, score); Boolean result = redisTemplate.opsForZSet().add(key, item, score); - log.info("zAdd(...) => result -> {}", result); + log.debug("zAdd(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } @@ -1935,9 +1935,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 本次添加进(key对应的)zset中的entry的个数 */ public static long zAdd(String key, Set> entries) { - log.info("zAdd(...) => key -> {}, entries -> {}", key, JSONUtil.toJsonStr(entries)); + log.debug("zAdd(...) => key -> {}, entries -> {}", key, JSONUtil.toJsonStr(entries)); Long count = redisTemplate.opsForZSet().add(key, entries); - log.info("zAdd(...) => count -> {}", count); + log.debug("zAdd(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -1954,9 +1954,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 实际移除了的项的个数 */ public static long zRemove(String key, Object... items) { - log.info("zRemove(...) => key -> {}, items -> {}", key, items); + log.debug("zRemove(...) => key -> {}, items -> {}", key, items); Long count = redisTemplate.opsForZSet().remove(key, items); - log.info("zRemove(...) => count -> {}", count); + log.debug("zRemove(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -1986,10 +1986,10 @@ public class RedisUtil implements ApplicationContextAware { * @return 实际移除了的项的个数 */ public static long zRemoveRange(String key, long startRange, long endRange) { - log.info("zRemoveRange(...) => key -> {}, startRange -> {}, endRange -> {}", + log.debug("zRemoveRange(...) => key -> {}, startRange -> {}, endRange -> {}", key, startRange, endRange); Long count = redisTemplate.opsForZSet().removeRange(key, startRange, endRange); - log.info("zRemoveRange(...) => count -> {}", count); + log.debug("zRemoveRange(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -2012,10 +2012,10 @@ public class RedisUtil implements ApplicationContextAware { * @return 实际移除了的项的个数 */ public static long zRemoveRangeByScore(String key, double minScore, double maxScore) { - log.info("zRemoveRangeByScore(...) => key -> {}, startIndex -> {}, startIndex -> {}", + log.debug("zRemoveRangeByScore(...) => key -> {}, startIndex -> {}, startIndex -> {}", key, minScore, maxScore); Long count = redisTemplate.opsForZSet().removeRangeByScore(key, minScore, maxScore); - log.info("zRemoveRangeByScore(...) => count -> {}", count); + log.debug("zRemoveRangeByScore(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -2031,9 +2031,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 修改后的score值 */ public static double zIncrementScore(String key, String item, double delta) { - log.info("zIncrementScore(...) => key -> {}, item -> {}, delta -> {}", key, item, delta); + log.debug("zIncrementScore(...) => key -> {}, item -> {}, delta -> {}", key, item, delta); Double scoreValue = redisTemplate.opsForZSet().incrementScore(key, item, delta); - log.info("zIncrementScore(...) => scoreValue -> {}", scoreValue); + log.debug("zIncrementScore(...) => scoreValue -> {}", scoreValue); if (scoreValue == null) { throw new RedisOpsResultIsNullException(); } @@ -2052,9 +2052,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 排名(等价于 : 索引) */ public static long zRank(String key, Object item) { - log.info("zRank(...) => key -> {}, item -> {}", key, item); + log.debug("zRank(...) => key -> {}, item -> {}", key, item); Long rank = redisTemplate.opsForZSet().rank(key, item); - log.info("zRank(...) => rank -> {}", rank); + log.debug("zRank(...) => rank -> {}", rank); if (rank == null) { throw new RedisOpsResultIsNullException(); } @@ -2073,9 +2073,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 排名(等价于 : 索引) */ public static long zReverseRank(String key, Object item) { - log.info("zReverseRank(...) => key -> {}, item -> {}", key, item); + log.debug("zReverseRank(...) => key -> {}, item -> {}", key, item); Long reverseRank = redisTemplate.opsForZSet().reverseRank(key, item); - log.info("zReverseRank(...) => reverseRank -> {}", reverseRank); + log.debug("zReverseRank(...) => reverseRank -> {}", reverseRank); if (reverseRank == null) { throw new RedisOpsResultIsNullException(); } @@ -2101,9 +2101,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 对应的item项集 */ public static Set zRange(String key, long start, long end) { - log.info("zRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("zRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); Set result = redisTemplate.opsForZSet().range(key, start, end); - log.info("zRange(...) => result -> {}", result); + log.debug("zRange(...) => result -> {}", result); return result; } @@ -2115,9 +2115,9 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRange(String, long, long) */ public static Set zWholeZSetItem(String key) { - log.info("zWholeZSetItem(...) => key -> {}", key); + log.debug("zWholeZSetItem(...) => key -> {}", key); Set result = redisTemplate.opsForZSet().range(key, 0, -1); - log.info("zWholeZSetItem(...) =>result -> {}", result); + log.debug("zWholeZSetItem(...) =>result -> {}", result); return result; } @@ -2142,9 +2142,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 对应的entry集 */ public static Set> zRangeWithScores(String key, long start, long end) { - log.info("zRangeWithScores(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("zRangeWithScores(...) => key -> {}, start -> {}, end -> {}", key, start, end); Set> entries = redisTemplate.opsForZSet().rangeWithScores(key, start, end); - log.info("zRangeWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); + log.debug("zRangeWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); return entries; } @@ -2156,9 +2156,9 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRangeWithScores(String, long, long) */ public static Set> zWholeZSetEntry(String key) { - log.info("zWholeZSetEntry(...) => key -> {}", key); + log.debug("zWholeZSetEntry(...) => key -> {}", key); Set> entries = redisTemplate.opsForZSet().rangeWithScores(key, 0, -1); - log.info("zWholeZSetEntry(...) => entries -> {}", key, JSONUtil.toJsonStr(entries)); + log.debug("zWholeZSetEntry(...) => entries -> {}", key, JSONUtil.toJsonStr(entries)); return entries; } @@ -2179,9 +2179,9 @@ public class RedisUtil implements ApplicationContextAware { * @return 对应的item项集 */ public static Set zRangeByScore(String key, double minScore, double maxScore) { - log.info("zRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); + log.debug("zRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); Set items = redisTemplate.opsForZSet().rangeByScore(key, minScore, maxScore); - log.info("zRangeByScore(...) => items -> {}", items); + log.debug("zRangeByScore(...) => items -> {}", items); return items; } @@ -2207,10 +2207,10 @@ public class RedisUtil implements ApplicationContextAware { */ public static Set zRangeByScore(String key, double minScore, double maxScore, long offset, long count) { - log.info("zRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}, offset -> {}, " + log.debug("zRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}, offset -> {}, " + "count -> {}", key, minScore, maxScore, offset, count); Set items = redisTemplate.opsForZSet().rangeByScore(key, minScore, maxScore, offset, count); - log.info("zRangeByScore(...) => items -> {}", items); + log.debug("zRangeByScore(...) => items -> {}", items); return items; } @@ -2227,10 +2227,10 @@ public class RedisUtil implements ApplicationContextAware { * 注: 当[minScore, maxScore]的范围比实际zset中score的范围大时, 返回范围上"交集"对应的项集合。 */ public static Set> zRangeByScoreWithScores(String key, double minScore, double maxScore) { - log.info("zRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}", + log.debug("zRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); Set> entries = redisTemplate.opsForZSet().rangeByScoreWithScores(key, minScore, maxScore); - log.info("zRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); + log.debug("zRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); return entries; } @@ -2249,12 +2249,12 @@ public class RedisUtil implements ApplicationContextAware { public static Set> zRangeByScoreWithScores(String key, double minScore, double maxScore, long offset, long count) { - log.info("zRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}," + log.debug("zRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}," + " offset -> {}, count -> {}", key, minScore, maxScore, offset, count); Set> entries = redisTemplate.opsForZSet().rangeByScoreWithScores(key, minScore, maxScore, offset, count); - log.info("zRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); + log.debug("zRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); return entries; } @@ -2265,9 +2265,9 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRange(String, long, long)。 只是zReverseRange这里会提前多一个倒序。 */ public static Set zReverseRange(String key, long start, long end) { - log.info("zReverseRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("zReverseRange(...) => key -> {}, start -> {}, end -> {}", key, start, end); Set entries = redisTemplate.opsForZSet().reverseRange(key, start, end); - log.info("zReverseRange(...) => entries -> {}", entries); + log.debug("zReverseRange(...) => entries -> {}", entries); return entries; } @@ -2277,9 +2277,9 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRangeWithScores(String, long, long)。 只是zReverseRangeWithScores这里会提前多一个倒序。 */ public static Set> zReverseRangeWithScores(String key, long start, long end) { - log.info("zReverseRangeWithScores(...) => key -> {}, start -> {}, end -> {}", key, start, end); + log.debug("zReverseRangeWithScores(...) => key -> {}, start -> {}, end -> {}", key, start, end); Set> entries = redisTemplate.opsForZSet().reverseRangeWithScores(key, start, end); - log.info("zReverseRangeWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); + log.debug("zReverseRangeWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); return entries; } @@ -2289,10 +2289,10 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRangeByScore(String, double, double)。 只是zReverseRangeByScore这里会提前多一个倒序。 */ public static Set zReverseRangeByScore(String key, double minScore, double maxScore) { - log.info("zReverseRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}", + log.debug("zReverseRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); Set items = redisTemplate.opsForZSet().reverseRangeByScore(key, minScore, maxScore); - log.info("zReverseRangeByScore(...) => items -> {}", items); + log.debug("zReverseRangeByScore(...) => items -> {}", items); return items; } @@ -2302,11 +2302,11 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRangeByScoreWithScores(String, double, double)。 只是zReverseRangeByScoreWithScores这里会提前多一个倒序。 */ public static Set> zReverseRangeByScoreWithScores(String key, double minScore, double maxScore) { - log.info("zReverseRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}", + log.debug("zReverseRangeByScoreWithScores(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); Set> entries = redisTemplate.opsForZSet().reverseRangeByScoreWithScores(key, minScore, maxScore); - log.info("zReverseRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); + log.debug("zReverseRangeByScoreWithScores(...) => entries -> {}", JSONUtil.toJsonStr(entries)); return entries; } @@ -2317,10 +2317,10 @@ public class RedisUtil implements ApplicationContextAware { * @see ZSetOps#zRangeByScore(String, double, double, long, long)。 只是zReverseRangeByScore这里会提前多一个倒序。 */ public static Set zReverseRangeByScore(String key, double minScore, double maxScore, long offset, long count) { - log.info("zReverseRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}, offset -> {}, " + log.debug("zReverseRangeByScore(...) => key -> {}, minScore -> {}, maxScore -> {}, offset -> {}, " + "count -> {}", key, minScore, maxScore, offset, count); Set items = redisTemplate.opsForZSet().reverseRangeByScore(key, minScore, maxScore, offset, count); - log.info("items -> {}", items); + log.debug("items -> {}", items); return items; } @@ -2333,9 +2333,9 @@ public class RedisUtil implements ApplicationContextAware { * @return [minScore, maxScore]中item的个数 */ public static long zCount(String key, double minScore, double maxScore) { - log.info("zCount(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); + log.debug("zCount(...) => key -> {}, minScore -> {}, maxScore -> {}", key, minScore, maxScore); Long count = redisTemplate.opsForZSet().count(key, minScore, maxScore); - log.info("zCount(...) => count -> {}", count); + log.debug("zCount(...) => count -> {}", count); if (count == null) { throw new RedisOpsResultIsNullException(); } @@ -2351,9 +2351,9 @@ public class RedisUtil implements ApplicationContextAware { * @return zset中item的个数 */ public static long zSize(String key) { - log.info("zSize(...) => key -> {}", key); + log.debug("zSize(...) => key -> {}", key); Long size = redisTemplate.opsForZSet().size(key); - log.info("zSize(...) => size -> {}", size); + log.debug("zSize(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2369,9 +2369,9 @@ public class RedisUtil implements ApplicationContextAware { * @return zset中item的个数 */ public static long zZCard(String key) { - log.info("zZCard(...) => key -> {}", key); + log.debug("zZCard(...) => key -> {}", key); Long size = redisTemplate.opsForZSet().zCard(key); - log.info("zZCard(...) => size -> {}", size); + log.debug("zZCard(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2386,9 +2386,9 @@ public class RedisUtil implements ApplicationContextAware { * @return item的score */ public static double zScore(String key, Object item) { - log.info("zScore(...) => key -> {}, item -> {}", key, item); + log.debug("zScore(...) => key -> {}, item -> {}", key, item); Double score = redisTemplate.opsForZSet().score(key, item); - log.info("zScore(...) => score -> {}", score); + log.debug("zScore(...) => score -> {}", score); if (score == null) { throw new RedisOpsResultIsNullException(); } @@ -2412,9 +2412,9 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)ZSet后, 该ZSet对应的size */ public static long zUnionAndStore(String key, String otherKey, String storeKey) { - log.info("zUnionAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); + log.debug("zUnionAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); Long size = redisTemplate.opsForZSet().unionAndStore(key, otherKey, storeKey); - log.info("zUnionAndStore(...) => size -> {}", size); + log.debug("zUnionAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2438,9 +2438,9 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)ZSet后, 该ZSet对应的size */ public static long zUnionAndStore(String key, Collection otherKeys, String storeKey) { - log.info("zUnionAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); + log.debug("zUnionAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); Long size = redisTemplate.opsForZSet().unionAndStore(key, otherKeys, storeKey); - log.info("zUnionAndStore(...) => size -> {}", size); + log.debug("zUnionAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2468,9 +2468,9 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)ZSet后, 该ZSet对应的size */ public static long zIntersectAndStore(String key, String otherKey, String storeKey) { - log.info("zIntersectAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); + log.debug("zIntersectAndStore(...) => key -> {}, otherKey -> {}, storeKey -> {}", key, otherKey, storeKey); Long size = redisTemplate.opsForZSet().intersectAndStore(key, otherKey, storeKey); - log.info("zIntersectAndStore(...) => size -> {}", size); + log.debug("zIntersectAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2490,10 +2490,10 @@ public class RedisUtil implements ApplicationContextAware { * @return add到(storeKey对应的)ZSet后, 该ZSet对应的size */ public static long zIntersectAndStore(String key, Collection otherKeys, String storeKey) { - log.info("zIntersectAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", + log.debug("zIntersectAndStore(...) => key -> {}, otherKeys -> {}, storeKey -> {}", key, otherKeys, storeKey); Long size = redisTemplate.opsForZSet().intersectAndStore(key, otherKeys, storeKey); - log.info("zIntersectAndStore(...) => size -> {}", size); + log.debug("zIntersectAndStore(...) => size -> {}", size); if (size == null) { throw new RedisOpsResultIsNullException(); } @@ -2597,7 +2597,7 @@ public class RedisUtil implements ApplicationContextAware { public static boolean getLockUntilTimeout(final String key, final String value, final long timeout, final TimeUnit unit, final long retryTimeoutLimit) { - log.info("getLockUntilTimeout(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, " + log.debug("getLockUntilTimeout(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, " + "retryTimeoutLimit -> {}ms", key, value, timeout, unit, retryTimeoutLimit); long startTime = Instant.now().toEpochMilli(); long now = startTime; @@ -2605,7 +2605,7 @@ public class RedisUtil implements ApplicationContextAware { try { boolean alreadyGotLock = getLock(key, value, timeout, unit, false); if (alreadyGotLock) { - log.info("getLockUntilTimeout(...) => consume time -> {}ms, result -> true", now - startTime); + log.debug("getLockUntilTimeout(...) => consume time -> {}ms, result -> true", now - startTime); return true; } } catch (Exception e) { @@ -2614,7 +2614,7 @@ public class RedisUtil implements ApplicationContextAware { } now = Instant.now().toEpochMilli(); } while (now < startTime + retryTimeoutLimit); - log.info("getLockUntilTimeout(...) => consume time -> {}ms, result -> false", now - startTime); + log.debug("getLockUntilTimeout(...) => consume time -> {}ms, result -> false", now - startTime); return false; } @@ -2653,7 +2653,7 @@ public class RedisUtil implements ApplicationContextAware { final long timeout, final TimeUnit unit, boolean recordLog) { if (recordLog) { - log.info("getLock(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, recordLog -> {}", + log.debug("getLock(...) => key -> {}, value -> {}, timeout -> {}, unit -> {}, recordLog -> {}", key, value, timeout, unit, recordLog); } Boolean result = redisTemplate.execute((RedisConnection connection) -> @@ -2663,7 +2663,7 @@ public class RedisUtil implements ApplicationContextAware { RedisStringCommands.SetOption.SET_IF_ABSENT) ); if (recordLog) { - log.info("getLock(...) => result -> {}", result); + log.debug("getLock(...) => result -> {}", result); } if (result == null) { throw new RedisOpsResultIsNullException(); @@ -2682,13 +2682,13 @@ public class RedisUtil implements ApplicationContextAware { * @return 释放锁是否成功 */ public static boolean releaseLock(final String key, final String value) { - log.info("releaseLock(...) => key -> {}, lockValue -> {}", key, value); + log.debug("releaseLock(...) => key -> {}, lockValue -> {}", key, value); Boolean result = redisTemplate.execute((RedisConnection connection) -> connection.eval(RELEASE_LOCK_LUA.getBytes(), ReturnType.BOOLEAN, 1, key.getBytes(StandardCharsets.UTF_8), value.getBytes(StandardCharsets.UTF_8)) ); - log.info("releaseLock(...) => result -> {}", result); + log.debug("releaseLock(...) => result -> {}", result); if (result == null) { throw new RedisOpsResultIsNullException(); } diff --git a/backend/java/sk-matrix-service/model/pom.xml b/backend/java/sk-matrix-service/model/pom.xml new file mode 100644 index 0000000..8725555 --- /dev/null +++ b/backend/java/sk-matrix-service/model/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + cn.skcks.matrix.v2 + sk-matrix-service + 1.0-SNAPSHOT + + + model + + + 17 + 17 + UTF-8 + + + + + cn.skcks.matrix.v2 + common + ${project.version} + + + + cn.skcks.matrix.v2 + orm + ${project.version} + + + + + org.mapstruct + mapstruct + + + org.mapstruct + mapstruct-processor + compile + + + + org.projectlombok + lombok + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/backend/java/sk-matrix-service/model/src/main/java/cn/skcks/matrix/v2/Main.java b/backend/java/sk-matrix-service/model/src/main/java/cn/skcks/matrix/v2/Main.java new file mode 100644 index 0000000..28c017b --- /dev/null +++ b/backend/java/sk-matrix-service/model/src/main/java/cn/skcks/matrix/v2/Main.java @@ -0,0 +1,7 @@ +package cn.skcks.matrix.v2; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} diff --git a/backend/java/sk-matrix-service/pom.xml b/backend/java/sk-matrix-service/pom.xml index b2e43a5..2a415a0 100644 --- a/backend/java/sk-matrix-service/pom.xml +++ b/backend/java/sk-matrix-service/pom.xml @@ -25,6 +25,7 @@ api auth services + model diff --git a/backend/java/sk-matrix-service/services/src/main/java/cn/skcks/matrix/v2/config/WebConfig.java b/backend/java/sk-matrix-service/services/src/main/java/cn/skcks/matrix/v2/config/WebConfig.java index 9566da9..559ec89 100644 --- a/backend/java/sk-matrix-service/services/src/main/java/cn/skcks/matrix/v2/config/WebConfig.java +++ b/backend/java/sk-matrix-service/services/src/main/java/cn/skcks/matrix/v2/config/WebConfig.java @@ -3,6 +3,8 @@ package cn.skcks.matrix.v2.config; import cn.skcks.matrix.v2.interceptor.AuthorizationInterceptor; import cn.skcks.matrix.v2.model.jwt.dto.Claims; import cn.skcks.matrix.v2.services.auth.AuthService; +import cn.skcks.matrix.v2.services.casbin.CasbinService; +import cn.skcks.matrix.v2.services.casbin.Permission; import cn.skcks.matrix.v2.services.jwt.JwtService; import cn.skcks.matrix.v2.utils.json.JsonResponse; import cn.skcks.matrix.v2.utils.json.ResponseStatus; @@ -19,6 +21,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.List; import java.util.Optional; @Slf4j @@ -30,9 +33,12 @@ public class WebConfig implements WebMvcConfigurer { private final JwtService jwtService; private final AuthService authService; - private final static JsonResponse NO_LOGIN = JsonResponse.build("未登录", ResponseStatus.UNAUTHORIZED); - private final static JsonResponse TOKEN_EXPIRE = JsonResponse.build("认证失效 请重新登录", ResponseStatus.UNAUTHORIZED); + private final CasbinService casbinService; + private final static JsonResponse NO_LOGIN = JsonResponse.build( ResponseStatus.UNAUTHORIZED,"未登录"); + private final static JsonResponse TOKEN_EXPIRE = JsonResponse.build(ResponseStatus.UNAUTHORIZED,"认证失效 请重新登录"); + + private final static JsonResponse NO_PERMISSION = JsonResponse.build(ResponseStatus.FORBIDDEN,"无权访问"); @Override public void addInterceptors(InterceptorRegistry registry) { @@ -64,6 +70,19 @@ public class WebConfig implements WebMvcConfigurer { }); } + private String getSystem(HttpServletRequest request) { + return Optional.ofNullable(request.getHeader("system")).orElseGet(() -> { + if (request.getCookies() != null) { + for (Cookie cookie : request.getCookies()) { + if (cookie.getName().equals("system")) { + return cookie.getValue(); + } + } + } + return CasbinService.DEFAULT_SYSTEM; + }); + } + private boolean auth(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String token = getToken(request); log.info("token => {}", token); @@ -86,6 +105,18 @@ public class WebConfig implements WebMvcConfigurer { return false; } - return true; + + String system = getSystem(request); + List permissions = casbinService.getUserPermission(claims.getUserId(),system); + log.debug("用户 {} 拥有的权限数量 {}", claims.getUserId(),permissions.size()); + for (Permission permission : permissions) { + log.info("permission {}", permission); + if(casbinService.enforce(permission.getName(),system,request.getRequestURI(),request.getMethod())){ + return true; + } + } + + writeResponse(response, NO_PERMISSION.getCode(), NO_PERMISSION); + return false; } } diff --git a/backend/java/sk-matrix-service/starter/src/main/resources/logback.xml b/backend/java/sk-matrix-service/starter/src/main/resources/logback.xml new file mode 100644 index 0000000..50ce03e --- /dev/null +++ b/backend/java/sk-matrix-service/starter/src/main/resources/logback.xml @@ -0,0 +1,54 @@ + + + + + logback + + + + + + + + + + + + + %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %yellow(at %class.%method) (%file:%line\) - %cyan(%msg%n) + + UTF-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +