From 585a05bef033fa4b6a02b5d3afd3b305b3914abb Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期五, 15 三月 2019 15:24:06 +0800 Subject: [PATCH] 券推送、今天推荐加入版本推送 用户活跃检测开启任务 --- fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java | 33 ++++++++++++++++++++++----------- 1 files changed, 22 insertions(+), 11 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java index 2dd362a..3d5bbb2 100644 --- a/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java +++ b/fanli/src/main/java/com/yeshi/fanli/aspect/ActiveUserAspect.java @@ -21,9 +21,9 @@ * @author Administrator * */ -//@Component -//@Aspect -//@Order(6) +@Component +@Aspect +@Order(6) public class ActiveUserAspect { @Resource(name = "taskExecutor") @@ -38,31 +38,43 @@ public static final String EDP = "execution(* com.yeshi.fanli.controller.client.*.*(..))"; -// @Around(EDP) + @Around(EDP) public Object activeAround(ProceedingJoinPoint joinPoint) throws Throwable { + Long uid = null; + ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); + HttpServletRequest request = servletContainer.getRequest(); - Object[] args = joinPoint.getArgs(); - - Long uid = null; - HttpServletRequest request = servletContainer.getRequest(); String str_uid = request.getParameter("uid"); if (str_uid != null && str_uid.trim().length() > 0) { uid = Long.parseLong(str_uid); } - System.out.println("uid: "+ uid); final Long uuid = uid; executor.execute(new Runnable() { @Override public void run() { + if (uuid == null) { return; } + + // 缂撳瓨uid鐨凨ey + String key = "activeUid_" + uuid; + + // 缂撳瓨涓槸鍚﹀瓨鍦╱id + String cacheValue = redisManager.getCommonString(key); + if (cacheValue != null && cacheValue.trim().length() > 0) { + return; + } + + // 鍔犲叆缂撳瓨 20鍒嗛挓 + redisManager.cacheCommonString("activeUid_" + uuid, uuid.toString(), 60 * 20); + // 鎺ユ敹鍒� try { @@ -73,8 +85,7 @@ } }); - return joinPoint.proceed(args); + return joinPoint.proceed(joinPoint.getArgs()); } - } -- Gitblit v1.8.0