第一次

main
刘泽璋 2024-06-24 08:45:06 +08:00
parent 8888e7981f
commit c7199c4cbf
52 changed files with 1350 additions and 64 deletions

View File

@ -2,13 +2,19 @@
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<annotationProcessing> <annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true"> <profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" /> <sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<module name="etl-common" /> <module name="etl-common" />
<module name="el-data-source-server" />
<module name="etl-gateway" /> <module name="etl-gateway" />
<module name="el-data-source-common" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel>
<module name="etl-mysql" target="1.8" />
</bytecodeTargetLevel>
</component> </component>
</project> </project>

View File

@ -3,8 +3,16 @@
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/etl-common/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/etl-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-common/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/etl-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/el-data-source-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/el-data-source-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/el-data-source-server/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/el-data-source-server/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-data-source/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-gateway/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/etl-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-gateway/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/etl-gateway/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-mysql/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-mysql/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component> </component>

View File

@ -0,0 +1,68 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAbstractClassShouldStartWithAbstractNaming" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidApacheBeanUtilsCopy" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidCallStaticSimpleDateFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidCommentBehindStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidComplexCondition" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidConcurrentCompetitionRandom" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidDoubleOrFloatEqualCompare" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidManuallyCreateThread" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidMissUseOfMathRandom" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidNegationOperator" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidNewDateGetTime" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidPatternCompileInMethod" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidReturnInFinally" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidStartWithDollarAndUnderLineNaming" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaAvoidUseTimer" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaBigDecimalAvoidDoubleConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaBooleanPropertyShouldNotStartWithIs" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaClassCastExceptionWithSubListToArrayList" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaClassCastExceptionWithToArray" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaClassMustHaveAuthor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaClassNamingShouldBeCamel" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaCollectionInitShouldAssignCapacity" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaCommentsMustBeJavadocFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaConcurrentExceptionWithModifyOriginSubList" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaConstantFieldShouldBeUpperCase" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaCountDownShouldInFinally" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaDontModifyInForeachCircle" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaEnumConstantsMustHaveComment" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaExceptionClassShouldEndWithException" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaIbatisMethodQueryForList" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaLockShouldWithTryFinally" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaLowerCamelCaseVariableNaming" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaMethodReturnWrapperType" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaMethodTooLong" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaPackageNaming" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaPojoMustOverrideToString" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaPojoMustUsePrimitiveField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaPojoNoDefaultValue" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaRemoveCommentedCode" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaServiceOrDaoClassShouldEndWithImpl" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaSneakyThrowsWithoutExceptionType" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaStringConcat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaSwitchExpression" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaSwitchStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaTestClassShouldEndWithTestNaming" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaThreadLocalShouldRemove" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaThreadPoolCreation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaThreadShouldSetName" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaTransactionMustHaveRollback" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaUndefineMagicConstant" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaUnsupportedExceptionWithModifyAsList" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaUseQuietReferenceNotation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AlibabaUseRightCaseForDateFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View File

@ -5,10 +5,19 @@
<option name="originalFiles"> <option name="originalFiles">
<list> <list>
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/etl-mysql/pom.xml" />
<option value="$PROJECT_DIR$/etl-data-source/pom.xml" />
<option value="$PROJECT_DIR$/etl-data-source/el-data-source-server/pom.xml" />
<option value="$PROJECT_DIR$/etl-data-source/el-data-source-common/pom.xml" />
</list> </list>
</option> </option>
<option name="ignoredFiles">
<set>
<option value="$PROJECT_DIR$/etl-mysql/pom.xml" />
</set>
</option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="SuppressionsComponent"> <component name="SuppressionsComponent">
<option name="suppComments" value="[]" /> <option name="suppComments" value="[]" />
</component> </component>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -9,13 +9,54 @@
</parent> </parent>
<artifactId>etl-common</artifactId> <artifactId>etl-common</artifactId>
<description>etl-common</description> <description>etl-common</description>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version> <spring-boot.version>2.6.13</spring-boot.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>etl-cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.21.1</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- SpringBoot Boot Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--knife4j-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency> <dependency>
<groupId>net.sourceforge.tess4j</groupId> <groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId> <artifactId>tess4j</artifactId>
@ -32,6 +73,10 @@
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId> <artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version> <version>4.4.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
@ -98,40 +143,6 @@
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.health.cloud.common.HealthCloudCommonApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -0,0 +1,2 @@
#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
# com.health.common.handle.ExceptHandle

