From 651a15c78f668bef3859d9ed1bb7ad0b669d3600 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 03 七月 2020 17:52:07 +0800
Subject: [PATCH] 多APP优化

---
 fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java |   66 +++++++++++++++------------------
 1 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java b/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
index 2ba1493..e77b4ab 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
@@ -5,6 +5,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.stereotype.Component;
 import org.yeshi.utils.JsonUtil;
 
@@ -151,7 +152,7 @@
 	public void saveTaoBaoGoodsBriefTemp(TaoBaoGoodsBrief goods) {
 		if (goods == null)
 			return;
-		String key = "taobao-goods-temp-" + goods.getAuctionId();
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsTemp, goods.getAuctionId() + "");
 		if (Constant.IS_OUTNET) {
 			// 鏆傚瓨4涓皬鏃剁殑鍒嗕韩
 			cacheCommonString(key, JsonUtil.getSimpleGson().toJson(goods), 60 * 60 * 4);
@@ -159,7 +160,7 @@
 	}
 
 	public TaoBaoGoodsBrief getTaoBaoGoodsTemp(Long auctionId) {
-		String key = "taobao-goods-temp-" + auctionId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsTemp, auctionId + "");
 		String value = getCommonString(key);
 		if (!StringUtil.isNullOrEmpty(value)) {
 			return JsonUtil.getSimpleGson().fromJson(value, TaoBaoGoodsBrief.class);
@@ -173,14 +174,14 @@
 	 * @param auctionId
 	 */
 	public void deleteTaoBaoGoodsBrief(Long auctionId) {
-		String key = "taobao-goods-" + auctionId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoods, auctionId + "");
 		if (Constant.IS_OUTNET)
 			removeKey(key);
 	}
 
 	public TaoBaoGoodsBrief getTaoBaoGoodsBrief(long auctionId) throws TaobaoGoodsDownException {
 		long startTime = System.currentTimeMillis();
-		String key = "taobao-goods-" + auctionId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoods, auctionId + "");
 		String value = "";
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
@@ -201,8 +202,8 @@
 		}
 	}
 
