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;
|
}
|
}
|
|
}
|