From bafb4a0e40a301873c4ceac5d2f619852146c044 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Sun, 2 Jul 2023 17:11:06 +0800 Subject: [PATCH] feat: add MybatisFlexAdminAutoConfiguration. --- .../MybatisFlexAdminAutoConfiguration.java | 69 +++++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + 3 files changed, 71 insertions(+) create mode 100644 mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAdminAutoConfiguration.java diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAdminAutoConfiguration.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAdminAutoConfiguration.java new file mode 100644 index 00000000..88fc907b --- /dev/null +++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisFlexAdminAutoConfiguration.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * 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 com.mybatisflex.spring.boot;
+
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.core.audit.MessageFactory;
+import com.mybatisflex.core.audit.MessageReporter;
+import com.mybatisflex.core.audit.http.HttpMessageReporter;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * MyBatis-Flex-Admin 自动配置。
+ *
+ * @author 王帅
+ * @since 2023-07-01
+ */
+@Configuration(proxyBeanMethods = false)
+@AutoConfigureAfter(MybatisFlexAutoConfiguration.class)
+@EnableConfigurationProperties(MybatisFlexProperties.class)
+@ConditionalOnProperty(prefix = "mybatis-flex.admin-config", name = "enable", havingValue = "true")
+public class MybatisFlexAdminAutoConfiguration implements InitializingBean {
+
+ private final MessageFactory messageFactory;
+ private final MybatisFlexProperties properties;
+ private final HttpMessageReporter.JSONFormatter jsonFormatter;
+
+ public MybatisFlexAdminAutoConfiguration(ObjectProvider