package org.generator;

import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;

import java.io.IOException;
import java.sql.SQLException;

/**
 * @program: ShSecpSystem
 * @description: 生成器启动器
 * @author: fengjun
 * @create: 2021-10-30
 */
public class GeneratorMain {
    //模块包(xml)
    public static final String MODULE_PACKAGE = "mapper";
    private static final JdbcParams jdbc = new JdbcParams();
    static {
        jdbc.setDriveClass("com.mysql.cj.jdbc.Driver");
        jdbc.setUrl("jdbc:mysql://192.168.1.188:3306/ag_one_test");
        jdbc.setUsername("root");
        jdbc.setPassword("agmysqlroot");
    }

    public static String getProjectPath() {
        return System.getProperty("user.dir");
    }


    //不考虑用户
    static class Generator{
        public static void main(String[] args) throws XMLParserException, SQLException, IOException, InterruptedException, InvalidConfigurationException {
            String tableNames = "student";
            String[] tableNameArray = tableNames.split(",");
            for (String tableName : tableNameArray) {
                GeneratorStarter.generate(tableName,jdbc);
            }
        }
    }
    //考虑用户 ,同一个用户
    static class GeneratorMultiple{
        public static void main(String[] args) throws XMLParserException, SQLException, IOException, InterruptedException, InvalidConfigurationException {
            String tableNames = "student";
            String tableSchema = "";
            String[] tableNameArray = tableNames.split(",");
            for (String tableName : tableNameArray) {
                GeneratorStarter.generate(tableName,tableSchema,jdbc);
            }
        }
    }
//    //考虑用户 ,不同用户
//    static class GeneratorMultipleDiff{
//        public static void main(String[] args) throws XMLParserException, SQLException, IOException, InterruptedException, InvalidConfigurationException {
//            String tableNames = "CSBK_BILL";
//            String[] tableNameArray = tableNames.split(",");
//            for (String tableName : tableNameArray) {
//                GeneratorStarter.generate(tableName);
//            }
//        }
//    }

    //基础路径
    public static final String BASE_PATH = getProjectPath()+"\\IlogDynamicModule\\src\\main\\";
    //domain包路径
    public static final String DOMAIN_PACKAGE = "com.ag.example.domain";
    //pojo包路径
    public static final String POJO_PACKAGE = "com.ag.example.pojo";
    //xml 项目位置
    public static final String SQL_PROJECT = BASE_PATH+"resources\\"+MODULE_PACKAGE;
}
