From c816f64dc5eadc1322a27b6c327c53f86fd20398 Mon Sep 17 00:00:00 2001
From: "Ray.Hao" <1490493387@qq.com>
Date: Fri, 6 Sep 2024 00:36:02 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E7=94=9F?=
=?UTF-8?q?=E6=88=90=E6=A8=A1=E5=9D=97=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
youlai-common/common-base/pom.xml | 1 +
youlai-common/common-core/pom.xml | 11 +-
.../security/config/ResourceServerConfig.java | 8 +-
youlai-generator/pom.xml | 39 ++++++-
.../generator/GeneratorApplication.java | 17 +++
...ontroller.java => DatabaseController.java} | 28 +++--
.../generator/model/form/GenConfigForm.java | 4 +-
...ourceService.java => DatabaseService.java} | 11 +-
...viceImpl.java => DatabaseServiceImpl.java} | 21 +---
.../src/main/resources/bootstrap.yml | 3 +
.../main/resources/mapper/DatabaseMapper.xml | 8 +-
.../main/resources/mapper/GenConfigMapper.xml | 2 +-
.../resources/mapper/GenFieldConfigMapper.xml | 2 +-
.../system/controller/DictController.java | 4 +-
.../system/controller/UserController.java | 1 -
.../youlai/system/model/entity/GenConfig.java | 53 ---------
.../system/model/entity/GenFieldConfig.java | 105 ------------------
.../system/model/form/GenConfigForm.java | 103 -----------------
.../youlai/system/service/DictService.java | 2 +-
...tServiceImpl.java => DictServiceImpl.java} | 4 +-
20 files changed, 97 insertions(+), 330 deletions(-)
create mode 100644 youlai-generator/src/main/java/com/youlai/generator/GeneratorApplication.java
rename youlai-generator/src/main/java/com/youlai/generator/controller/{DatasourceController.java => DatabaseController.java} (50%)
rename youlai-generator/src/main/java/com/youlai/generator/service/{DatasourceService.java => DatabaseService.java} (73%)
rename youlai-generator/src/main/java/com/youlai/generator/service/impl/{DatasourceServiceImpl.java => DatabaseServiceImpl.java} (67%)
delete mode 100644 youlai-system/system-boot/src/main/java/com/youlai/system/model/entity/GenConfig.java
delete mode 100644 youlai-system/system-boot/src/main/java/com/youlai/system/model/entity/GenFieldConfig.java
delete mode 100644 youlai-system/system-boot/src/main/java/com/youlai/system/model/form/GenConfigForm.java
rename youlai-system/system-boot/src/main/java/com/youlai/system/service/impl/{SysDictServiceImpl.java => DictServiceImpl.java} (98%)
diff --git a/youlai-common/common-base/pom.xml b/youlai-common/common-base/pom.xml
index 996ae6012..31b1540c9 100644
--- a/youlai-common/common-base/pom.xml
+++ b/youlai-common/common-base/pom.xml
@@ -14,6 +14,7 @@
+
io.swagger.core.v3
swagger-annotations
diff --git a/youlai-common/common-core/pom.xml b/youlai-common/common-core/pom.xml
index 31d3bc826..ac8c278fb 100644
--- a/youlai-common/common-core/pom.xml
+++ b/youlai-common/common-core/pom.xml
@@ -23,6 +23,7 @@
spring-boot-starter-aop
+
io.github.openfeign
feign-core
@@ -75,16 +76,6 @@
knife4j-openapi3-jakarta-spring-boot-starter
-
- com.baomidou
- mybatis-plus-generator
-
-
-
- org.apache.velocity
- velocity-engine-core
-
-
diff --git a/youlai-common/common-framework/common-security/src/main/java/com/youlai/common/security/config/ResourceServerConfig.java b/youlai-common/common-framework/common-security/src/main/java/com/youlai/common/security/config/ResourceServerConfig.java
index bb21c729f..d1e5e9f8c 100644
--- a/youlai-common/common-framework/common-security/src/main/java/com/youlai/common/security/config/ResourceServerConfig.java
+++ b/youlai-common/common-framework/common-security/src/main/java/com/youlai/common/security/config/ResourceServerConfig.java
@@ -51,7 +51,7 @@ public class ResourceServerConfig {
* 白名单路径列表
*/
@Setter
- private List whitelistPaths;
+ private List ignoreUris;
@Bean
@@ -59,11 +59,11 @@ public class ResourceServerConfig {
MvcRequestMatcher.Builder mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspector);
- log.info("whitelist path:{}", JSONUtil.toJsonStr(whitelistPaths));
+ log.info("whitelist path:{}", JSONUtil.toJsonStr(ignoreUris));
http.authorizeHttpRequests((requests) ->
{
- if (CollectionUtil.isNotEmpty(whitelistPaths)) {
- for (String whitelistPath : whitelistPaths) {
+ if (CollectionUtil.isNotEmpty(ignoreUris)) {
+ for (String whitelistPath : ignoreUris) {
requests.requestMatchers(mvcMatcherBuilder.pattern(whitelistPath)).permitAll();
}
}
diff --git a/youlai-generator/pom.xml b/youlai-generator/pom.xml
index f8ad02e6f..e3c1a13a0 100644
--- a/youlai-generator/pom.xml
+++ b/youlai-generator/pom.xml
@@ -18,13 +18,40 @@
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ jsr305
+ com.google.code.findbugs
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
com.youlai
common-core
-
com.youlai
common-mybatis
@@ -35,6 +62,16 @@
dynamic-datasource-spring-boot3-starter
+
+ com.baomidou
+ mybatis-plus-generator
+
+
+
+ org.apache.velocity
+ velocity-engine-core
+
+
\ No newline at end of file
diff --git a/youlai-generator/src/main/java/com/youlai/generator/GeneratorApplication.java b/youlai-generator/src/main/java/com/youlai/generator/GeneratorApplication.java
new file mode 100644
index 000000000..34a9f7481
--- /dev/null
+++ b/youlai-generator/src/main/java/com/youlai/generator/GeneratorApplication.java
@@ -0,0 +1,17 @@
+package com.youlai.generator;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 系统服务启动类
+ *
+ * @author Ray
+ * @since 0.0.1
+ */
+@SpringBootApplication
+public class GeneratorApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(GeneratorApplication.class, args);
+ }
+}
diff --git a/youlai-generator/src/main/java/com/youlai/generator/controller/DatasourceController.java b/youlai-generator/src/main/java/com/youlai/generator/controller/DatabaseController.java
similarity index 50%
rename from youlai-generator/src/main/java/com/youlai/generator/controller/DatasourceController.java
rename to youlai-generator/src/main/java/com/youlai/generator/controller/DatabaseController.java
index 09ccec951..23b8d9589 100644
--- a/youlai-generator/src/main/java/com/youlai/generator/controller/DatasourceController.java
+++ b/youlai-generator/src/main/java/com/youlai/generator/controller/DatabaseController.java
@@ -1,43 +1,49 @@
package com.youlai.generator.controller;
+import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.result.PageResult;
+import com.youlai.common.result.Result;
import com.youlai.generator.model.query.TablePageQuery;
import com.youlai.generator.model.vo.TablePageVO;
-import com.youlai.generator.service.DatasourceService;
+import com.youlai.generator.service.DatabaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import javax.sql.DataSource;
+import java.util.ArrayList;
import java.util.List;
/**
- * 数据源控制器
+ * 数据库管理控制器
*
* @author Ray
* @since 2.10.0
*/
-@Tag(name = "数据源接口")
+@Tag(name = "数据库管理接口")
@RestController
-@RequestMapping("/api/v1/datasources")
+@RequestMapping("/api/v1/database")
@RequiredArgsConstructor
-public class DatasourceController {
+public class DatabaseController {
- private final DatasourceService datasourceService;
+ private final DataSource dataSource;
+ private final DatabaseService databaseService;
- @GetMapping("/keys")
+ @GetMapping("/datasource/keys")
@Operation(summary = "获取所有数据源的key")
- public List getAllDatasourceKeys() {
- return datasourceService.getAllDatasourceKeys();
+ public Result> getAllDatasourceKeys() {
+ DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
+ return Result.success(new ArrayList<>(ds.getDataSources().keySet()));
}
@Operation(summary = "获取数据表分页列表")
- @GetMapping("/tables")
+ @GetMapping("/tables/page")
public PageResult getTablePage(
TablePageQuery queryParams
) {
- Page result = datasourceService.getTablePage(queryParams);
+ Page result = databaseService.getTablePage(queryParams);
return PageResult.success(result);
}
diff --git a/youlai-generator/src/main/java/com/youlai/generator/model/form/GenConfigForm.java b/youlai-generator/src/main/java/com/youlai/generator/model/form/GenConfigForm.java
index f0ad36046..b4840cdf9 100644
--- a/youlai-generator/src/main/java/com/youlai/generator/model/form/GenConfigForm.java
+++ b/youlai-generator/src/main/java/com/youlai/generator/model/form/GenConfigForm.java
@@ -1,7 +1,7 @@
package com.youlai.generator.model.form;
-import com.youlai.boot.common.enums.FormTypeEnum;
-import com.youlai.boot.common.enums.QueryTypeEnum;
+import com.youlai.generator.enums.FormTypeEnum;
+import com.youlai.generator.enums.QueryTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/youlai-generator/src/main/java/com/youlai/generator/service/DatasourceService.java b/youlai-generator/src/main/java/com/youlai/generator/service/DatabaseService.java
similarity index 73%
rename from youlai-generator/src/main/java/com/youlai/generator/service/DatasourceService.java
rename to youlai-generator/src/main/java/com/youlai/generator/service/DatabaseService.java
index 9dff8fb39..aedb63827 100644
--- a/youlai-generator/src/main/java/com/youlai/generator/service/DatasourceService.java
+++ b/youlai-generator/src/main/java/com/youlai/generator/service/DatabaseService.java
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.generator.model.query.TablePageQuery;
import com.youlai.generator.model.vo.TablePageVO;
-import java.util.List;
/**
* 数据源服务接口
@@ -12,15 +11,7 @@ import java.util.List;
* @author Ray
* @since 4.0.0
*/
-public interface DatasourceService {
-
- /**
- * 获取所有数据源
- *
- * @return
- */
- List getAllDatasourceKeys() ;
-
+public interface DatabaseService {
/**
* 获取数据表分页列表
diff --git a/youlai-generator/src/main/java/com/youlai/generator/service/impl/DatasourceServiceImpl.java b/youlai-generator/src/main/java/com/youlai/generator/service/impl/DatabaseServiceImpl.java
similarity index 67%
rename from youlai-generator/src/main/java/com/youlai/generator/service/impl/DatasourceServiceImpl.java
rename to youlai-generator/src/main/java/com/youlai/generator/service/impl/DatabaseServiceImpl.java
index cbe0b77e6..608a5ac4a 100644
--- a/youlai-generator/src/main/java/com/youlai/generator/service/impl/DatasourceServiceImpl.java
+++ b/youlai-generator/src/main/java/com/youlai/generator/service/impl/DatabaseServiceImpl.java
@@ -1,17 +1,14 @@
package com.youlai.generator.service.impl;
-import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.generator.config.GeneratorProperties;
import com.youlai.generator.mapper.DatabaseMapper;
import com.youlai.generator.model.query.TablePageQuery;
import com.youlai.generator.model.vo.TablePageVO;
-import com.youlai.generator.service.DatasourceService;
+import com.youlai.generator.service.DatabaseService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
-import javax.sql.DataSource;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -22,27 +19,13 @@ import java.util.List;
*/
@Service
@RequiredArgsConstructor
-public class DatasourceServiceImpl implements DatasourceService {
+public class DatabaseServiceImpl implements DatabaseService {
- private final DataSource dataSource;
private final DatabaseMapper databaseMapper;
private final GeneratorProperties generatorProperties;
- /**
- * 获取所有数据源
- *
- * @return 数据源列表
- */
-
- @Override
- public List getAllDatasourceKeys() {
- DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
- return new ArrayList<>(ds.getDataSources().keySet());
- }
-
-
/**
* 数据表分页列表
*
diff --git a/youlai-generator/src/main/resources/bootstrap.yml b/youlai-generator/src/main/resources/bootstrap.yml
index 184a6d087..4f53553fb 100644
--- a/youlai-generator/src/main/resources/bootstrap.yml
+++ b/youlai-generator/src/main/resources/bootstrap.yml
@@ -1,3 +1,6 @@
+server:
+ port: 8810
+
spring:
application:
name: youlai-generator
diff --git a/youlai-generator/src/main/resources/mapper/DatabaseMapper.xml b/youlai-generator/src/main/resources/mapper/DatabaseMapper.xml
index b04e4eb50..5cfe0addb 100644
--- a/youlai-generator/src/main/resources/mapper/DatabaseMapper.xml
+++ b/youlai-generator/src/main/resources/mapper/DatabaseMapper.xml
@@ -2,10 +2,10 @@
-
+
-