package com.platform.modules.live.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author TONG
 * 2019/11/14 14:11
 **/
@Aspect
@Component
public class ClipsTenantAspect extends BaseTenantAspect {

    public ClipsTenantAspect(ApplicationContext applicationContext) {
        super(applicationContext);
    }

    @Around("@annotation(com.platform.modules.live.aspect.ClipsTenant)")
    public Object doLiveSceneValid(ProceedingJoinPoint pjp) throws Throwable {
        return super.doTenantValid(pjp);
    }

    @Override
    public TenantAspectRegistry buildTenantAspectRegistry(Method method) {
        ClipsTenant clipsTenant = method.getAnnotation(ClipsTenant.class);
        if (clipsTenant == null) {
            return null;
        }
        return new TenantAspectRegistry(clipsTenant.value(), clipsTenant.tenantTableClazz(), clipsTenant.method(), String.class);
    }
}
