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

cn.schoolwow.quickdao.module.initial.flow.table.BeforeAutomaticCreateFlow Maven / Gradle / Ivy

There is a newer version: 5.3.1
Show newest version
package cn.schoolwow.quickdao.module.initial.flow.table;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.domain.QuickDAOConfig;
import cn.schoolwow.quickdao.domain.database.parent.UpgradeRequest;
import cn.schoolwow.quickdao.module.operation.flow.upgrade.DatabaseUpgradeFlow;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.Map;
import java.util.function.Consumer;

public class BeforeAutomaticCreateFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        QuickDAOConfig quickDAOConfig = (QuickDAOConfig) flowContext.checkData("quickDAOConfig");
        if(quickDAOConfig.upgradeOption.beforeAutomaticCreate.isEmpty()){
            flowContext.remark("跳过在自动建表语句之前执行语句");
            return;
        }
        for(Map.Entry> entry:quickDAOConfig.upgradeOption.beforeAutomaticCreate.entrySet()){
            UpgradeRequest upgradeRequest = new UpgradeRequest();
            upgradeRequest.comment = entry.getKey();
            upgradeRequest.upgradeConsumer = entry.getValue();

            flowContext.startFlow(new DatabaseUpgradeFlow())
                    .putTemporaryData("upgradeRequest", upgradeRequest)
                    .execute();
        }
    }

    @Override
    public String name() {
        return "自动建表语句执行之前";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy