소스 검색

增加生成器禁用模板生成.

https://github.com/baomidou/mybatis-plus/issues/2384

https://gitee.com/baomidou/mybatis-plus/issues/I1BRRV
聂秋秋 5 년 전
부모
커밋
605e63747b

+ 33 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java

@@ -48,4 +48,37 @@ public class TemplateConfig {
     public String getEntity(boolean kotlin) {
         return kotlin ? entityKt : entity;
     }
+    
+    /**
+     * 禁用模板
+     *
+     * @param templateTypes 模板类型
+     * @return this
+     * @since 3.3.2
+     */
+    public TemplateConfig disable(TemplateType... templateTypes) {
+        if (templateTypes != null && templateTypes.length > 0) {
+            for (TemplateType templateType : templateTypes) {
+                switch (templateType) {
+                    case XML:
+                        setXml(null);
+                        break;
+                    case ENTITY:
+                        setEntity(null).setEntityKt(null);
+                        break;
+                    case MAPPER:
+                        setMapper(null);
+                        break;
+                    case SERVICE:
+                        setService(null).setServiceImpl(null);
+                        break;
+                    case CONTROLLER:
+                        setController(null);
+                        break;
+                }
+            }
+        }
+        return this;
+    }
+    
 }

+ 13 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateType.java

@@ -0,0 +1,13 @@
+package com.baomidou.mybatisplus.generator.config;
+
+/**
+ * 模板类型
+ *
+ * @author nieqiurong 2020/4/28.
+ * @since 3.3.2
+ */
+public enum TemplateType {
+    
+    ENTITY, SERVICE, CONTROLLER, MAPPER, XML
+    
+}