1616
1717package com .itfsw .mybatis .generator .plugins ;
1818
19- import com .itfsw .mybatis .generator .plugins .utils .BasePlugin ;
20- import com .itfsw .mybatis .generator .plugins .utils .FormatTools ;
21- import com .itfsw .mybatis .generator .plugins .utils .IntrospectedTableTools ;
22- import com .itfsw .mybatis .generator .plugins .utils .JavaElementGeneratorTools ;
19+ import com .itfsw .mybatis .generator .plugins .utils .*;
2320import org .mybatis .generator .api .CommentGenerator ;
2421import org .mybatis .generator .api .IntrospectedColumn ;
2522import org .mybatis .generator .api .IntrospectedTable ;
2623import org .mybatis .generator .api .dom .java .*;
2724import org .mybatis .generator .internal .util .StringUtility ;
2825
2926import java .math .BigDecimal ;
30- import java .util .ArrayList ;
31- import java .util .LinkedHashMap ;
32- import java .util .List ;
33- import java .util .Map ;
27+ import java .util .*;
3428import java .util .regex .Matcher ;
3529import java .util .regex .Pattern ;
3630
@@ -113,6 +107,19 @@ public void initialized(IntrospectedTable introspectedTable) {
113107 }
114108 }
115109 }
110+
111+ // 逻辑删除插件依赖该插件生成对应枚举
112+ if (PluginTools .checkDependencyPlugin (this .getContext (), LogicalDeletePlugin .class )) {
113+ // 1. 获取配置的逻辑删除列
114+ String logicalDeleteColumnStr = this .getProperties ().getProperty (LogicalDeletePlugin .PRO_LOGICAL_DELETE_COLUMN );
115+ if (introspectedTable .getTableConfigurationProperty (LogicalDeletePlugin .PRO_LOGICAL_DELETE_COLUMN ) != null ) {
116+ logicalDeleteColumnStr = introspectedTable .getTableConfigurationProperty (LogicalDeletePlugin .PRO_LOGICAL_DELETE_COLUMN );
117+ }
118+ IntrospectedColumn logicalDeleteColumn = IntrospectedTableTools .safeGetColumn (introspectedTable , logicalDeleteColumnStr );
119+ if (logicalDeleteColumn != null ) {
120+ this .enumColumns .remove (logicalDeleteColumn .getJavaProperty ());
121+ }
122+ }
116123 }
117124
118125 /**
@@ -127,6 +134,19 @@ public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, Intros
127134 return super .modelPrimaryKeyClassGenerated (topLevelClass , introspectedTable );
128135 }
129136
137+ /**
138+ * Model 生成
139+ * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
140+ * @param topLevelClass
141+ * @param introspectedTable
142+ * @return
143+ */
144+ @ Override
145+ public boolean modelBaseRecordClassGenerated (TopLevelClass topLevelClass , IntrospectedTable introspectedTable ) {
146+ this .generateModelEnum (topLevelClass , introspectedTable );
147+ return super .modelBaseRecordClassGenerated (topLevelClass , introspectedTable );
148+ }
149+
130150 /**
131151 * 生成对应enum
132152 * @param topLevelClass
@@ -142,20 +162,6 @@ private void generateModelEnum(TopLevelClass topLevelClass, IntrospectedTable in
142162 }
143163 }
144164
145- /**
146- * Model 生成
147- * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
148- * @param topLevelClass
149- * @param introspectedTable
150- * @return
151- */
152- @ Override
153- public boolean modelBaseRecordClassGenerated (TopLevelClass topLevelClass , IntrospectedTable introspectedTable ) {
154- this .generateModelEnum (topLevelClass , introspectedTable );
155- return super .modelBaseRecordClassGenerated (topLevelClass , introspectedTable );
156- }
157-
158-
159165 public static class EnumInfo {
160166 private List <EnumItemInfo > items = new ArrayList <>();
161167 private IntrospectedColumn column ;
0 commit comments