1
0

feat: 增加DDL语句生成小工具

This commit is contained in:
2025-09-11 11:31:12 +08:00
parent efd7f5e9f2
commit 8a0c1ae3be
7 changed files with 58 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<JSCodeStyleSettings version="0"> <JSCodeStyleSettings version="0">
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" /> <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="FORCE_SEMICOLON_STYLE" value="true" /> <option name="FORCE_SEMICOLON_STYLE" value="true" />
@@ -27,6 +28,9 @@
<ScalaCodeStyleSettings> <ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" /> <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings> </ScalaCodeStyleSettings>
<SqlCodeStyleSettings version="7">
<option name="KEYWORD_CASE" value="1" />
</SqlCodeStyleSettings>
<TypeScriptCodeStyleSettings version="0"> <TypeScriptCodeStyleSettings version="0">
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" /> <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="FORCE_SEMICOLON_STYLE" value="true" /> <option name="FORCE_SEMICOLON_STYLE" value="true" />
@@ -73,6 +77,15 @@
<option name="TAB_SIZE" value="2" /> <option name="TAB_SIZE" value="2" />
</indentOptions> </indentOptions>
</codeStyleSettings> </codeStyleSettings>
<codeStyleSettings language="SQL">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript"> <codeStyleSettings language="TypeScript">
<indentOptions> <indentOptions>
<option name="INDENT_SIZE" value="2" /> <option name="INDENT_SIZE" value="2" />

4
.idea/dataSources.xml generated
View File

@@ -39,11 +39,11 @@
</jdbc-additional-properties> </jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
<data-source source="LOCAL" name="leopard@81.71.3.24" uuid="4b5dd0f8-26c8-49e2-b794-d464461c121a"> <data-source source="LOCAL" name="leopard_dev@81.71.3.24" uuid="63824900-a456-4883-8de4-8f436cd00c71">
<driver-ref>postgresql</driver-ref> <driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver> <jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://81.71.3.24:6785/leopard</jdbc-url> <jdbc-url>jdbc:postgresql://81.71.3.24:6785/leopard_dev</jdbc-url>
<jdbc-additional-properties> <jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" /> <property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" /> <property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />

View File

@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DataSourcePerFileMappings"> <component name="DataSourcePerFileMappings">
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/4b5dd0f8-26c8-49e2-b794-d464461c121a/console.sql" value="4b5dd0f8-26c8-49e2-b794-d464461c121a" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/a8b9cd0a-335e-42ae-991a-f2733200afbf/console.sql" value="a8b9cd0a-335e-42ae-991a-f2733200afbf" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/f7d817dc-8c9c-479f-b469-583df17cb013/console.sql" value="f7d817dc-8c9c-479f-b469-583df17cb013" /> <file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/f7d817dc-8c9c-479f-b469-583df17cb013/console.sql" value="f7d817dc-8c9c-479f-b469-583df17cb013" />
</component> </component>
</project> </project>

View File

@@ -24,6 +24,17 @@
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -9,7 +9,6 @@ import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners; import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated; import jakarta.persistence.Enumerated;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.time.LocalDate; import java.time.LocalDate;
@@ -74,10 +73,6 @@ public class Stock extends SimpleEntity {
@ToString.Exclude @ToString.Exclude
private Set<CashFlow> cashFlows; private Set<CashFlow> cashFlows;
@ManyToMany
@ToString.Exclude
private Set<StockCollection> collections;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum Market implements SimpleEnum { public enum Market implements SimpleEnum {

View File

@@ -0,0 +1,25 @@
package com.lanyuanxiaoyao.leopard.core;
import com.lanyuanxiaoyao.service.template.util.DDLGenerator;
import org.hibernate.dialect.PostgreSQLDialect;
import org.postgresql.Driver;
/**
* 建表语句
*
* @author lanyuanxiaoyao
* @version 20250911
*/
public class GenerateDDL {
public static void main(String[] args) {
DDLGenerator.generateDDL(
"com.lanyuanxiaoyao.leopard.core.entity",
"/Users/lanyuanxiaoyao/Project/IdeaProjects/leopard/leopard-core/target",
PostgreSQLDialect.class,
"jdbc:postgresql://81.71.3.24:6785/leopard_dev",
"leopard",
"9NEzFzovnddf@PyEP?e*AYAWnCyd7UhYwQK$pJf>7?ccFiN^x4$eKEZ5~E<7<+~X",
Driver.class
);
}
}

View File

@@ -24,6 +24,7 @@
<spring-boot.version>3.5.0</spring-boot.version> <spring-boot.version>3.5.0</spring-boot.version>
<spring-cloud.version>2025.0.0</spring-cloud.version> <spring-cloud.version>2025.0.0</spring-cloud.version>
<spring-ai.version>1.0.1</spring-ai.version> <spring-ai.version>1.0.1</spring-ai.version>
<hibernate.version>6.6.15.Final</hibernate.version>
<eclipse-collections.version>13.0.0</eclipse-collections.version> <eclipse-collections.version>13.0.0</eclipse-collections.version>
<hutool.version>5.8.39</hutool.version> <hutool.version>5.8.39</hutool.version>
@@ -74,6 +75,12 @@
<version>${liteflow.version}</version> <version>${liteflow.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>