
package com.pavis.admin.open.handler;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import org.springframework.stereotype.Component;
import com.pavis.admin.open.util.OpenApiUtils;

import java.lang.reflect.Method;

import static cn.dev33.satoken.annotation.handler.SaCheckPermissionHandler._checkMethod;

/**
 * 重定义注解 SaCheckPermission 的处理器
 *
 * 
 * @since 2024/10/25 12:03
 */
@Component
public class SaCheckPermissionHandler implements SaAnnotationHandlerInterface<SaCheckPermission> {

    @Override
    public Class<SaCheckPermission> getHandlerAnnotationClass() {
        return SaCheckPermission.class;
    }

    @Override
    public void checkMethod(SaCheckPermission at, Method method) {
        if (!OpenApiUtils.isSignParamExists()) {
            _checkMethod(at.type(), at.value(), at.mode(), at.orRole());
        }
    }
}
