| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.aspectj.lang.ProceedingJoinPoint;
|
| | | import org.aspectj.lang.JoinPoint;
|
| | | import org.aspectj.lang.Signature;
|
| | | import org.aspectj.lang.annotation.Aspect;
|
| | | import org.aspectj.lang.annotation.Before;
|
| | | import org.aspectj.lang.reflect.MethodSignature;
|
| | | import org.springframework.core.DefaultParameterNameDiscoverer;
|
| | |
| | | import org.springframework.expression.ExpressionParser;
|
| | | import org.springframework.expression.spel.standard.SpelExpressionParser;
|
| | | import org.springframework.expression.spel.support.StandardEvaluationContext;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.annotation.UserActive;
|
| | |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | // @Component
|
| | | // @Aspect
|
| | | // @Order(6)
|
| | | @Component
|
| | | @Aspect
|
| | | public class ActiveUserAspect {
|
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | private ExpressionParser parser = new SpelExpressionParser();
|
| | |
|
| | | private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
|
| | |
|
| | | public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) {
|
| | | public String generateKeyBySpEL(String spELString, JoinPoint joinPoint) {
|
| | | MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
| | | String[] paramNames = nameDiscoverer.getParameterNames(methodSignature.getMethod());
|
| | | Expression expression = parser.parseExpression(spELString);
|
| | |
| | | public static final String EDP = "execution(* com.yeshi.fanli.controller.client.*.*.*(..))";
|
| | |
|
| | | @Before(EDP)
|
| | | public void activeBefore(ProceedingJoinPoint joinPoint) {
|
| | | public void activeBefore(JoinPoint joinPoint) {
|
| | | try {
|
| | | Signature signature = joinPoint.getSignature();
|
| | | MethodSignature methodSignature = (MethodSignature) signature;
|
| | |
| | | String key = "useractive-" + uidStr;
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | |
|
| | | if (jedis.setnx(key, "1") > 0) {
|
| | | jedis.expire(key, 60);// 60s内不处理
|
| | | jedis.expire(key, 60 * 5);// 5分钟内不处理
|
| | | try {
|
| | | // TODO 用户活跃处理
|
| | |
|
| | | Long uid = Long.parseLong(uidStr);
|
| | | userInfoModifyRecordService.syncBeforeInfo(uid);
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra != null && !StringUtil.isNullOrEmpty(extra.getInviteCode()))
|
| | | integralGetService.addInviteActivate(uid);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|