All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.erupt.core.invoke.PowerInvoke Maven / Gradle / Ivy

There is a newer version: 1.12.17
Show newest version
package xyz.erupt.core.invoke;

import xyz.erupt.annotation.fun.PowerHandler;
import xyz.erupt.annotation.fun.PowerObject;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.core.util.EruptSpringUtil;
import xyz.erupt.core.view.EruptModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author YuePeng
 * date 2021/3/16 00:07
 */
public class PowerInvoke {

    private static final List> powerHandlerStack = new ArrayList<>();

    public static void registerPowerHandler(Class powerHandler) {
        powerHandlerStack.add(powerHandler);
    }

    //动态获取erupt power值
    public static PowerObject getPowerObject(EruptModel eruptModel) {
        Power power = eruptModel.getErupt().power();
        if (eruptModel.getErupt().authVerify()) {
            PowerObject powerBean = new PowerObject(power);
            if (eruptModel.getErupt().authVerify()) {
                powerHandlerStack.forEach(ph -> EruptSpringUtil.getBean(ph).handler(powerBean));
            }
            if (!power.powerHandler().isInterface()) EruptSpringUtil.getBean(power.powerHandler()).handler(powerBean);
            return powerBean;
        } else {
            return new PowerObject(power);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy