From 55b6ce35c1cf113fcb21de661c30918d0ec58813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Sun, 17 Jan 2021 09:20:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=BC=94?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/system/controller/SystemBase.php | 26 ++++++++++ app/system/route/system.php | 1 + .../20210117005351_rule_addsystemreset.php | 49 +++++++++++++++++++ database/seeds/Rule.php | 7 +++ 4 files changed, 83 insertions(+) create mode 100644 database/migrations/20210117005351_rule_addsystemreset.php diff --git a/app/system/controller/SystemBase.php b/app/system/controller/SystemBase.php index 7066f32a..2ac80759 100755 --- a/app/system/controller/SystemBase.php +++ b/app/system/controller/SystemBase.php @@ -95,4 +95,30 @@ class SystemBase extends AdminBase return json($data); } + + // 系统初始化 + public function resetMayi() + { + // 删除班级 + $bjObj = new \app\teach\model\Banji; + $bjList = $bjObj->where('id', '>', 0)->select(); + $bj = $bjList->force()->delete(); + + // 删除学生信息 + $stuObj = new \app\student\model\Student; + $stuList = $stuObj->where('id', '>', 0)->select(); + $stu = $stuList->force()->delete(); + + // 删除教师信息 + $terObj = new \app\teacher\model\Teacher; + $terList = $terObj->where('id', '>', 0)->select(); + $ter = $terList->force()->delete(); + + $bj && $stu && $ter ? $data = ['msg' => '添加成功', 'val' => 1] + : $data = ['msg' => '数据处理错误', 'val' => 0]; + + // 返回信息 + return json($data); + } + } diff --git a/app/system/route/system.php b/app/system/route/system.php index 7d4de44a..b5706d24 100755 --- a/app/system/route/system.php +++ b/app/system/route/system.php @@ -14,6 +14,7 @@ use think\facade\Route; Route::group('/', function () { Route::rule('', 'SystemBase/edit', 'get'); # 系统配置页面 Route::rule('update/', 'SystemBase/update', 'put'); # 配置更新 + Route::rule('reset', 'SystemBase/resetMayi', 'post'); # 配置更新 }); // 文件管理 diff --git a/database/migrations/20210117005351_rule_addsystemreset.php b/database/migrations/20210117005351_rule_addsystemreset.php new file mode 100644 index 00000000..e91694ff --- /dev/null +++ b/database/migrations/20210117005351_rule_addsystemreset.php @@ -0,0 +1,49 @@ + 707 + ,'title' => '删除演示数据' + ,'name' => 'system/systembase/resetmayi' + ,'paixu' => 7 + ,'pid' => 7 + ,'ismenu' => 1 + ], + ]; + + // this is a handy shortcut + $this->insert('auth_rule', $singleRow); + } + + public function down() + { + $this->execute('DELETE FROM cj_auth_rule where id=707'); + } +} diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 8b121a57..7e10c6ea 100755 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -1282,6 +1282,13 @@ class Rule extends Seeder ,'paixu' => 7 ,'pid' => 706 ], + ['id' => 707 + ,'title' => '删除演示数据' + ,'name' => 'system/systembase/resetmayi' + ,'paixu' => 7 + ,'pid' => 7 + ,'ismenu' => 1 + ], /*====================================================================== * 考试管理