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

com.nbsaas.boot.generator.GeneratorApp Maven / Gradle / Ivy

There is a newer version: 1.1.10-2024
Show newest version
/*
 *
 *  * 版权声明和许可协议
 *  *
 *  * 版权所有 (c) 2023 纽百特®
 *  * 版权所有,保留所有权利
 *  *
 *  * 本软件使用 MIT 许可协议进行许可,详情请参阅:
 *  *
 *  *   https://opensource.org/licenses/MIT
 *  *
 *  * 更多信息,请访问我们的网站:
 *  *
 *  *   http://www.nbsaas.com
 *  *
 *  * 纽百特® 是西安纽百特科技有限责任公司的注册商标,未经授权不得使用。
 *
 */

package com.nbsaas.boot.generator;

import com.nbsaas.boot.chain.impl.ChainBase;
import com.nbsaas.boot.generator.beans.FormBean;
import com.nbsaas.boot.generator.beans.FormBeanConvert;
import com.nbsaas.boot.generator.command.common.FinishCommand;
import com.nbsaas.boot.generator.command.vue3.VueCommand;
import com.nbsaas.boot.generator.config.Config;
import com.nbsaas.boot.generator.context.InputRequestObject;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.nio.file.Files;
import java.util.List;

public class GeneratorApp {

    public static void main(String[] args) throws Exception {

        //config/bootadmin/system.yml
        //config/bootadmin/user.yml
        generator("config/vue/ad.yml");

    }

    public static void generator(String configFile) throws Exception {
        Yaml yaml = new Yaml();
        String baseFile = GeneratorApp.class.getClassLoader().getResource("").getFile();
        File f = new File(baseFile + configFile);
        //读入文件

        Config config = yaml.loadAs(Files.newInputStream(f.toPath()), Config.class);
        if (config.getModuleName() == null) {
            config.setModuleName(config.getProjectName());
        }
        config.setBase(baseFile);

        List tables = config.getEntities();
        if (tables == null) {
            return;
        }
        for (String table : tables) {

            FormBean formBean = new FormBeanConvert().convertClass(Class.forName(config.getEntityPackage() + "." + table));

            ChainBase> chainBase = new ChainBase<>();
//            chainBase.addCommand(new DomainCommand());
//            chainBase.addCommand(new ApiCommand());
//            chainBase.addCommand(new ConvertCommand());
//            chainBase.addCommand(new ControllerAdminCommand());
//            chainBase.addCommand(new ControllerFrontCommand());
//            chainBase.addCommand(new RestCommand());
//            chainBase.addCommand(new ExtApiCommand());
            chainBase.addCommand(new VueCommand());
            chainBase.addCommand(new FinishCommand());

            InputRequestObject context = new InputRequestObject();
            context.setConfig(config);
            context.setFormBean(formBean);
            chainBase.execute(context);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy