From 74be2e325a3bc4dbe95e9825c18574e1102877c5 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 27 八月 2019 15:08:54 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

---
 fanli/src/main/java/com/yeshi/fanli/aspect/integral/IntegralGetFrequencyLimitAspect.java |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/aspect/IntegralGetVersionLimitAspect.java b/fanli/src/main/java/com/yeshi/fanli/aspect/integral/IntegralGetFrequencyLimitAspect.java
similarity index 73%
copy from fanli/src/main/java/com/yeshi/fanli/aspect/IntegralGetVersionLimitAspect.java
copy to fanli/src/main/java/com/yeshi/fanli/aspect/integral/IntegralGetFrequencyLimitAspect.java
index 2de7abc..75f0472 100644
--- a/fanli/src/main/java/com/yeshi/fanli/aspect/IntegralGetVersionLimitAspect.java
+++ b/fanli/src/main/java/com/yeshi/fanli/aspect/integral/IntegralGetFrequencyLimitAspect.java
@@ -1,6 +1,5 @@
-package com.yeshi.fanli.aspect;
+package com.yeshi.fanli.aspect.integral;
 
-import java.io.IOException;
 import java.lang.reflect.Method;
 
 import javax.annotation.Resource;
@@ -20,17 +19,19 @@
 import org.yeshi.utils.NumberUtil;
 
 import com.yeshi.fanli.entity.bus.user.UserActiveLog;
-import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.user.UserActiveLogService;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.VersionUtil;
+import com.yeshi.fanli.util.annotation.integral.IntegralGetFrequencyLimit;
 import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit;
 
 @Component
 @Aspect
-public class IntegralGetVersionLimitAspect {
+public class IntegralGetFrequencyLimitAspect {
 
 	@Resource
-	private UserActiveLogService userActiveLogService;
+	private RedisManager redisManager;
 
 	private ExpressionParser parser = new SpelExpressionParser();
 
@@ -56,19 +57,20 @@
 		try {
 			Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(joinPoint.getSignature().getName(),
 					targetMethod.getParameterTypes());
-			if (realMethod.isAnnotationPresent(IntegralGetVersionLimit.class)) {
-				IntegralGetVersionLimit rs = realMethod.getAnnotation(IntegralGetVersionLimit.class);
-				String key = rs.uid();
-				String uid = generateKeyBySpEL(key, joinPoint);
-				if (uid != null && NumberUtil.isNumeric(uid)) {
-					UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(Long.parseLong(uid));
-					if (activeLog != null) {
-						// 灏忎簬1.6.5鐗堟湰涓嶅鍔犵Н鍒�
-						if (!VersionUtil.greaterThan_1_6_5(
-								"appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
-								activeLog.getVersionCode()))
-							return null;
-					}
+			if (realMethod.isAnnotationPresent(IntegralGetFrequencyLimit.class)) {
+				IntegralGetFrequencyLimit rs = realMethod.getAnnotation(IntegralGetFrequencyLimit.class);
+				String key = rs.key();
+				String catchKey = StringUtil.Md5("integral-get-frequency-" + generateKeyBySpEL(key, joinPoint));
+
+				if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(catchKey))) {
+					return null;
+				}
+
+				try {
+					return joinPoint.proceed();
+				} finally {
+					// 30鍒嗛挓鍐呬笉鍏佽鎿嶄綔
+					redisManager.cacheCommonString(catchKey, "1", 60 * 30);
 				}
 			}
 		} catch (NoSuchMethodException e) {
@@ -78,7 +80,7 @@
 		}
 
 		return joinPoint.proceed();
-		
+
 	}
 
 }

--
Gitblit v1.8.0