package com.hotent.base.aop;

import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.HttpUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 临时租户切面
 * @author liangjc
 * @company 广州宏天软件股份有限公司
 * @email liangjc@jee-soft.cn
 * @date 2022-10-28 11:30
 */
@Aspect
@Component
public class TemporaryTenantAspect {

	@Around("execution(* *..*Controller.*(..)) && @annotation(io.swagger.annotations.ApiOperation) || @annotation(com.hotent.base.annotation.TemporaryTenant)")
	public Object sysLogs(ProceedingJoinPoint joinPoint) throws Throwable{
        HttpServletRequest request = HttpUtil.getRequest();
        if(BeanUtils.isNotEmpty(request)) {
            request.setAttribute("enterController", true);
        }
		return joinPoint.proceed();
	}
}
