| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import org.aspectj.lang.ProceedingJoinPoint;
|
| | | import org.aspectj.lang.Signature;
|
| | | import org.aspectj.lang.annotation.Around;
|
| | |
| | | import org.springframework.expression.spel.support.StandardEvaluationContext;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.annotation.integral.IntegralGetFrequencyLimit;
|
| | |
|
| | |
| | | public class IntegralGetFrequencyLimitAspect {
|
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | | private RedisManager redisManager;
|
| | |
|
| | | private ExpressionParser parser = new SpelExpressionParser();
|
| | |
|
| | |
| | | return expression.getValue(context).toString();
|
| | | }
|
| | |
|
| | | @Around("execution(public * com.yeshi.fanli.service.impl.integral.*.*(..))")
|
| | | @Around("execution(public * com.yeshi.fanli.service.impl.user.integral.*.*(..))")
|
| | | public Object requestSerializable(ProceedingJoinPoint joinPoint) throws Throwable {
|
| | | Signature signature = joinPoint.getSignature();
|
| | | MethodSignature methodSignature = (MethodSignature) signature;
|
| | |
| | |
|
| | | String catchKey = "integral-get-frequency-" + StringUtil.Md5(generateKeyBySpEL(key, joinPoint));
|
| | |
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | Jedis jedis =redisManager.getJedis();
|
| | | try {
|
| | | if (jedis.setnx(catchKey, "1") > 0) {
|
| | | jedis.expire(catchKey, timeS);
|
| | |
| | | } finally {
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | } catch (NoSuchMethodException e) {
|