Jelajahi Sumber

获取数据库表信息

3254194295 5 bulan lalu
induk
melakukan
ac6df66b2e

+ 25 - 1
platform-rest/src/main/java/com/platform/rest/controller/workflow/DatabaseController.java

@@ -38,7 +38,19 @@ import java.util.List;
 public class DatabaseController {
 
 
-
+    public static void main(String[] args) {
+        String h ="shabi";
+        String[] arr =h.split("_");
+        String str = h;
+        if (arr.length>1){
+            str = arr[0];
+            for (int i=1;i<arr.length;i++){
+                arr[i] = arr[i].substring(0,1).toUpperCase()+arr[i].substring(1);
+                str+=arr[i];
+            }
+        }
+        System.out.println(str);
+    }
     /**
      * 通过id查询单条记录
      *
@@ -51,6 +63,18 @@ public class DatabaseController {
             throw new BusinessException("表名为空!");
         }
         List<String> columnNames = DatabaseUtil.getColumnNames(tableName);
+        columnNames.forEach(item->{
+            String[] arr =item.split("_");
+            String str = item;
+            if (arr.length>1){
+                str = arr[0];
+                for (int i=1;i<arr.length;i++){
+                    arr[i] = arr[i].substring(0,1).toUpperCase()+arr[i].substring(1);
+                    str+=arr[i];
+                }
+                item = str;
+            }
+        });
         List<String> columnComments = DatabaseUtil.getColumnComments(tableName);
         List<JSONObject> list = new ArrayList<>();
         for (int i = 0;i<columnNames.size();i++){