View File

@ -0,0 +1,2 @@
#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
# com.health.common.handle.ExceptHandle

Binary file not shown.

View File

@ -1,5 +1,5 @@
#Generated by Maven #Generated by Maven
#Tue Jun 18 19:06:20 CST 2024 #Fri Jun 21 17:06:57 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie groupId=com.bwie
artifactId=etl-common artifactId=etl-common
version=1.0-SNAPSHOT

View File

@ -0,0 +1,19 @@
com\etl\common\constants\Constants.class
com\etl\common\result\PageResult.class
com\etl\common\constants\JwtConstants.class
com\etl\common\Entity.class
com\etl\common\handler\ExceptionHandlers.class
com\etl\common\util\JwtUtils.class
com\etl\common\util\RequestUtil.class
com\etl\common\exception\ServiceException.class
com\etl\common\result\ResultBody.class
com\etl\common\config\Swagger.class
com\etl\common\exception\AllException.class
com\etl\common\util\RestTemplateUtil.class
com\etl\common\result\Result.class
com\etl\common\config\Swagger$1.class
com\etl\common\BaseEntity.class
com\etl\common\exception\GlobalException.class
com\etl\common\util\RestTemplateConfig.class
com\etl\common\constants\TokenConstants.class
com\etl\common\util\StringUtils.class

View File

@ -0,0 +1,18 @@
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\config\Swagger.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\AllException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\Result.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RestTemplateConfig.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\Constants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\PageResult.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\TokenConstants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RequestUtil.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\StringUtils.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RestTemplateUtil.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\JwtConstants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\JwtUtils.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\BaseEntity.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\GlobalException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\handler\ExceptionHandlers.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\Entity.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\ServiceException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\ResultBody.java

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>etl-data-source</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>el-data-source-common</artifactId>
<description>el-data-source-common</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>etl-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,36 @@
package com.etl.data.source.common.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "数据库配置")
public class DatabaseConfig {
@NotBlank(message = "驱动类不能为空")
@ApiModelProperty(value = "驱动类")
private String driverClassName;
@NotBlank(message = "数据库连接地址不能为空")
@ApiModelProperty(value = "数据库连接地址")
private String url;
@NotBlank(message = "数据库用户名不能为空")
@ApiModelProperty(value = "数据库用户名")
private String username;
@NotBlank(message = "数据库密码不能为空")
@ApiModelProperty(value = "数据库密码")
private String password;
@ApiModelProperty(value = "数据库表名")
private String tableName;
@ApiModelProperty(value = "数据库库名")
private String warehouseName;
}

View File

@ -0,0 +1,25 @@
package com.etl.data.source.common.pojo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
/**
* @ClassName DatabaseRedis
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/24 8:35
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "redis数据库配置")
public class DatabaseRedis {
@NotBlank(message = "redis连接地址不能为空")
private String url;
@NotBlank(message = "redis端口号不能为空")
private String port;
}

View File

@ -0,0 +1,13 @@
package com.etl.data.source.common.pojo.constants;
/**
* @ClassName MysqlConstants
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/21 20:34
*/
public class MysqlConstants {
public static final String MYSQL_USER = "user";
public static final String MYSQL_PASSWORD = "password";
}

View File

@ -0,0 +1,22 @@
package com.etl.data.source.common.pojo.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName ConnectMysqlReq
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/21 15:32
*/
@Data
@ApiModel(value = "连接mysql请求参数")
public class ConnectMysqlReq {
@ApiModelProperty(value = "数据库连接地址")
private String url;
@ApiModelProperty(value = "数据库用户名")
private String user;
@ApiModelProperty(value = "数据库密码")
private String passWard;
}

View File

@ -0,0 +1,27 @@
package com.etl.data.source.common.pojo.resq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "字段信息")
public class ColumnInfo {
@ApiModelProperty(value = "字段名")
private String columnName;
@ApiModelProperty(value = "字段类型")
private String dataType;
@ApiModelProperty(value = "字段长度")
private Integer characterMaximumLength; // 注意这里可能是null
@ApiModelProperty(value = "字段键类型")
private String columnKey; // 主键、唯一键等
@ApiModelProperty(value = "是否为空")
private String isNullable; // YES 或 NO
@ApiModelProperty(value = "字段注释")
private String columnComment; // 列注释
}

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>etl-data-source</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>el-data-source-server</artifactId>
<description>el-data-source-server</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>el-data-source-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.data.source.server.ElDataSourceServerApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
package com.etl.data.source.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ElDataSourceServerApplication {
public static void main(String[] args) {
SpringApplication.run(ElDataSourceServerApplication.class, args);
System.out.println(" __ __ _ _ _ _");
System.out.println(" ___ _ __ ___/ _|__ / /_ | | | | | | ___| |__");
System.out.println(" / _ \\ '__/ _ \\ _/ _ \\ | '_ \\ | |_| | | |/ _ \\ '_ \\");
System.out.println("| (_) | | | __/ | || __/| |_) || _ | | | __/ | | |");
System.out.println(" \\___/|_| \\___|_| \\___| |_.__/ |_| |_| |_| \\___|_| |_|");
System.out.println(" 数据源业务启动成功!");
}
}

View File

@ -0,0 +1,42 @@
package com.etl.data.source.server;
import com.etl.common.result.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.List;
import java.util.stream.Collectors;
@ControllerAdvice
@Log4j2
public class GlobalExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Result<String>> handleValidationExceptions(MethodArgumentNotValidException ex) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
String errorMessage = fieldErrors.stream()
.map(FieldError::getDefaultMessage)
.collect(Collectors.joining(", "));
log.error(errorMessage);
// 使用Result封装错误信息
Result<String> result = Result.error(errorMessage);
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(Exception.class)
public ResponseEntity<Result<String>> handleException(Exception ex) {
log.error("General exception", ex); // 最好打印堆栈信息以便排查问题
// 使用Result封装错误信息
Result<String> result = Result.error(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

View File

@ -0,0 +1,101 @@
package com.etl.data.source.server.config;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;
@Configuration
@EnableSwagger2WebMvc
@Slf4j
public class Swagger {
@Bean(value = "defaultApi")
public Docket defaultApi() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
//分组名称
.groupName("2.X版本")
.select()
//这里指定Controller扫描包路径
// .apis(RequestHandlerSelectors.basePackage("com.github.xiaoymin.knife4j.controller"))
//这里指定扫描有ApiOperation注解的类
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//所有路径
.paths(PathSelectors.any())
//不包含^/inner/.*的路径
//.paths(input -> !input.matches("^/inner/.*"))
.build();
return docket;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("七组RESTful APIs")
.description("构建RESTful APIs")
.termsOfServiceUrl("https://blog.csdn.net/weixin_43453386")
.contact(new Contact("刘泽璋",
"https://blog.csdn.net/weixin_43453386",
"xxx@163.com"))
.version("1.0")
.build();
}
/**
* SpringBootSwagger2
*
* @return
*/
@Bean
public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
return new BeanPostProcessor() {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof WebMvcRequestHandlerProvider) {
customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
}
return bean;
}
private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
List<T> copy = mappings.stream()
.filter(mapping -> mapping.getPatternParser() == null)
.collect(Collectors.toList());
mappings.clear();
mappings.addAll(copy);
}
@SuppressWarnings("unchecked")
private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
try {
Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
field.setAccessible(true);
return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
} catch (IllegalArgumentException | IllegalAccessException e) {
log.warn("修改WebMvcRequestHandlerProvider的属性handlerMappings出错可能导致swagger不可用", e);
throw new IllegalStateException(e);
}
}
};
}
}

