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

cn.schoolwow.quickdao.module.database.dcl.service.CreateDatabaseUserFlow Maven / Gradle / Ivy

There is a newer version: 5.3.1
Show newest version
package cn.schoolwow.quickdao.module.database.dcl.service;

import cn.schoolwow.quickdao.domain.database.dcl.DataBaseUser;
import cn.schoolwow.quickdao.domain.database.parent.DatabaseType;
import cn.schoolwow.quickdao.module.database.parent.flow.executor.ExecuteUpdateConnectionFlow;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class CreateDatabaseUserFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DatabaseType databaseType = (DatabaseType) flowContext.checkData("databaseType");
        DataBaseUser dataBaseUser = (DataBaseUser) flowContext.checkData("dataBaseUser");

        flowContext.putTemporaryData("name", "创建数据库用户");
        switch (databaseType){
            case Mysql:{
                flowContext.putTemporaryData("sql", "create user '" + dataBaseUser.username + "'@'" + dataBaseUser.host + "' identified by '" + dataBaseUser.password + "';");
            };break;
            case Postgresql:{
                flowContext.putTemporaryData("sql", "create user " + dataBaseUser.username + " with password '" + dataBaseUser.password + "';");
            };break;
            default:{
                throw new UnsupportedOperationException("当前数据库不支持创建数据库用户!数据库类型:"+databaseType.name());
            }
        }
        flowContext.executeFlowList(new ExecuteUpdateConnectionFlow());
    }

    @Override
    public String name() {
        return "创建数据库用户";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy