package com.czg.handler;

import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import com.czg.annotation.SaCheckMainShop;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * 员工权限校验
 * @author Administrator
 */
@Component
@Slf4j
public class SaCheckMainShopHandler implements SaAnnotationHandlerInterface<SaCheckMainShop> {

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

    @Override
    public void checkMethod(SaCheckMainShop at, Method method) {
        boolean mainShop = StpKit.USER.isMainShop();
        if (!mainShop) {
            throw new CzgException("此接口仅主店可操作");
        }
    }
}