View File

@ -0,0 +1,75 @@
package com.etl.data.source.server.controller;
import com.etl.common.result.Result;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.server.service.DatabaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import javax.validation.Valid;
import java.util.List;
// 声明为一个 Spring Boot 控制器
@RestController
@Api(tags = "数据源")
@Slf4j
public class DatabaseController {
@Autowired
private DatabaseService databaseService;
@PostMapping("/testDatabaseRedis")
public Result<String> testDatabaseRedis(@Valid @RequestBody DatabaseRedis databaseRedis) {
try (Jedis jedis = new Jedis(databaseRedis.getUrl(), Integer.parseInt(databaseRedis.getPort()))) {
// 测试连接,例如设置一个键并获取它
String testKey = "testKey";
String testValue = "testValue";
jedis.set(testKey, testValue);
String result = jedis.get(testKey);
// 假设Result是一个泛型类用于封装响应结果
return Result.success(result);
} catch (Exception e) {
// 处理异常,例如记录日志或返回错误结果
log.info("Redis test failed: " + e.getMessage());
return Result.error("连接失败");
}
}
// POST请求映射到/test-database-connection路径
@PostMapping("/testDatabaseMysql")
@ApiOperation(value = "测试数据库连接")
public Result<String> testDatabaseConnection(@Valid @RequestBody DatabaseConfig config) {
String string = databaseService.testDatabaseConnection(config);
if (string.equals("ok")) {
return Result.success("连接成功");
} else {
return Result.error("连接失败");
}
}
@PostMapping("/findDatabaseTable")
@ApiOperation(value = "查询数据库表")
public Result<List<String>> findDatabaseTable(@Valid @RequestBody DatabaseConfig config){
return Result.success(databaseService.findDatabaseTable(config));
}
@PostMapping("/findDatabaseTableName")
@ApiOperation("查询指定数据库的所有表名")
public Result<List<String>> findDatabaseTableName(@Valid @RequestBody DatabaseConfig config){
return Result.success(databaseService.findDatabaseTables(config));
}
@PostMapping("/findDatabaseTableField")
@ApiOperation("查询指定数据库的指定表的所有字段")
public Result<List<ColumnInfo>> findDatabaseTableField(@Valid @RequestBody DatabaseConfig config){
return Result.success(databaseService.findDatabaseTableField(config));
}
}

View File

@ -0,0 +1,22 @@
package com.etl.data.source.server.service;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
import java.util.List;
/**
* @ClassName DatabaseService
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/21 20:16
*/
public interface DatabaseService {
String testDatabaseConnection(DatabaseConfig config);
List<String> findDatabaseTable(DatabaseConfig config);
List<String> findDatabaseTables(DatabaseConfig config);
List<ColumnInfo> findDatabaseTableField(DatabaseConfig config);
}

View File

