com.jfinal.plugin.activerecord.dialect.MysqlDialect Java Examples

The following examples show how to use com.jfinal.plugin.activerecord.dialect.MysqlDialect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: _JFCodeGenerator.java    From sdb-mall with Apache License 2.0 6 votes vote down vote up
public TableMeta getTableMeta(String tableName) {
    if (tablemetaMap == null) {

        DataSource dataSource = _JFinalGenerator.getDataSource();

        MetaBuilder metaBuilder = new MetaBuilder(dataSource);
        metaBuilder.setDialect(new MysqlDialect());
        metaBuilder.addExcludedTable(_JFinalGenerator.excludedTable);
        List<TableMeta> tableMetas = metaBuilder.build();
        new DataGenerator(dataSource, null).rebuildColumnMetas(tableMetas);

        if (tableMetas.size() == 0) {
            System.out.println("TableMeta 数量为 0,不生成任何文件");
            return null;
        }
        Kv kv = Kv.create();
        for (TableMeta tableMeta : tableMetas) {
            kv.set(tableMeta.name, tableMeta);
        }
        tablemetaMap = kv;
    }
    return (TableMeta) tablemetaMap.get(tableName);
}
 
Example #2
Source File: _JFCodeGenerator.java    From sdb-mall with Apache License 2.0 6 votes vote down vote up
public void generate(){
    DataSource dataSource = _JFinalGenerator.getDataSource();

    MyMetaBuilder metaBuilder = new MyMetaBuilder(dataSource);
    metaBuilder.setDialect(new MysqlDialect());
    metaBuilder.addExcludedTable(_JFinalGenerator.excludedTable);
    List<TableMeta> tableMetas = metaBuilder.build();
    for (TableMeta tableMeta : tableMetas
            ) {
        if (serviceGenerate) {
            _JFCodeGenerator.me.service(tableMeta.modelName, tableMeta.name);
            _JFCodeGenerator.me.serviceImpl(tableMeta.modelName, tableMeta.name);
            _JFCodeGenerator.me.dao(tableMeta.modelName, tableMeta.name);
            _JFCodeGenerator.me.controller(tableMeta.modelName);
            _JFCodeGenerator.me.vue(tableMeta.modelName, tableMeta);
            _JFCodeGenerator.me.vueAddUpdate(tableMeta.modelName, tableMeta);
        }
    }
}
 
Example #3
Source File: ModelGenerator.java    From NewsRecommendSystem with MIT License 6 votes vote down vote up
/**
 * @param dataSource
 * @param baseModelPackageName
 * @param baseModelOutputDir
 * @param modelPackageName
 * @param modelOutputDir
 */
public static void main(String[] args)
{
	// base model 所使用的包名
	String baseModelPackageName = "top.qianxinyao.model.base";
	// base model 文件保存路径
	String baseModelOutputDir = PathKit.getRootClassPath() + "/../../src/top/qianxinyao/model/base";
	System.out.println("rootclasspath:"+baseModelOutputDir);
	// model 所使用的包名 (MappingKit 默认使用的包名)
	String modelPackageName = "top.qianxinyao.model";
	// model 文件保存路径 (MappingKit 与 DataDictionary 文件默认保存路径)
	String modelOutputDir = baseModelOutputDir+"/..";
	System.out.println(baseModelOutputDir);
	// 创建生成器
	Generator gernerator = new Generator(DBKit.getDataSource(), baseModelPackageName, baseModelOutputDir,
			modelPackageName, modelOutputDir);
	gernerator.setDialect(new MysqlDialect());
	// 设置是否在 Model 中生成 dao 对象
	gernerator.setGenerateDaoInModel(true);
	// 设置是否生成字典文件
	gernerator.setGenerateDataDictionary(false);
	// 生成
	gernerator.generate();
}
 
Example #4
Source File: JfinalModelClient.java    From my_curd with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    Generator generator = new Generator(MysqlDataSourceUtils.getDataSource(), baseModelPkg, baseModelDir, modelPkg, modelDir);
    generator.setDialect(new MysqlDialect());
    // 链式
    generator.setGenerateChainSetter(true);
    // model 中生成 dao 对象
    generator.setGenerateDaoInModel(true);

    // 数据字典
    generator.setGenerateDataDictionary(true);
    generator.setDataDictionaryFileName("dict.txt");
    generator.setDataDictionaryOutputDir(baseModelDir); // base 包下
    generator.setGenerateRemarks(true); // baseModel 字段是否生成注释

    // 添加不需要生成的表名
    // generator.addExcludedTable("adv");
    // 设置需要被移除的表名前缀用于生成modelName。例如表名 "osc_user",移除前缀 "osc_"后生成的model名为 "User"而非 OscUser
    // generator.setRemovedTableNamePrefixes("t_");
    //generator.addExcludedTable("SYS_USER_BAK");

    generator.generate();
}
 
