Browse Source

fixed gitee issues/IHUIJ

= 7 years ago
parent
commit
5fbb2babbb

+ 15 - 14
mybatis-plus-generate/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java

@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.baomidou.mybatisplus.generator.InjectionConfig;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,6 +78,20 @@ public abstract class AbstractTemplateEngine {
                 Map<String, Object> objectMap = this.getObjectMap(tableInfo);
                 Map<String, String> pathInfo = this.getConfigBuilder().getPathInfo();
                 TemplateConfig template = this.getConfigBuilder().getTemplate();
+                // 自定义内容
+                InjectionConfig injectionConfig = this.getConfigBuilder().getInjectionConfig();
+                if (null != injectionConfig) {
+                    injectionConfig.initMap();
+                    objectMap.put("cfg", injectionConfig.getMap());
+                    List<FileOutConfig> focList = injectionConfig.getFileOutConfigList();
+                    if (CollectionUtils.isNotEmpty(focList)) {
+                        for (FileOutConfig foc : focList) {
+                            if (this.isCreate(foc.outputFile(tableInfo))) {
+                                this.writer(objectMap, foc.getTemplatePath(), foc.outputFile(tableInfo));
+                            }
+                        }
+                    }
+                }
                 // Mp.java
                 String entityName = tableInfo.getEntityName();
                 if (null != entityName) {
@@ -120,20 +135,6 @@ public abstract class AbstractTemplateEngine {
                         this.writer(objectMap, this.templateFilePath(template.getController()), controllerFile);
                     }
                 }
-                // 自定义内容
-                InjectionConfig injectionConfig = this.getConfigBuilder().getInjectionConfig();
-                if (null != injectionConfig) {
-                    injectionConfig.initMap();
-                    objectMap.put("cfg",injectionConfig.getMap());
-                    List<FileOutConfig> focList = injectionConfig.getFileOutConfigList();
-                    if (CollectionUtils.isNotEmpty(focList)) {
-                        for (FileOutConfig foc : focList) {
-                            if (this.isCreate(foc.outputFile(tableInfo))) {
-                                this.writer(objectMap, foc.getTemplatePath(), foc.outputFile(tableInfo));
-                            }
-                        }
-                    }
-                }
             }
         } catch (Exception e) {
             logger.error("无法创建文件,请检查配置信息!", e);