io.jboot.codegen.CodeGenHelpler Java Examples

The following examples show how to use io.jboot.codegen.CodeGenHelpler. 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: JbootModelGenerator.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootModelGenerator(String modelPackageName,
                           String baseModelPackageName, String modelOutputDir) {
    super(modelPackageName, baseModelPackageName, modelOutputDir);

    this.template = "/io/jboot/codegen/model/model_template.tp";
    this.metaBuilder = CodeGenHelpler.createMetaBuilder();

}
 
Example #2
Source File: JbootBaseModelGenerator.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootBaseModelGenerator(String baseModelPackageName,
                               String baseModelOutputDir) {
    super(baseModelPackageName, baseModelOutputDir);

    this.template = "/io/jboot/codegen/model/base_model_template.tp";
    this.metaBuilder = CodeGenHelpler.createMetaBuilder();
}
 
Example #3
Source File: JbootServiceImplGenerator.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootServiceImplGenerator(String basePackage, String modelPackage) {

        this.basePackage = basePackage;
        this.modelPackage = modelPackage;
        this.template = "io/jboot/codegen/service/service_impl_template.tp";
        this.metaBuilder = CodeGenHelpler.createMetaBuilder();
        this.outputDir = buildOutPutDir();

    }
 
Example #4
Source File: JbootServiceImplGenerator.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootServiceImplGenerator(String basePackage,String outputDir ,String modelPackage) {

        this.basePackage = basePackage;
        this.modelPackage = modelPackage;
        this.template = "io/jboot/codegen/service/service_impl_template.tp";
        this.metaBuilder = CodeGenHelpler.createMetaBuilder();
        this.outputDir = outputDir;

    }
 
Example #5
Source File: JbootServiceInterfaceGenerator.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootServiceInterfaceGenerator(String basePackage,String outputDir, String modelPacket) {
    super(basePackage, outputDir);
    this.modelPacket = modelPacket;
    this.basePackage = basePackage;
    this.template = "io/jboot/codegen/service/service_template.tp";
    this.metaBuilder = CodeGenHelpler.createMetaBuilder();

}
 
Example #6
Source File: AppServiceImplGenerator.java    From jboot-admin with Apache License 2.0 4 votes vote down vote up
public static void doGenerate() {
    AppServiceImplGeneratorConfig config = Jboot.config(AppServiceImplGeneratorConfig.class);

    System.out.println(config.toString());

    if (StrKit.isBlank(config.getModelpackage())) {
        System.err.println("jboot.admin.serviceimpl.ge.modelpackage 不可为空");
        System.exit(0);
    }

    if (StrKit.isBlank(config.getServicepackage())) {
        System.err.println("jboot.admin.serviceimpl.ge.servicepackage 不可为空");
        System.exit(0);
    }

    if (StrKit.isBlank(config.getServiceimplpackage())) {
        System.err.println("jboot.admin.serviceimpl.ge.serviceimplpackage 不可为空");
        System.exit(0);
    }

    String modelPackage = config.getModelpackage();
    String servicepackage = config.getServicepackage();
    String serviceimplpackage = config.getServiceimplpackage();

    System.out.println("start generate...");
    System.out.println("generate dir:" + servicepackage);

    DataSource dataSource = CodeGenHelpler.getDatasource();

    AppMetaBuilder metaBuilder = new AppMetaBuilder(dataSource);

    if (StrKit.notBlank(config.getRemovedtablenameprefixes())) {
        metaBuilder.setRemovedTableNamePrefixes(config.getRemovedtablenameprefixes().split(","));
    }

    if (StrKit.notBlank(config.getExcludedtableprefixes())) {
        metaBuilder.setSkipPre(config.getExcludedtableprefixes().split(","));
    }

    List<TableMeta> tableMetaList = metaBuilder.build();
    CodeGenHelpler.excludeTables(tableMetaList, config.getExcludedtable());

    new AppJbootServiceImplGenerator(servicepackage , modelPackage, serviceimplpackage).generate(tableMetaList);

    System.out.println("service generate finished !!!");

}
 
