|
@@ -54,6 +54,37 @@ public class MybatisPlusGenCode {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static String getTableInfo(String tableName) {
|
|
|
+ String tableInfo = "";
|
|
|
+ try {
|
|
|
+
|
|
|
+ Class.forName(DRIVER_CLASS);
|
|
|
+
|
|
|
+ Connection connection = DriverManager.getConnection(CONNECTION_URL, USER_ID, PASS_WORD);
|
|
|
+
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String sql = "SELECT table_name,table_comment FROM information_schema.TABLES WHERE table_schema = '" + DATABASE_NAME + "' AND table_name = '" + tableName + "'";
|
|
|
+ ResultSet resultSet = statement.executeQuery(sql);
|
|
|
+ System.out.println("sql:" + sql);
|
|
|
+ while (resultSet.next()) {
|
|
|
+
|
|
|
+
|
|
|
+ tableInfo = resultSet.getString("table_comment");
|
|
|
+ }
|
|
|
+
|
|
|
+ resultSet.close();
|
|
|
+ statement.close();
|
|
|
+ connection.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException("数据库连接错误!");
|
|
|
+ }
|
|
|
+ return tableInfo;
|
|
|
+ }
|
|
|
+
|
|
|
public static List<ColumnVo> getIdType(String tableName) {
|
|
|
|
|
|
List<ColumnVo> columnVos = new ArrayList<>();
|
|
@@ -113,6 +144,8 @@ public class MybatisPlusGenCode {
|
|
|
ve.init();
|
|
|
VelocityContext ctx = new VelocityContext();
|
|
|
ctx.put("tableName", tableName);
|
|
|
+ String tableInfo = getTableInfo(tableName);
|
|
|
+ ctx.put("tableInfo", tableInfo);
|
|
|
|
|
|
List<ColumnVo> mysqlDataType = getIdType(tableName);
|
|
|
for (ColumnVo columnVo : mysqlDataType) {
|