Example #5
Source File: _JFinalDemoGenerator.java    From sqlhelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
	// base model 所使用的包名
	String baseModelPackageName = "com.demo.common.model.base";
	// base model 文件保存路径
	String baseModelOutputDir = PathKit.getWebRootPath() + "/src/main/java/com/demo/common/model/base";
	
	// model 所使用的包名 (MappingKit 默认使用的包名)
	String modelPackageName = "com.demo.common.model";
	// model 文件保存路径 (MappingKit 与 DataDictionary 文件默认保存路径)
	String modelOutputDir = baseModelOutputDir + "/..";
	
	// 创建生成器
	Generator generator = new Generator(getDataSource(), baseModelPackageName, baseModelOutputDir, modelPackageName, modelOutputDir);
	
	// 配置是否生成备注
	generator.setGenerateRemarks(true);
	
	// 设置数据库方言
	generator.setDialect(new MysqlDialect());
	
	// 设置是否生成链式 setter 方法
	generator.setGenerateChainSetter(false);
	
	// 添加不需要生成的表名
	generator.addExcludedTable("adv");
	
	// 设置是否在 Model 中生成 dao 对象
	generator.setGenerateDaoInModel(false);
	
	// 设置是否生成字典文件
	generator.setGenerateDataDictionary(false);
	
	// 设置需要被移除的表名前缀用于生成modelName。例如表名 "osc_user",移除前缀 "osc_"后生成的model名为 "User"而非 OscUser
	generator.setRemovedTableNamePrefixes("t_");
	
	// 生成
	generator.generate();
}
 
Example #6
Source File: Test.java    From my_curd with Apache License 2.0 5 votes vote down vote up
static void init() {
    Prop jdbcProp = PropKit.use("config-dev.txt");
    DruidPlugin dp = new DruidPlugin(jdbcProp.get("oa.jdbc.url"),
            jdbcProp.get("oa.jdbc.user"), jdbcProp.get("oa.jdbc.password"), jdbcProp.get("oa.jdbc.driver"));
    dp.start();
    ActiveRecordPlugin arp = new ActiveRecordPlugin(ActivitiConfig.DATASOURCE_NAME, dp);
    arp.setDialect(new MysqlDialect());
    arp.setShowSql(true);
    arp.start();
    ActivitiPlugin ap = new ActivitiPlugin();
    ap.start();
}
 
Example #7
Source File: AppConfig.java    From my_curd with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("Duplicates")
    @Override
    public void configPlugin(Plugins me) {
        // 数据源 1 (用户权限、组织机构、主数据 等) main
        DruidPlugin sysDruid = new DruidPlugin(configProp.get("jdbc.url"), configProp.get("jdbc.user"), configProp.get("jdbc.password"), configProp.get("jdbc.driver"));
        sysDruid.setInitialSize(configProp.getInt("jdbc.initialSize"));
        sysDruid.setMaxActive(configProp.getInt("jdbc.maxActive"));
        sysDruid.setMinIdle(configProp.getInt("jdbc.minIdle"));
        StatFilter statFilter = new StatFilter();
        WallFilter wall = new WallFilter();
        wall.setDbType(configProp.get("jdbc.dbType"));
        sysDruid.addFilter(statFilter);
        sysDruid.addFilter(wall);
        me.add(sysDruid);
        ActiveRecordPlugin sysActiveRecord = new ActiveRecordPlugin(sysDruid);
        sysActiveRecord.setDialect(new MysqlDialect());
        sysActiveRecord.setShowSql(activeProfile.equalsIgnoreCase("dev"));
        SystemModelMapping.mapping(sysActiveRecord);  // system 模块
        ExampleModelMapping.mapping(sysActiveRecord); // example 模块
        me.add(sysActiveRecord);
        log.info("设置 数据源 sysDruid sysActiveRecord 成功");


        // 数据源2 (activiti表、流程表单) my_curd_oa
        DruidPlugin oaDruid = new DruidPlugin(configProp.get("oa.jdbc.url"), configProp.get("oa.jdbc.user"), configProp.get("oa.jdbc.password"), configProp.get("oa.jdbc.driver"));
        oaDruid.setInitialSize(configProp.getInt("oa.jdbc.initialSize"));
        oaDruid.setMaxActive(configProp.getInt("oa.jdbc.maxActive"));
        oaDruid.setMinIdle(configProp.getInt("oa.jdbc.minIdle"));
        oaDruid.addFilter(statFilter);
        oaDruid.addFilter(wall);
        me.add(oaDruid);
        ActiveRecordPlugin oaActiveRecord = new ActiveRecordPlugin(ActivitiConfig.DATASOURCE_NAME,oaDruid);
        oaActiveRecord.setDialect(new MysqlDialect());
        oaActiveRecord.setShowSql(activeProfile.equalsIgnoreCase("dev"));
        OaModelMapping.mapping(oaActiveRecord);
        me.add(oaActiveRecord);
        log.info("设置 数据源 oaDruid oaActiveRecord 成功");

        // activiti 插件
        ActivitiPlugin ap = new ActivitiPlugin();
        me.add(ap);
        log.info("加载 Activiti 插件 成功");

        // 定时任务
        Cron4jPlugin cp = new Cron4jPlugin(configProp, "cron4j");
        me.add(cp);
        log.info("加载 Corn4j 插件 成功");

        //         redis 插件
//        RedisPlugin userRedis = new RedisPlugin("user", configProp.get("redis.host"),configProp.getInt("redis.port")
//                ,configProp.getInt("redis.timeout"),configProp.get("redis.password"),configProp.getInt("redis.database"));
//        me.add(userRedis);
//        log.info("加载redis 插件成功");

    }