Example #7
Source File: AppServiceGenerator.java    From jboot-admin with Apache License 2.0 4 votes vote down vote up
public static void doGenerate() {
    AppServiceGeneratorConfig config = Jboot.config(AppServiceGeneratorConfig.class);

    System.out.println(config.toString());

    if (StrKit.isBlank(config.getModelpackage())) {
        System.err.println("jboot.admin.service.ge.modelpackage 不可为空");
        System.exit(0);
    }

    if (StrKit.isBlank(config.getServicepackage())) {
        System.err.println("jboot.admin.service.ge.servicepackage 不可为空");
        System.exit(0);
    }

    String modelPackage = config.getModelpackage();
    String servicepackage = config.getServicepackage();

    System.out.println("start generate...");
    System.out.println("generate dir:" + servicepackage);

    DataSource dataSource = CodeGenHelpler.getDatasource();

    AppMetaBuilder metaBuilder = new AppMetaBuilder(dataSource);

    if (StrKit.notBlank(config.getRemovedtablenameprefixes())) {
        metaBuilder.setRemovedTableNamePrefixes(config.getRemovedtablenameprefixes().split(","));
    }

    if (StrKit.notBlank(config.getExcludedtableprefixes())) {
        metaBuilder.setSkipPre(config.getExcludedtableprefixes().split(","));
    }

    List<TableMeta> tableMetaList = metaBuilder.build();
    CodeGenHelpler.excludeTables(tableMetaList, config.getExcludedtable());

    new JbootServiceInterfaceGenerator(servicepackage, modelPackage).generate(tableMetaList);

    System.out.println("service generate finished !!!");

}
 
Example #8
Source File: SystemGenerator.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) {

        String dbTables = "user,attachment,menu,option,payment_record,permission,role,utm," +
                "wechat_menu,wechat_reply," +
                "member,member_group,member_dist_amount,member_joined_record,member_price," +
                "user_address,user_amount,user_amount_statement,user_amount_payout," +
                "coupon,coupon_code,coupon_used_record," +
                "user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," +
                "user_openid,user_favorite,user_tag," +
                "payment_record";

        String optionsTables = "coupon,member,member_group,product,product_category,user_address," +
                "user_amount_statement,user_amount_payout,user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," +
                "payment_record,user_openid,member_joined_record,user_favorite,user_tag";

        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jpress3");
        JbootApplication.setBootArg("jboot.datasource.user", "root");
        JbootApplication.setBootArg("jboot.datasource.password", "123456");

        String modelPackage = "io.jpress.model";

        String baseModelPackage = modelPackage + ".base";

        String modelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate...dir:" + modelDir);

        Set<String> genTableNames = StrUtil.splitToSet(dbTables, ",");
        MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder();
        metaBuilder.setGenerateRemarks(true);
        List<TableMeta> tableMetas = metaBuilder.build();
        tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase()));


        new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas);

        String servicePackage = "io.jpress.service";
        String apiPath = PathKit.getWebRootPath() + "/../jpress-service-api/src/main/java/" + servicePackage.replace(".", "/");
        String providerPath = PathKit.getWebRootPath() + "/../jpress-service-provider/src/main/java/" + servicePackage.replace(".", "/") + "/provider";


        new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas);
        new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas);

        Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ",");
        if (optionsTableNames != null && optionsTableNames.size() > 0) {
            tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase()));
            new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        }
    }
 
Example #9
Source File: AddonGenerator.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void genCode() {


        JbootApplication.setBootArg("jboot.datasource.url", dbUrl);
        JbootApplication.setBootArg("jboot.datasource.user", dbUser);
        JbootApplication.setBootArg("jboot.datasource.password", dbPassword);

        String baseModelPackage = modelPackage + ".base";

        String modelDir = basePath + "/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = basePath + "/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate... dir:" + modelDir);

        MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder();
        metaBuilder.setGenerateRemarks(true);
        List<TableMeta> tableMetas = metaBuilder.build();

        Set<String> genTableNames = StrUtil.splitToSet(dbTables, ",");
        tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase()));


        new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas);

        String apiPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/");
        String providerPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/") + "/provider";

        new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas);
        new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas);

        if (genUI) {
            new AddonUIGenerator(basePath, addonName, modelPackage, tableMetas)
                    .genControllers()
                    .genEdit()
                    .genList();
        }

        Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ",");
        if (optionsTableNames != null && optionsTableNames.size() > 0) {
            tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase()));
            new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        }
    }
 
