新增: 加载表方法
parent
385ea82755
commit
ad79acc598
@ -0,0 +1,69 @@
|
|||||||
|
package space.caoshd.otone.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TableInfo {
|
||||||
|
|
||||||
|
private String comment;
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
private String beanName;
|
||||||
|
|
||||||
|
private String beanParamName;
|
||||||
|
|
||||||
|
private List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
|
|
||||||
|
private Map<String, List<FieldInfo>> indexMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
private Boolean booleanExists;
|
||||||
|
|
||||||
|
private Boolean dateExists;
|
||||||
|
|
||||||
|
private Boolean dateTimeExists;
|
||||||
|
|
||||||
|
private Boolean bigDecimalExists;
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBeanName() {
|
||||||
|
return beanName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeanName(String beanName) {
|
||||||
|
this.beanName = beanName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBeanParamName() {
|
||||||
|
return beanParamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeanParamName(String beanParamName) {
|
||||||
|
this.beanParamName = beanParamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FieldInfo> getFieldInfoList() {
|
||||||
|
return fieldInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldInfoList(List<FieldInfo> fieldInfoList) {
|
||||||
|
this.fieldInfoList = fieldInfoList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package space.caoshd.otone.util;
|
||||||
|
|
||||||
|
public class ConfigConstants {
|
||||||
|
|
||||||
|
public static final String SCHEMA_NAMES = "database.schemas";
|
||||||
|
|
||||||
|
public static final String TABLE_NAMES = "table.names";
|
||||||
|
|
||||||
|
public static final String TABLE_PREFIXIES = "table.prefixes";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package space.caoshd.otone.util;
|
|
||||||
|
|
||||||
public class Constants {
|
|
||||||
public Constants() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String DATASOURCE_PATH = "datasource.properties";
|
|
||||||
|
|
||||||
public static final String CONFIG_PATH = "config.properties";
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package space.caoshd.otone.util;
|
||||||
|
|
||||||
|
public class PropertiesConstants {
|
||||||
|
|
||||||
|
public PropertiesConstants() {}
|
||||||
|
|
||||||
|
public static final String DATASOURCE_PROPERTIES_PATH = "datasource.properties";
|
||||||
|
|
||||||
|
public static final String CONFIG_PROPERTIES_PATH = "config.properties";
|
||||||
|
|
||||||
|
public static final String MYSQL_PROPERTIES_PATH = "mysql.properties";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
database.schemas=otone
|
||||||
|
table.names=t_file_export_instance,t_file_export_path,t_file_export_type_text,t_file_export_workspace
|
||||||
|
table.prefixes=t_,m_
|
@ -1,4 +1,4 @@
|
|||||||
username=root
|
username=root
|
||||||
password=123456
|
password=123456
|
||||||
url=jdbc:mysql://localhost:3306/otone?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
url=jdbc:mysql://192.168.0.100:3306/otone?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||||
driver-class-name=com.mysql.cj.jdbc.Driver
|
driver-class-name=com.mysql.cj.jdbc.Driver
|
@ -0,0 +1,5 @@
|
|||||||
|
table.detail.sql=select * from information_schema.tables
|
||||||
|
table.detail.sql.schema=select * from information_schema.tables where table_schema = ?
|
||||||
|
table.detail.sql.schema.table=select * from information_schema.tables where table_schema = ? and table_name = ?
|
||||||
|
table.detail.label.table-name=TABLE_NAME
|
||||||
|
table.detail.label.table-comment=TABLE_COMMENT
|
@ -0,0 +1,25 @@
|
|||||||
|
package space.caoshd.otone.util;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import space.caoshd.otone.tool.PropertyTools;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
class DatabaseUtilsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void executeQuery() {
|
||||||
|
PropertyTools sqlProperties = new PropertyTools(PropertiesConstants.MYSQL_PROPERTIES_PATH);
|
||||||
|
String sql = sqlProperties.getString(SqlConstants.TABLE_DETAIL_SQL_SCHEMA_TABLE);
|
||||||
|
PropertyTools configProperties =
|
||||||
|
new PropertyTools(PropertiesConstants.CONFIG_PROPERTIES_PATH);
|
||||||
|
List<String> schemas = configProperties.getStrings(ConfigConstants.SCHEMA_NAMES);
|
||||||
|
List<String> tables = configProperties.getStrings(ConfigConstants.TABLE_NAMES);
|
||||||
|
List<Object> params = Arrays.asList(schemas.get(0), tables.get(0));
|
||||||
|
List<Map<String, String>> maps = DatabaseUtils.list(sql, params);
|
||||||
|
Assertions.assertFalse(maps.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
database.schemas=otone
|
||||||
|
table.names=t_file_export_instance,t_file_export_path,t_file_export_type_text,t_file_export_workspace
|
||||||
|
table.prefixes=t_,m_
|
@ -1,4 +1,4 @@
|
|||||||
username=root
|
username=root
|
||||||
password=123456
|
password=123456
|
||||||
url=jdbc:mysql://localhost:3306/otone?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
url=jdbc:mysql://192.168.0.100:3306/otone?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||||
driver-class-name=com.mysql.cj.jdbc.Driver
|
driver-class-name=com.mysql.cj.jdbc.Driver
|
@ -0,0 +1,5 @@
|
|||||||
|
table.detail.sql=select * from information_schema.tables
|
||||||
|
table.detail.sql.schema=select * from information_schema.tables where table_schema = ?
|
||||||
|
table.detail.sql.schema.table=select * from information_schema.tables where table_schema = ? and table_name = ?
|
||||||
|
table.detail.label.table-name=TABLE_NAME
|
||||||
|
table.detail.label.table-comment=TABLE_COMMENT
|
Loading…
Reference in New Issue