ny
23 小时以前 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package jnpf.base.util.custom;
 
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
import lombok.extern.slf4j.Slf4j;
 
import java.util.Map;
 
 
@Slf4j
public class CustomGenerator {
 
    public ConfigBuilder config;
    public InjectionConfig injectionConfig;
    public DataSourceConfig dataSource;
    public StrategyConfig strategy;
    public PackageConfig packageInfo;
    public TemplateConfig template;
    public GlobalConfig globalConfig;
    public AbstractTemplateEngine templateEngine;
 
    private Map<String, Object> customParams;
 
    public CustomGenerator(Map<String, Object> customParams) {
        this.customParams = customParams;
    }
 
    public void execute(String path) {
        if (null == this.config) {
            this.config = new ConfigBuilder(packageInfo, dataSource, strategy, template, globalConfig, injectionConfig);
        }
        if (null == this.templateEngine) {
            if (customParams != null) {
                this.templateEngine = new CustomTemplateEngine(customParams, path);
            } else {
                this.templateEngine = new CustomTemplateEngine(path);
            }
        }
        this.templateEngine.init(this.config).batchOutput().open();
    }
 
    public DataSourceConfig getDataSource() {
        return this.dataSource;
    }
 
    public CustomGenerator setDataSource(DataSourceConfig dataSource) {
        this.dataSource = dataSource;
        return this;
    }
 
    public StrategyConfig getStrategy() {
        return this.strategy;
    }
 
    public CustomGenerator setStrategy(StrategyConfig strategy) {
        this.strategy = strategy;
        return this;
    }
 
    public PackageConfig getPackageInfo() {
        return this.packageInfo;
    }
 
    public CustomGenerator setPackageInfo(PackageConfig packageInfo) {
        this.packageInfo = packageInfo;
        return this;
    }
 
    public TemplateConfig getTemplate() {
        return this.template;
    }
 
    public CustomGenerator setTemplate(TemplateConfig template) {
        this.template = template;
        return this;
    }
 
    public ConfigBuilder getConfig() {
        return this.config;
    }
 
    public CustomGenerator setConfig(ConfigBuilder config) {
        this.config = config;
        return this;
    }
 
    public GlobalConfig getGlobalConfig() {
        return this.globalConfig;
    }
 
    public CustomGenerator setGlobalConfig(GlobalConfig globalConfig) {
        this.globalConfig = globalConfig;
        return this;
    }
 
    public InjectionConfig getCfg() {
        return this.injectionConfig;
    }
 
    public CustomGenerator setCfg(InjectionConfig injectionConfig) {
        this.injectionConfig = injectionConfig;
        return this;
    }
 
    public AbstractTemplateEngine getTemplateEngine() {
        return this.templateEngine;
    }
 
    public CustomGenerator setTemplateEngine(AbstractTemplateEngine templateEngine) {
        this.templateEngine = templateEngine;
        return this;
    }
}