Java Code Examples for io.jboot.codegen.CodeGenHelpler#createMetaBuilder()

The following examples show how to use io.jboot.codegen.CodeGenHelpler#createMetaBuilder() . 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: 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 7
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 8
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 9
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);
        }

    }