From 50fbfe2cb4271e46f28eb53ea44e93671c7aef49 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期二, 20 六月 2023 12:11:12 +0800 Subject: [PATCH] !370 扩展第三方登录授权功能 * add 查看授权列表 * 优化第三方授权登录 * 第三方授权登录,加上配置 * 优化,第三方授权登录 * 新增加第三方登录授权功能 --- ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java new file mode 100644 index 0000000..f7f2392 --- /dev/null +++ b/ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java @@ -0,0 +1,65 @@ +package org.dromara.common.social.utils; + +import jakarta.annotation.PostConstruct; +import me.zhyd.oauth.cache.AuthStateCache; +import org.dromara.common.redis.utils.RedisUtils; +import org.dromara.common.social.config.properties.SocialProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.time.Duration; + +public class AuthRedisStateCache implements AuthStateCache { + + private SocialProperties socialProperties; + + /** + * 瀛樺叆缂撳瓨 + * + * @param key 缂撳瓨key + * @param value 缂撳瓨鍐呭 + */ + @Override + public void cache(String key, String value) { + // TODO: 鑷畾涔夊瓨鍏ョ紦瀛� + RedisUtils.setCacheObject(key, value, Duration.ofMillis(socialProperties.getTimeout())); + } + + /** + * 瀛樺叆缂撳瓨 + * + * @param key 缂撳瓨key + * @param value 缂撳瓨鍐呭 + * @param timeout 鎸囧畾缂撳瓨杩囨湡鏃堕棿(姣) + */ + @Override + public void cache(String key, String value, long timeout) { + // TODO: 鑷畾涔夊瓨鍏ョ紦瀛� + RedisUtils.setCacheObject(key, value, Duration.ofMillis(timeout)); + } + + /** + * 鑾峰彇缂撳瓨鍐呭 + * + * @param key 缂撳瓨key + * @return 缂撳瓨鍐呭 + */ + @Override + public String get(String key) { + // TODO: 鑷畾涔夎幏鍙栫紦瀛樺唴瀹� + return RedisUtils.getCacheObject(key); + } + + /** + * 鏄惁瀛樺湪key锛屽鏋滃搴攌ey鐨剉alue鍊煎凡杩囨湡锛屼篃杩斿洖false + * + * @param key 缂撳瓨key + * @return true锛氬瓨鍦╧ey锛屽苟涓攙alue娌¤繃鏈燂紱false锛歬ey涓嶅瓨鍦ㄦ垨鑰呭凡杩囨湡 + */ + @Override + public boolean containsKey(String key) { + // TODO: 鑷畾涔夊垽鏂璳ey鏄惁瀛樺湪 + return RedisUtils.hasKey(key); + } +} -- Gitblit v1.9.3