zilong 4 jaren geleden
bovenliggende
commit
3614c5cf2b
1 gewijzigde bestanden met toevoegingen van 20 en 36 verwijderingen
  1. 20 36
      app/Http/Controllers/Api/V1/CommonController.php

+ 20 - 36
app/Http/Controllers/Api/V1/CommonController.php

xqd
@@ -79,48 +79,32 @@ class CommonController extends Controller
     {
         $database = env('DB_DATABASE');
         $prefix = env('DB_PREFIX');
-        $map1 = [
-            'users' => 'users(用户表)',
-            'organizations' => 'organizations(机构表)',
-            'orders' => 'orders(订单表)',
-            'order_patients' => 'order_patients(订单患者表)',
-            'order_vaccines' => 'order_vaccines(订单疫苗表)',
-            'order_nurses' => 'order_nurses(订单儿保表)',
-            'order_packs' => 'order_packs(订单服务包表)',
-            'schedules' => 'schedules(排班表)',
-            'schedule_periods' => 'schedule_periods(排班时间段表)',
-            'qualifications' => 'qualifications(医生资质表)',
-            'coupons' => 'coupons(优惠券表)',
-            'coupon_types' => 'coupon_types(优惠券类型表)',
-        ];
-
-        $data1 = array();
+        $exclude_tables = "'bm_password_resets','bm_admin_menu','bm_admin_users','bm_failed_jobs','bm_migrations'";
+
+        $sql = "select TABLE_NAME name,TABLE_COMMENT comment from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='".$database."' and TABLE_NAME not in (".$exclude_tables.")";
+        $tables = \DB::select($sql);
+        $map1 = $map2 = [];
+        $i = round(count($tables)/2);
+        foreach ($tables as $k => $v) {
+            $name = str_replace($prefix, '', $v->name);
+            if ($k >= $i) {
+                $map1[$v->name] = $name.'('.$v->comment.')';
+            }
+            else {
+                $map2[$v->name] = $name.'('.$v->comment.')';
+            }
+        }
+
+        $data1 = [];
         foreach ($map1 as $k => $v){
-            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$prefix.$k."'";
+            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
             $comment = \DB::select($sql);
             $data1[$v] = $comment;
         }
 
-        $map2 = [
-            'docters' => 'docters(医生表)',
-            'docter_organizations' => 'docter_organizations(医生机构关联表)',
-            'payments' => 'payments(支付表)',
-            'patients' => 'patients(患者档案表)',
-            'nurses' => 'nurses(儿保项目表)',
-            'vaccines' => 'vaccines(疫苗表)',
-            'service_packs' => 'service_packs(服务包表)',
-            'time_periods' => 'time_periods(时间段配置表)',
-            'teams' => 'teams(团队表)',
-            'team_docters' => 'team_docters(团队医生表)',
-            'offices' => 'offices(科室表)',
-            'user_coupons' => 'user_coupons(用户优惠券表)',
-            'user_messages' => 'user_messages(用户消息表)',
-            'areas' => 'areas(地区表)',
-        ];
-
-        $data2 = array();
+        $data2 = [];
         foreach ($map2 as $k => $v){
-            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$prefix.$k."'";
+            $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
             $comment = \DB::select($sql);
             $data2[$v] = $comment;
         }