From 15fadce52e9f5130ca4a29b1b20a9a7a5455f2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Fri, 8 Jan 2021 11:41:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9phinx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/login/route/login.php | 3 +-- database/migrations/20210107070200_kaoshi_up.php | 4 +++- database/seeds/Admin.php | 13 ++++++++++--- database/seeds/Banji.php | 10 +++++++++- database/seeds/Category.php | 8 ++++++++ database/seeds/Rule.php | 7 +++++++ database/seeds/School.php | 6 ++++++ database/seeds/Student.php | 7 +++++++ database/seeds/Subject.php | 12 +++++++++--- database/seeds/SystemBase.php | 8 ++++++++ database/seeds/Teacher.php | 7 +++++++ database/seeds/TongjiXingmu.php | 8 ++++++++ database/seeds/Xueqi.php | 7 +++++++ database/seeds/{AuthGroup.php => ZauthGroup.php} | 15 ++++++++++----- 14 files changed, 100 insertions(+), 15 deletions(-) rename database/seeds/{AuthGroup.php => ZauthGroup.php} (61%) diff --git a/app/login/route/login.php b/app/login/route/login.php index 8cbc3480..685abb69 100755 --- a/app/login/route/login.php +++ b/app/login/route/login.php @@ -28,5 +28,4 @@ Route::group('student', function () { // 学生查询成绩登录 Route::group('teacher', function () { Route::rule('', 'Teacher/login', 'post'); -}); - +}); \ No newline at end of file diff --git a/database/migrations/20210107070200_kaoshi_up.php b/database/migrations/20210107070200_kaoshi_up.php index dcb5724c..ec2e3725 100644 --- a/database/migrations/20210107070200_kaoshi_up.php +++ b/database/migrations/20210107070200_kaoshi_up.php @@ -45,7 +45,9 @@ class KaoshiUp extends Migrator $table = $this->table('kaoshi'); $table - ->removeColumn('user_id', 'user_group', 'jibie_id') + ->removeColumn('user_id') + ->removeColumn('user_group') + ->removeColumn('jibie_id') ->update(); } } diff --git a/database/seeds/Admin.php b/database/seeds/Admin.php index 23bac039..ad5cbc9b 100755 --- a/database/seeds/Admin.php +++ b/database/seeds/Admin.php @@ -14,7 +14,7 @@ class Admin extends Seeder */ public function run() { - // 初始化超级管理员 + // 定义表的名称 $rows = [ [ 'id' => 1, @@ -30,10 +30,17 @@ class Admin extends Seeder 'school_id' => 1, 'password' => '$apr1$RSUodBwI$zOhVq9RQWfQDOW2sbeCDS1', ], + ]; - ]; + $serRows = $this->fetchAll('select * from cj_admin'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = array(); + return true; + } + // 保存数据 - $this->table('admin')->insert($rows)->save(); + $this->table('admin')->insert($rows)->update(); } } diff --git a/database/seeds/Banji.php b/database/seeds/Banji.php index 82294c58..548ec278 100644 --- a/database/seeds/Banji.php +++ b/database/seeds/Banji.php @@ -14,6 +14,7 @@ class Banji extends Seeder */ public function run() { + // 定义表的名称 $y = date('Y'); $m = date('m'); @@ -25,7 +26,7 @@ class Banji extends Seeder } // 设置数据 - $rows= [ + $rows = [ [ 'school_id' => 2 ,'ruxuenian' => $ruxuenian @@ -43,6 +44,13 @@ class Banji extends Seeder ] ]; + $serRows = $this->fetchAll('select * from cj_banji'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = array(); + return true; + } + // 保存数据 $this->table('banji')->insert($rows)->save(); diff --git a/database/seeds/Category.php b/database/seeds/Category.php index 59f04b17..87f066f5 100755 --- a/database/seeds/Category.php +++ b/database/seeds/Category.php @@ -297,6 +297,14 @@ class Category extends Seeder ['id' => 12211,'title' => '管理员-学生成绩列表-成绩条(学生)','p_id' => 122,'paixu' => 10,'isupdate' => 0], ['id' => 12212,'title' => '管理员-学生成绩列表-成绩条(班级)','p_id' => 122,'paixu' => 10,'isupdate' => 0], ]; + + $serRows = $this->fetchAll('select * from cj_category'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = array(); + return true; + } + // 保存数据 $this->table('category')->insert($rows)->save(); } diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 8b121a57..a437c07d 100755 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -1755,6 +1755,13 @@ class Rule extends Seeder ], ]; + + $serRows = $this->fetchAll('select * from cj_auth_rule'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } // 保存数据 $this->table('auth_rule')->insert($rows)->save(); } diff --git a/database/seeds/School.php b/database/seeds/School.php index ad5910a6..992b477d 100755 --- a/database/seeds/School.php +++ b/database/seeds/School.php @@ -39,6 +39,12 @@ class School extends Seeder ,'xingzhi_id' => 10102 ], ]; + $serRows = $this->fetchAll('select * from cj_school'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } // 保存数据 $this->table('school')->insert($rows)->save(); } diff --git a/database/seeds/Student.php b/database/seeds/Student.php index 5d84c8cf..305c3880 100644 --- a/database/seeds/Student.php +++ b/database/seeds/Student.php @@ -60,6 +60,13 @@ class Student extends Seeder ] ]; + $serRows = $this->fetchAll('select * from cj_student'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 $this->table('student')->insert($rows)->save(); } diff --git a/database/seeds/Subject.php b/database/seeds/Subject.php index c4cef836..949c510a 100755 --- a/database/seeds/Subject.php +++ b/database/seeds/Subject.php @@ -191,9 +191,15 @@ class Subject extends Seeder ], ]; + + $serRows = $this->fetchAll('select * from cj_subject'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 - $this->table('subject') - ->insert($rows) - ->save(); + $this->table('subject')->insert($rows)->save(); } } diff --git a/database/seeds/SystemBase.php b/database/seeds/SystemBase.php index 2245df5c..b9b37cf5 100755 --- a/database/seeds/SystemBase.php +++ b/database/seeds/SystemBase.php @@ -28,6 +28,14 @@ class SystemBase extends Seeder 'classalias' => 0, 'studefen' => 1, ]; + + $serRows = $this->fetchAll('select * from cj_system_base'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 $this->table('system_base')->insert($rows)->save(); } diff --git a/database/seeds/Teacher.php b/database/seeds/Teacher.php index 008ac01c..79eb5aa3 100644 --- a/database/seeds/Teacher.php +++ b/database/seeds/Teacher.php @@ -29,6 +29,13 @@ class Teacher extends Seeder ] ]; + $serRows = $this->fetchAll('select * from cj_teacher'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 $this->table('teacher')->insert($rows)->save(); } diff --git a/database/seeds/TongjiXingmu.php b/database/seeds/TongjiXingmu.php index 495f16d3..59be1541 100755 --- a/database/seeds/TongjiXingmu.php +++ b/database/seeds/TongjiXingmu.php @@ -1220,6 +1220,14 @@ class TongjiXingmu extends Seeder // ,'category_id' => 12209 // ] ]; + + $serRows = $this->fetchAll('select * from cj_tongji_xiangmu'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 $this->table('tongji_xiangmu')->insert($rows)->save(); } diff --git a/database/seeds/Xueqi.php b/database/seeds/Xueqi.php index 4bf7806c..7f8ed4fb 100644 --- a/database/seeds/Xueqi.php +++ b/database/seeds/Xueqi.php @@ -44,6 +44,13 @@ class Xueqi extends Seeder ] ]; + $serRows = $this->fetchAll('select * from cj_xueqi'); + if(is_array($serRows) && count($serRows) > 0) + { + $rows = []; + return true; + } + // 保存数据 $this->table('xueqi')->insert($rows)->save(); } diff --git a/database/seeds/AuthGroup.php b/database/seeds/ZauthGroup.php similarity index 61% rename from database/seeds/AuthGroup.php rename to database/seeds/ZauthGroup.php index 59f469f3..1f32890b 100644 --- a/database/seeds/AuthGroup.php +++ b/database/seeds/ZauthGroup.php @@ -2,7 +2,7 @@ use think\migration\Seeder; -class AuthGroup extends Seeder +class ZauthGroup extends Seeder { /** * Run Method. @@ -14,10 +14,8 @@ class AuthGroup extends Seeder */ public function run() { - $auth = new \app\admin\model\AuthRule; - $authList = $auth - ->where('status', 1) - ->column('id'); + $authList = $this->fetchAll('select * from cj_auth_rule where status = 1'); + $authList = array_column($authList, 'id'); $authList = implode(',', $authList); // 设置数据 @@ -29,6 +27,13 @@ class AuthGroup extends Seeder ] ]; + $serRows = $this->fetchAll('select * from cj_auth_group'); + if($rows[0]['rules'] == '' || (is_array($serRows) && count($serRows) > 0)) + { + $rows = array(); + return true; + } + // 保存数据 $this->table('auth_group')->insert($rows)->save(); }