@ -0,0 +1,174 @@
package com.etl.data.source.server.service.impl;
import com.etl.common.util.StringUtils;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.constants.MysqlConstants;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.server.service.DatabaseService;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* @ClassName DatabaseServiceImpl
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/21 20:16
*/
@Service
public class DatabaseServiceImpl implements DatabaseService {
@Override
public String testDatabaseConnection(DatabaseConfig config) {
try {
// 创建数据源
DataSource dataSource = createDataSource(config);
// 使用JdbcTemplate执行SQL语句
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("SELECT 1");
// 如果连接成功,返回"ok"
return "ok";
} catch (Exception e) {
// 如果发生异常,打印异常信息并返回"error"
e.printStackTrace();
return "error";
}
}
@Override
public List<String> findDatabaseTable(DatabaseConfig config) {
List<String> tableNames = new ArrayList<>();
try (Connection connection = getConnection(config)) {
try (Statement statement = connection.createStatement()) {
// 查询所有数据库名
try (ResultSet resultSet = statement.executeQuery("SHOW DATABASES;")) {
while (resultSet.next()) {
tableNames.add(resultSet.getString(1));
}
}
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return tableNames;
}
@Override
public List<String> findDatabaseTables(DatabaseConfig config) {
if(StringUtils.isNull(config.getWarehouseName())){
throw new RuntimeException("请选择数据库");
}
List<String> tableNames = new ArrayList<>();
try (Connection connection = getConnection(config)) {
try (Statement statement = connection.createStatement()) {
// 查询指定数据库的所有表名
try (ResultSet resultSet = statement.executeQuery(
"SHOW TABLES FROM " + config.getWarehouseName() + ";")) {
while (resultSet.next()) {
tableNames.add(resultSet.getString(1));
}
}
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return tableNames;
}
@Override
public List<ColumnInfo> findDatabaseTableField(DatabaseConfig config) {
if(StringUtils.isNull(config.getWarehouseName())){
throw new RuntimeException("请选择数据库");
}
if(StringUtils.isNull(config.getTableName())){
throw new RuntimeException("请选择表");
}
List<ColumnInfo> columnInfos = new ArrayList<>();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
// 加载并注册JDBC驱动
Class.forName(config.getDriverClassName());
// 建立数据库连接
connection = DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword());
// 创建PreparedStatement以避免SQL注入
String sql = "SELECT " +
"COLUMN_NAME, " +
"DATA_TYPE, " +
"CHARACTER_MAXIMUM_LENGTH, " +
"COLUMN_KEY, " +
"IS_NULLABLE, " +
"COLUMN_COMMENT " +
"FROM INFORMATION_SCHEMA.COLUMNS " +
"WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, config.getWarehouseName());
preparedStatement.setString(2, config.getTableName());
// 执行查询
resultSet = preparedStatement.executeQuery();
// 遍历结果集
while (resultSet.next()) {
ColumnInfo columnInfo = new ColumnInfo();
columnInfo.setColumnName(resultSet.getString("COLUMN_NAME"));
columnInfo.setDataType(resultSet.getString("DATA_TYPE"));
columnInfo.setCharacterMaximumLength(resultSet.getInt("CHARACTER_MAXIMUM_LENGTH")); // 注意可能为null
columnInfo.setColumnKey(resultSet.getString("COLUMN_KEY"));
columnInfo.setIsNullable(resultSet.getString("IS_NULLABLE"));
columnInfo.setColumnComment(resultSet.getString("COLUMN_COMMENT"));
columnInfos.add(columnInfo);
}
} catch (ClassNotFoundException | SQLException e) {
// 处理异常
e.printStackTrace();
} finally {
// 关闭资源
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return columnInfos;
}
private static Connection getConnection(DatabaseConfig config) throws ClassNotFoundException, SQLException {
// 加载MySQL驱动
Class.forName(config.getDriverClassName());
// 设置数据库连接信息
String url = config.getUrl();
Properties properties = new Properties();
properties.setProperty(MysqlConstants.MYSQL_USER, config.getUsername());
properties.setProperty(MysqlConstants.MYSQL_PASSWORD, config.getPassword());
// 获取数据库连接
return DriverManager.getConnection(url, properties);
}
private DataSource createDataSource(DatabaseConfig config) {
// 使用DriverManagerDataSource创建数据源
DriverManagerDataSource dataSource = new DriverManagerDataSource();
// 设置数据源的驱动类名、URL、用户名和密码
dataSource.setDriverClassName(config.getDriverClassName());
dataSource.setUrl(config.getUrl());
dataSource.setUsername(config.getUsername());
dataSource.setPassword(config.getPassword());
return dataSource;
}
}

View File

@ -0,0 +1,27 @@
# Tomcat
server:
port: 8886
# Spring
spring:
application:
# 应用名称
name: etl-data-source-service
profiles:
# 环境配置
active: dev
main:
# 允许使用循环引用
allow-circular-references: true
# 允许定义相同的bean对象 去覆盖原有的
allow-bean-definition-overriding: true
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 182.254.221.163:8848
config:
# 配置中心地址
server-addr: 182.254.221.163:8848
# 配置文件格式
file-extension: yml

View File

@ -0,0 +1,39 @@
package com.etl.data.source.server;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.sql.*;
import java.util.*;
@SpringBootTest
class ElDataSourceServerApplicationTests {
@Test
void contextLoads() {
// List<String> list = Arrays.asList("a", "b", "c");
// list.forEach(item -> System.out.println("Lambda方式遍历元素: "+item));
//创建一个未排序的列表
List<String> list = Arrays.asList("b", "a", "c","aa");
//使用传统方式进行排序
// Collections.sort(list, new Comparator<String>() {
// @Override
// public int compare(String o1, String o2) {
// return o1.compareTo(o2);
// }
// });
//
// System.out.println("传统方式排序结果:"+list);
// list.sort((s1,s2) -> s1.compareTo(s2));
// System.out.println("Lambda方式排序结果"+list);
//创建一个新的列表来存储过滤后的结果
// ArrayList<String> filteredLis = new ArrayList<>();
// //使用传统方式过滤
// for (String item : list) {
// if(item.startsWith("a")){
// filteredLis.add(item);
// }
// }
// //打印过滤后的列表
// System.out.println("传统过滤结果:"+filteredLis);
}
}

View File

@ -0,0 +1,27 @@
# Tomcat
server:
port: 8886
# Spring
spring:
application:
# 应用名称
name: etl-data-source-service
profiles:
# 环境配置
active: dev
main:
# 允许使用循环引用
allow-circular-references: true
# 允许定义相同的bean对象 去覆盖原有的
allow-bean-definition-overriding: true
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 182.254.221.163:8848
config:
# 配置中心地址
server-addr: 182.254.221.163:8848
# 配置文件格式
file-extension: yml

View File

@ -0,0 +1,5 @@
#Generated by Maven
#Fri Jun 21 15:04:44 CST 2024
groupId=com.bwie
artifactId=el-data-source-server
version=1.0-SNAPSHOT

View File

@ -0,0 +1 @@
com\etl\data\source\server\ElDataSourceServerApplication.class

View File

@ -0,0 +1 @@
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\ElDataSourceServerApplication.java

View File

@ -0,0 +1 @@
com\etl\data\source\server\ElDataSourceServerApplicationTests.class

View File

@ -0,0 +1 @@
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\test\java\com\etl\data\source\server\ElDataSourceServerApplicationTests.java

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>etl-cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>etl-data-source</artifactId>
<description>etl-data-source</description>
<packaging>pom</packaging>
<modules>
<module>el-data-source-server</module>
<module>el-data-source-common</module>
</modules>
</project>

View File

@ -62,11 +62,6 @@
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.1.3</version> <version>3.1.3</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,31 @@
# Tomcat
server:
port: 18080
# Spring
spring:
application:
# 应用名称
name: etl-gateway
profiles:
# 环境配置
active: dev
main:
# 允许使用循环引用
allow-circular-references: true
# 允许定义相同的bean对象 去覆盖原有的
allow-bean-definition-overriding: true
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
config:
# 配置中心地址
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -11,6 +11,7 @@
<modules> <modules>
<module>etl-common</module> <module>etl-common</module>
<module>etl-gateway</module> <module>etl-gateway</module>
<module>etl-data-source</module>
</modules> </modules>
<properties> <properties>