-	public List<ImageInfo> getTaoBaoGoodsDetailImgs(long auctionId) {
-		String key = "taobao-goods-detailimgs-size-" + auctionId;
+	public List<ImageInfo> getTaoBaoGoodsDetailImgs(long auctionId, SystemEnum system) {
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsDetailimgs, auctionId + "");
 		String value = "";
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
@@ -210,7 +211,7 @@
 		if (StringUtil.isNullOrEmpty(value)) {
 			List<ImageInfo> list = null;
 			try {
-				list = TaoBaoUtil.getTBDetailImageWithSizev2(auctionId, configService.getTaoBaoProxyIP());
+				list = TaoBaoUtil.getTBDetailImageWithSizev2(auctionId, configService.getTaoBaoProxyIP(system));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
@@ -231,7 +232,7 @@
 
 	public String getXCXCouponToken(TaoBaoGoodsBrief tb) {
 		List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
-		String key = "taobao-couple-xcx-" + tb.getAuctionId();
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoCoupleXCX, tb.getAuctionId() + "");
 		String value = "";
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
@@ -254,7 +255,7 @@
 	 * @param ip
 	 */
 	public boolean ipFrequencyLimit(String ip, String apiName) {
-		String key = ip + "-" + StringUtil.Md5(apiName);
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, ip + "-" + StringUtil.Md5(apiName));
 		Jedis jedis = jedisPool.getResource();
 		try {
 			long count = jedis.incr(key);
@@ -270,7 +271,7 @@
 	}
 
 	public boolean frequencyLimit(String key, int timeS, int num) {
-		key = "frequency-" + key;
+		key = RedisKeyEnum.getRedisKey(RedisKeyEnum.frequencyLimit, key);
 		Jedis jedis = jedisPool.getResource();
 		try {
 			long count = jedis.incr(key);
@@ -292,7 +293,7 @@
 	 * @return
 	 */
 	public List<String> getTBImg(Long auctionId) {
-		String key = "taobao-img-" + auctionId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoImgs, auctionId + "");
 		String value = "";
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
@@ -321,7 +322,7 @@
 	 * @return
 	 */
 	public TaoBaoShopInfo getTBShopInfo(String shopTitle, Long sellerId, Long auctionId) {
-		String key = "taobao-shop-" + sellerId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoShop, sellerId +"");
 		String value = "";
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
@@ -370,7 +371,7 @@
 	public boolean isSmsFrequencyLimit(String phone, int type) {
 		if (!Constant.IS_OUTNET)
 			return false;
-		String key = "sms-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMS,  phone + "-" + type);
 		String value = getCommonString(key);
 		if (StringUtil.isNullOrEmpty(value))
 			return false;
@@ -387,14 +388,14 @@
 	public void sendSms(String phone, int type) {
 		if (!Constant.IS_OUTNET)
 			return;
-		String key = "sms-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMS,  phone + "-" + type);
 		setString(key, "1", 10);
 	}
 
 	public void clearSMSFrequencyLimit(String phone, int type) {
 		if (!Constant.IS_OUTNET)
 			return;
-		String key = "sms-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMS,  phone + "-" + type);
 		removeKey(key);
 	}
 
@@ -407,7 +408,7 @@
 	 */
 
 	public void saveSMSVCode(String phone, int type, String code) {
-		String key = "smscode-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + type);
 		// 淇濆瓨2鍒嗛挓
 		setString(key, code, 120);
 	}
@@ -421,7 +422,7 @@
 	public String getSMSVCode(String phone, int type) {
 		// if (!Constant.IS_OUTNET)
 		// return "";
-		String key = "smscode-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + type);
 		// 淇濆瓨2鍒嗛挓
 		return getString(key);
 	}
@@ -436,7 +437,7 @@
 	public void clearSMSVCode(String phone, int type) {
 		// if (!Constant.IS_OUTNET)
 		// return;
-		String key = "smscode-" + phone + "-" + type;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + type);
 		removeKey(key);
 	}
 
@@ -444,8 +445,7 @@
 	 * 淇濆瓨缁戝畾鏀粯瀹濈煭淇¢獙璇佺爜鐨勬纭��
 	 */
 	public void saveBindAlipayAccountSMSState(String phone) {
-		String key = "smsstate-alipay-" + phone;
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSStateAlipay, phone + "" );
 		// 楠岃瘉鍚庡崄鍒嗛挓鏈夋晥
 		setString(key, "1", 10 * 60);
 	}
@@ -457,7 +457,7 @@
 	 * @return
 	 */
 	public boolean isBindAlipayAccountSMSStateValid(String phone) {
-		String key = "smsstate-alipay-" + phone;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSStateAlipay, phone + "" );
 		return !StringUtil.isNullOrEmpty(getString(key));
 	}
 
@@ -469,8 +469,7 @@
 	 */
 	public void setInviteShortLink(long uid, String shortlink) {
 		String value = "";
-		String key = "invite-shortlink-" + uid;
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.inviteShortLink, uid + "" );
 		if (Constant.IS_OUTNET) {
 
 			value = getCommonString(key);
@@ -489,10 +488,8 @@
 	 * @return
 	 */
 	public String getInviteShortLink(long uid) {
-
 		String value = "";
-		String key = "invite-shortlink-" + uid;
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.inviteShortLink, uid + "" );
 		if (Constant.IS_OUTNET)
 			value = getCommonString(key);
 
@@ -506,7 +503,7 @@
 	 * @param token
 	 */
 	public void saveCommonTaoToken(Long auctionId, String token) {
-		String key = "taobao-common-token-" + auctionId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenCommon, auctionId + "" );
 		if (Constant.IS_OUTNET) {
 			if (!StringUtil.isNullOrEmpty(token)) {
 				// 鍙d护缂撳瓨10澶�
@@ -522,8 +519,7 @@
 	 * @return
 	 */
 	public String getCommonTaoToken(Long auctionId) {
-		String key = "taobao-common-token-" + auctionId;
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenCommon, auctionId + "" );
 		if (Constant.IS_OUTNET) {
 			return getCommonString(key);
 		}
@@ -537,7 +533,7 @@
 	 * @param token
 	 */
 	public void saveTLJToken(String url, String token) {
-		String key = "taobao-tlj-token-" + StringUtil.Md5(url);
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenTLJ, StringUtil.Md5(url));
 		if (Constant.IS_OUTNET) {
 			if (!StringUtil.isNullOrEmpty(token)) {
 				// 鍙d护缂撳瓨10澶�
@@ -553,8 +549,7 @@
 	 * @return
 	 */
 	public String getTLJToken(String url) {
-		String key = "taobao-common-token-" + StringUtil.Md5(url);
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenTLJ, StringUtil.Md5(url));
 		if (Constant.IS_OUTNET) {
 			return getCommonString(key);
 		}
@@ -568,7 +563,7 @@
 	 * @param key
 	 * @param seconds
 	 */
-	public void saveObj(Class<?> clazz, String key, Integer seconds) {
+	public void saveObj(Object clazz, String key, Integer seconds) {
 		if (clazz == null)
 			return;
 		String value = new Gson().toJson(clazz);
@@ -621,8 +616,7 @@
 	}
 
 	public JDGoods getJDGoods(long goodsId) {
-		String key = "jingdong-goods-" + goodsId;
-
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.jingDongGoods, goodsId +"");
 		String value = getCommonString(key);
 		if (StringUtil.isNullOrEmpty(value)) {
 			JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
@@ -641,7 +635,7 @@
 	}
 
 	public PDDGoodsDetail getPDDGoodsDetail(long goodsId) {
-		String key = "pinduoduo-goods-" + goodsId;
+		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.pinDuoDuoGoods, goodsId +"");
 
 		String value = getCommonString(key);
 		if (StringUtil.isNullOrEmpty(value)) {

--
Gitblit v1.8.0