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 + ], /*====================================================================== * 考试管理