|
|
@@ -3,10 +3,12 @@ package com.cyksj.redis;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Getter;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.ZSetOperations;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
@@ -27,6 +29,16 @@ public class RedisService {
|
|
|
@Resource
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
+ public static String env = "dev";
|
|
|
+
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String active;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void init(){
|
|
|
+ env = active + ":";
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 指定缓存失效时间
|
|
|
@@ -103,7 +115,7 @@ public class RedisService {
|
|
|
* @return 值
|
|
|
*/
|
|
|
public String getStr(String key) {
|
|
|
- return key == null ? null : StringUtil.getString(redisTemplate.opsForValue().get(key));
|
|
|
+ return key == null ? null : StringUtil.getString(redisTemplate.opsForValue().get(key));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -735,9 +747,9 @@ public class RedisService {
|
|
|
@Getter
|
|
|
public enum key {
|
|
|
|
|
|
- CORP_AUTH_MAPPING_KEY("mapping:corp:", "企业微信授权跳转", 60 * 60 * 24L),
|
|
|
- CORP_ACCESSO_TOKEN_KEY("corp:access_token:", "corp_access_token", 60 * 30L),
|
|
|
- MAPPING_INDEX_KEY("mapper:index:", "授权跳转", 60 * 10L),
|
|
|
+ CORP_AUTH_MAPPING_KEY("mapping:corp:", "企业微信授权跳转", 60 * 60 * 24L),
|
|
|
+ CORP_ACCESSO_TOKEN_KEY("corp:access_token:", "corp_access_token", 60 * 30L),
|
|
|
+ MAPPING_INDEX_KEY("mapper:index:", "授权跳转", 60 * 10L),
|
|
|
WX_LOGIN_AUTH_URI("wx_login_auth_uri:%s:%s", "微信网页授权登录uri", 60 * 60 * 24L),
|
|
|
RECOMMEND_COUPON_DAY("recommend_coupon_day:%s", "推荐优惠券弹窗", 60 * 60 * 24L),
|
|
|
EMAIL_CODE_KEY("email_code_key:%s", "邮箱验证码", 60 * 3),
|
|
|
@@ -821,8 +833,11 @@ public class RedisService {
|
|
|
|
|
|
private long timeout;
|
|
|
|
|
|
+ public String getEnvName() {
|
|
|
+ return this.name + env;
|
|
|
+ }
|
|
|
public String getNameFormat(Object ... str) {
|
|
|
- return String.format(this.getName(), str);
|
|
|
+ return String.format(this.getEnvName(), str);
|
|
|
}
|
|
|
|
|
|
}
|