Example #10
Source File: AppModelGenerator.java    From jboot-admin with Apache License 2.0 3 votes vote down vote up
public static void doGenerate() {
    AppModelGeneratorConfig config = Jboot.config(AppModelGeneratorConfig.class);

    System.out.println(config.toString());

    if (StrKit.isBlank(config.getModelpackage())) {
        System.err.println("jboot.admin.model.ge.modelpackage 不可为空");
        System.exit(0);
    }

    String modelPackage = config.getModelpackage();
    String baseModelPackage = modelPackage + ".base";

    String modelDir = PathKit.getWebRootPath() + "/src/main/java/" + modelPackage.replace(".", "/");
    String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/" + baseModelPackage.replace(".", "/");

    System.out.println("start generate...");
    System.out.println("generate dir:" + modelDir);

    DataSource dataSource = CodeGenHelpler.getDatasource();

    AppMetaBuilder metaBuilder = new AppMetaBuilder(dataSource);

    if (StrKit.notBlank(config.getRemovedtablenameprefixes())) {
        metaBuilder.setRemovedTableNamePrefixes(config.getRemovedtablenameprefixes().split(","));
    }

    if (StrKit.notBlank(config.getExcludedtableprefixes())) {
        metaBuilder.setSkipPre(config.getExcludedtableprefixes().split(","));
    }

    List<TableMeta> tableMetaList = metaBuilder.build();
    CodeGenHelpler.excludeTables(tableMetaList, config.getExcludedtable());

    new JbootBaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetaList);
    new JbootModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetaList);

    System.out.println("entity generate finished !!!");

}
 
Example #11
Source File: JbootServiceInterfaceGenerator.java    From jboot with Apache License 2.0 3 votes vote down vote up
public JbootServiceInterfaceGenerator(String basePackage, String modelPacket) {
    super(basePackage, PathKit.getWebRootPath() + "/src/main/java/" + basePackage.replace(".", "/"));


    this.modelPacket = modelPacket;
    this.basePackage = basePackage;
    this.template = "io/jboot/codegen/service/service_template.tp";
    this.metaBuilder = CodeGenHelpler.createMetaBuilder();

}
 
Example #12
Source File: ServiceApiGenerator.java    From jpress with GNU Lesser General Public License v3.0 3 votes vote down vote up
public static void main(String[] args) {

        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jbootdemo");
        JbootApplication.setBootArg("jboot.datasource.user", "root");

        String basePackage = "io.jboot.codegen.service.test";
        String modelPackage = "io.jboot.codegen.model.test";

        List<TableMeta> tableMetaList = CodeGenHelpler.createMetaBuilder().build();
        CodeGenHelpler.excludeTables(tableMetaList, null);

        new ServiceApiGenerator(basePackage, modelPackage,"core-service").generate(tableMetaList);
    }
 
Example #13
Source File: ModuleGenerator.java    From jpress with GNU Lesser General Public License v3.0 2 votes vote down vote up
private void genCode() {

        String modelModuleName = "/module-" + moduleName + "-model";
        String serviceApiModuleName = "/module-" + moduleName + "-service-api";
        String serviceProviderModuleName = "/module-" + moduleName + "-service-provider";

        JbootApplication.setBootArg("jboot.datasource.url", dbUrl);
        JbootApplication.setBootArg("jboot.datasource.user", dbUser);
        JbootApplication.setBootArg("jboot.datasource.password", dbPassword);

        String baseModelPackage = modelPackage + ".base";

        String modelDir = basePath + modelModuleName + "/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = basePath + modelModuleName + "/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate... dir:" + modelDir);


        Set<String> genTableNames = StrUtil.splitToSet(dbTables, ",");

        MetaBuilder mb = CodeGenHelpler.createMetaBuilder();
        mb.setGenerateRemarks(true);
        List<TableMeta> tableMetas = mb.build();

        tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase()));


        new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas);

        String apiPath = basePath + serviceApiModuleName + "/src/main/java/" + servicePackage.replace(".", "/");
        String providerPath = basePath + serviceProviderModuleName + "/src/main/java/" + servicePackage.replace(".", "/") + "/provider";

        new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas);
        new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas);
        if (genUI) {
            new ModuleUIGenerator(moduleName, modelPackage, tableMetas).genListener().genControllers().genEdit().genList();
        }

        Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ",");
        if (optionsTableNames != null && optionsTableNames.size() > 0) {
            tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase()));
            new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        }

    }