diff --git a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java index e72d8ec7..701d4d91 100644 --- a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java +++ b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java @@ -36,7 +36,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; import top.continew.starter.core.constant.PropertiesConstants; import top.continew.starter.core.util.GeneralPropertySourceFactory; import top.continew.starter.data.mp.autoconfigure.idgenerator.MyBatisPlusIdGeneratorConfiguration; -import top.continew.starter.data.mp.handler.MybatisBaseEnumTypeHandler; +import top.continew.starter.data.mp.handler.CompositeBaseEnumTypeHandler; import java.util.Map; @@ -63,7 +63,8 @@ public class MybatisPlusAutoConfiguration { */ @Bean public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() { - return properties -> properties.getConfiguration().setDefaultEnumTypeHandler(MybatisBaseEnumTypeHandler.class); + return properties -> properties.getConfiguration() + .setDefaultEnumTypeHandler(CompositeBaseEnumTypeHandler.class); } /** diff --git a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/handler/CompositeBaseEnumTypeHandler.java b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/handler/CompositeBaseEnumTypeHandler.java new file mode 100644 index 00000000..368f6b15 --- /dev/null +++ b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/handler/CompositeBaseEnumTypeHandler.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.gnu.org/licenses/lgpl.html + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package top.continew.starter.data.mp.handler;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import org.apache.ibatis.type.EnumTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.TypeException;
+import org.apache.ibatis.type.TypeHandler;
+
+import java.lang.reflect.Constructor;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 复合枚举类型处理器(扩展 BaseEnum 支持)
+ *
+ * @author miemie(MyBatis Plus)
+ * @author Charles7c
+ * @see com.baomidou.mybatisplus.core.handlers.CompositeEnumTypeHandler
+ * @since 2.7.3
+ */
+public class CompositeBaseEnumTypeHandler