duhuizhe
2024-04-19 64c4fd3c7067c7626dc960a70b4bc2c3662bc653
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
package com.yqzx.generator.engine.base;
 
import cn.hutool.core.collection.CollectionUtil;
import com.yqzx.generator.action.model.TableInfo;
import com.yqzx.generator.engine.config.*;
import lombok.Data;
 
import java.util.List;
 
/**
 * @description: 模板生成父类
 * @author: chaoyapeng
 * @time: 2020/8/18 16:03
 */
@Data
public class BaseTemplateEngine {
 
    /**
     * 全局配置
     */
    protected ContextConfig contextConfig;
 
    protected ControllerConfig controllerConfig;
 
    protected ServiceConfig serviceConfig;
 
    protected MapperConfig mapperConfig;
 
    protected ModelConfig modelConfig;
 
    protected QueryConfig queryConfig;
 
    protected List<TableInfo> tableInfo;
 
    protected List<TableInfo> queryTableInfo;
 
    protected String columnStr;
 
    public void initConfig() {
        if (this.contextConfig == null) {
            this.contextConfig = new ContextConfig();
        }
        contextConfig.init();
        if (this.controllerConfig == null) {
            this.controllerConfig = new ControllerConfig();
        }
        this.controllerConfig.setContextConfig(this.contextConfig);
        controllerConfig.init();
        if (this.serviceConfig == null) {
            this.serviceConfig = new ServiceConfig();
        }
        this.serviceConfig.setContextConfig(this.contextConfig);
        serviceConfig.init();
        if (this.mapperConfig == null) {
            this.mapperConfig = new MapperConfig();
        }
        this.mapperConfig.setContextConfig(this.contextConfig);
        mapperConfig.init();
        if (this.modelConfig == null) {
            this.modelConfig = new ModelConfig();
        }
        this.modelConfig.setContextConfig(this.contextConfig);
        modelConfig.init();
        if (this.queryConfig == null) {
            this.queryConfig = new QueryConfig();
        }
        this.queryConfig.setContextConfig(this.contextConfig);
        queryConfig.init();
 
        // 无查询参数列,默认是数据库表所有字段
        if (CollectionUtil.isEmpty(queryTableInfo)) {
            this.queryTableInfo = tableInfo;
        }
    }
 
}