package com.tiesheng.core.config.token;

import com.tiesheng.annotation.token.TokenIgnore;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;


/**
 * @author hao
 * @ProjectName CmccSpring
 * @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved
 * @Description 这里是对文件的描述
 * @data 2019-07-15
 * @note 这里写文件的详细功能和改动
 * @note
 */
@Aspect
@Component
public class TokenValidAspect {


    /**
     * 切入点
     */
    @Pointcut("execution(* com..controller..*.*(..))")
    public void methodArgs() {

    }


    /**
     * 获取操作日志说明
     *
     * @param joinPoint
     */
    @Before("methodArgs()")
    public void before(JoinPoint joinPoint) {

        // 过滤不要需要验证的接口
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
        if (apiTokenIgnore != null) {
            return;
        }

        // token验证
        TokenParse.get();
    }


}
