From 81126bbb534383428b464cfc4b9c685b7ff64cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Sat, 13 Feb 2021 13:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E7=A7=BB=E6=9B=B4=E5=A4=9A=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/BaseController.php | 5 +- app/base/controller/AdminBase.php | 10 +- app/base/controller/ToolBase.php | 35 ++++++ app/chengji/controller/Tongji.php | 73 ++++--------- app/chengji/model/Tongji.php | 40 +++++++ app/chengji/route/chengji.php | 4 +- app/kaohao/controller/Index.php | 2 +- app/kaoshi/controller/Index.php | 29 +++-- app/kaoshi/route/kaoshi.php | 1 + app/kaoshi/view/index/chengji.html | 124 +++++++++++++++++++++ app/kaoshi/view/index/index.html | 16 ++- app/kaoshi/view/index/tongji.html | 8 +- app/kaoshi/view/kaoshi_set/index.html | 10 +- app/login/controller/Index.php | 151 ++++++++++++++++++-------- app/login/controller/Student.php | 87 --------------- app/login/controller/Teacher.php | 91 ---------------- app/login/controller/YanZheng.php | 114 +++++++++++++++++++ app/login/route/login.php | 14 +-- app/login/view/index/index.html | 26 ++--- app/login/view/index/shangma_log.html | 2 +- app/luru/controller/Index.php | 27 +---- app/middleware/Login.php | 14 +-- database/seeds/Rule.php | 45 +++++--- 23 files changed, 557 insertions(+), 371 deletions(-) create mode 100644 app/base/controller/ToolBase.php create mode 100644 app/kaoshi/view/index/chengji.html delete mode 100755 app/login/controller/Student.php delete mode 100755 app/login/controller/Teacher.php create mode 100644 app/login/controller/YanZheng.php diff --git a/app/BaseController.php b/app/BaseController.php index 64cd5303..cc0cfd53 100755 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -37,10 +37,13 @@ abstract class BaseController * @var array */ protected $middleware = [ - 'online' + // 'online' ]; + protected $online; + + /** * 构造方法 * @access public diff --git a/app/base/controller/AdminBase.php b/app/base/controller/AdminBase.php index dbacd7b2..5c564089 100755 --- a/app/base/controller/AdminBase.php +++ b/app/base/controller/AdminBase.php @@ -8,7 +8,7 @@ use app\BaseController; /** * 控制器基础类 */ -abstract class AdminBase extends BaseController +abstract class AdminBase extends BaseController { /** * 控制器中间件 @@ -24,9 +24,9 @@ abstract class AdminBase extends BaseController protected function initialize() { $this->online = session('onlineCategory'); - // if($this->online != 'admin') - // { - // \app\facade\OnLine::jump('/login', '请使用管理员帐号登录'); - // } + if($this->online != 'admin') + { + \app\facade\OnLine::jump('/login', '请使用管理员帐号登录'); + } } } diff --git a/app/base/controller/ToolBase.php b/app/base/controller/ToolBase.php new file mode 100644 index 00000000..185bee23 --- /dev/null +++ b/app/base/controller/ToolBase.php @@ -0,0 +1,35 @@ +online = session('onlineCategory'); + if($this->online == 'teacher') + { + $this->middleware = [ + 'online' + ,'login' + ]; + }else{ + $this->middleware = [ + 'online' + ,'login' + ,'auth' + ]; + } + $this->luruTeacherId = session('user_id'); + } + +} diff --git a/app/chengji/controller/Tongji.php b/app/chengji/controller/Tongji.php index fdee89c0..9b1df0ea 100755 --- a/app/chengji/controller/Tongji.php +++ b/app/chengji/controller/Tongji.php @@ -73,65 +73,36 @@ class Tongji extends AdminBase } - // 按学科重新计算得分率 - public function editDefenlv($kaoshi_id) { - - // 设置页面标题 - $list['set'] = array( - 'webtitle'=>'编辑课题', - 'butname'=>'修改', - 'formpost'=>'PUT', - 'url'=>'/chengji/tongji/editdfl', - 'kaoshi_id'=>$kaoshi_id - ); - - // 模板赋值 - $this->view->assign('list', $list); - // 渲染 - return $this->view->fetch(); - } - - - // 更新得分率 + // 批量统计得分率 public function updateDefenLv() { // 获取参数 $src = $this->request ->only([ 'kaoshi_id' => 0 - ,'subject_id' => 0 - ,'ruxuenian' => 0 - ], 'PUT'); + ,'ruxuenian' + ,'subject_id' + ], 'POST'); - // 获取满分 - $ksSet = new \app\kaoshi\model\KaoshiSet; - $manfen = $ksSet->where('kaoshi_id', $src['kaoshi_id']) - ->where('subject_id', $src['subject_id']) - ->where('ruxuenian', $src['ruxuenian']) - ->field('id,title') - ->value('manfen'); - // 获取考号 - $kaohao = new \app\kaohao\model\Kaohao; - $kaohaoid = $kaohao->where('kaoshi_id', $src['kaoshi_id']) - ->where('ruxuenian', $src['ruxuenian']) - ->column('id'); - // 查询成绩 - $cj = new \app\chengji\model\Chengji; - $cjList = $cj->where('kaohao_id', 'in', $kaohaoid) - ->where('subject_id', $src['subject_id']) - ->whereNotNull('defen') - ->field('id, defen, defenlv') - ->select(); + $tj = new TJ(); + if(isset($src['ruxuenian']) && isset($src['subject_id'])) + { + $data = $tj->updateDfl($src); + }else{ + $ksset = new \app\kaoshi\model\KaoshiSet; - $data = array(); - foreach ($cjList as $key => $value) { - $data[] = [ - 'id' => $value->id - ,'defenlv' => $value->defen / $manfen *100 - ]; + // 重新计算得分率 + $nj = $ksset->srcGrade($src['kaoshi_id']); # 获取参考年级 + foreach ($nj as $key => $value) { # 循环获取各年级参考学科 + $src['ruxuenian'] = $value['ruxuenian']; + $manfen = $ksset->srcSubject($src); # 获取本年级各学科满分 + // 循环取出当前学科成绩 + foreach ($manfen as $mf_k => $mf_v) { + $src['subject_id'] = $mf_v['id']; + $data = $tj->updateDfl($src); + } + } } - - $data = $cj->saveAll($data); - + $data ? $data = ['msg' => '重新计算完成', 'val' => 1] : $data = ['msg' => '数据处理错误', 'val' => 0]; diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index 941259b3..8d6748ae 100755 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -375,5 +375,45 @@ class Tongji extends BaseModel } + // 重新计算得分率 + public function updateDfl($srcfrom) + { + $src = [ + 'kaoshi_id' => 0 + ,'ruxuenian' => 0 + ,'subject_id' => 0 + ]; + // 用新值替换初始值 + $src = array_cover($srcfrom, $src); + $cj = new \app\chengji\model\Chengji; + $kh = new \app\kaohao\model\Kaohao; + + // 查询考号 + $kaohaoid = $kh->where('kaoshi_id', $src['kaoshi_id']) + + ->where('ruxuenian', $src['ruxuenian']) + ->column('id'); + // 查询成绩 + $cjList = $cj->where('kaohao_id', 'in', $kaohaoid) + ->where('subject_id', $src['subject_id']) + ->whereNotNull('defen') + ->field('id, defen, defenlv') + ->select(); + // 循环写入新成绩 + $data = array(); + foreach ($cjList as $cj_k => $cj_v) { + $data[] = [ + 'id' => $cj_v->id + ,'defenlv' => $cj_v->defen / $mf_v['fenshuxian']['manfen'] *100 + ]; + } + $data = $cj->saveAll($data); + + $data ? $data = true : false; + + return $data; + } + + } diff --git a/app/chengji/route/chengji.php b/app/chengji/route/chengji.php index 99a3fa9b..ab1dd410 100755 --- a/app/chengji/route/chengji.php +++ b/app/chengji/route/chengji.php @@ -32,8 +32,8 @@ Route::group('index', function () { Route::group('tongji', function () { Route::rule('yilucnt/','Tongji/yiluCnt'); # 更新信息 Route::rule('data','Tongji/ajaxData','post'); # 扫码界面 - Route::rule('editdfl/','Tongji/editDefenLv','get'); # 扫码界面 - Route::rule('editdfl','Tongji/updateDefenLv','put'); # 扫码界面 + // Route::rule('editdfl/','Tongji/editDefenLv','get'); # 扫码界面 + Route::rule('editdfl','Tongji/updateDefenLv','post'); # 扫码界面 }); diff --git a/app/kaohao/controller/Index.php b/app/kaohao/controller/Index.php index 330cd1e9..98ed1bc5 100755 --- a/app/kaohao/controller/Index.php +++ b/app/kaohao/controller/Index.php @@ -6,7 +6,7 @@ use app\base\controller\AdminBase; // 引用数据模型类 use app\kaoshi\model\Kaoshi as KS; - +use app\kaoshi\model\KaoshiSet as ksset; use app\kaohao\model\Kaohao as KH; use think\Validate; diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index 3c9dbb2f..2d15e4ad 100755 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -173,10 +173,11 @@ class Index extends AdminBase ,'url' => '/chengji/schtj/tongji' ,'checked' => ' checked' ] - // ,[ - // 'title' => '重算得分率' - // ,'url' => '/chengji/tongji/editdfl/' . $kaoshi_id - // ] + ,[ + 'title' => '重算得分率' + ,'url' => '/chengji/tongji/editdfl' + ,'checked' => '' + ] ]; // 模板赋值 @@ -303,9 +304,6 @@ class Index extends AdminBase } - - - // 设置成绩是否允许操作 public function luru() { @@ -373,4 +371,21 @@ class Index extends AdminBase // 渲染 return $this->view->fetch(); } + + + // 查询考试成绩 + public function chengji($kaoshi_id) + { + // 获取考试信息 + $kaoshi = KS::where('id', $kaoshi_id) + ->field('id, title, bfdate, enddate') + ->find(); + + // 设置页面标题 + $list['webtitle'] = $kaoshi->title . '(' . $kaoshi->bfdate . '~' . $kaoshi->enddate . ')'; + $list['kaoshi_id'] = $kaoshi->id; + $this->view->assign('list', $list); + // 渲染 + return $this->view->fetch(); + } } diff --git a/app/kaoshi/route/kaoshi.php b/app/kaoshi/route/kaoshi.php index 55a3a916..5201c44e 100755 --- a/app/kaoshi/route/kaoshi.php +++ b/app/kaoshi/route/kaoshi.php @@ -27,6 +27,7 @@ Route::group('index', function () { Route::rule('setp2/','Index/createSetp2','get'); # 添加信息 Route::rule('setp3/','Index/createSetp3','get'); # 添加信息 Route::rule('tongji/','Index/tongji','get'); # 添加信息 + Route::rule('chengji/','Index/chengji','get'); # 添加信息 }); diff --git a/app/kaoshi/view/index/chengji.html b/app/kaoshi/view/index/chengji.html new file mode 100644 index 00000000..2ee3b94c --- /dev/null +++ b/app/kaoshi/view/index/chengji.html @@ -0,0 +1,124 @@ + + + + + {$list.webtitle} + + + + {load href="__XADMIN__/css/font.css" /} + {load href="__XADMIN__/css/xadmin.css" /} + {load href="__XADMIN__/js/jquery.min.js" /} + {load href="__XADMIN__/lib/layui/layui.js" /} + {load href="__XADMIN__/js/xadmin.js" /} + {load href="__XADMIN__/js/cookie.js" /} + {load href="__XADMIN__/js/md5.min.js" /} + {block name="jsset"}{/block} + + + + + + + {php}$kaoshi_id =$list['kaoshi_id']; {/php} + + +
 
+ + + diff --git a/app/kaoshi/view/index/index.html b/app/kaoshi/view/index/index.html index 366b093f..a2702ed7 100755 --- a/app/kaoshi/view/index/index.html +++ b/app/kaoshi/view/index/index.html @@ -60,9 +60,12 @@ @@ -78,7 +81,7 @@ // 设置列 options.cols=[[ //表头 {type:'checkbox', fixed:'left'}, - {field:'id', title:'操作', toolbar:'#barDemo', minWidth:120}, + {field:'id', title:'操作', toolbar:'#barDemo', minWidth:220}, {field:'luru', title:'成绩编辑', minWidth:100, templet:'#luru', sort:true}, {field:'status', title:'状态', minWidth:80, templet:'#jieshu', sort:true}, {field:'title', title:'考试名称', sort:true, minWidth:240}, @@ -140,6 +143,15 @@ case 'tongji':// 状态 cjgl.add(obj.data.title + ' 成绩统计', '/kaoshi/index/tongji/' + obj.data.id, '650', '400', false); break; + case 'fenshuxian':// 设置分数线 + cjgl.addTab(obj.data.title + ' 分数线', '/kaoshi/kaoshiset/index/' + obj.data.id, true); + break; + case 'kaohao':// 生成考号 + cjgl.add(obj.data.title + ' 生成考号', '/kaohao/index/createall/' + obj.data.id, '650', '400', false); + break; + case 'chengji':// 查询成绩 + cjgl.addTab(obj.data.title + ' 查看成绩', '/kaoshi/index/chengji/' + obj.data.id, true); + break; }; }); }); diff --git a/app/kaoshi/view/index/tongji.html b/app/kaoshi/view/index/tongji.html index c783f9b9..bac1c821 100644 --- a/app/kaoshi/view/index/tongji.html +++ b/app/kaoshi/view/index/tongji.html @@ -9,9 +9,9 @@ - - - + + + @@ -30,7 +30,7 @@ diff --git a/app/kaoshi/view/kaoshi_set/index.html b/app/kaoshi/view/kaoshi_set/index.html index 3ea2aa16..364eb273 100755 --- a/app/kaoshi/view/kaoshi_set/index.html +++ b/app/kaoshi/view/kaoshi_set/index.html @@ -93,7 +93,7 @@ cjgl.delAll(checkStatus,'/kaoshi/kaoshiset/delete','mytable'); break; case 'add': - cjgl.add('添加参考学科','/kaoshi/kaoshiset/create/'+"{$list.kaoshi_id}",'','',true); + cjgl.add('添加参考学科','/kaoshi/kaoshiset/create/'+"{$list.kaoshi_id}",'650','400', false); break; }; }); @@ -111,7 +111,7 @@ defenlv(obj.data); break; case 'edit':// 编辑 - cjgl.add('编辑','/kaoshi/kaoshiset/edit/'+obj.data.id,'','',true); + cjgl.add('编辑','/kaoshi/kaoshiset/edit/'+obj.data.id,'650','400', false); break; }; }); @@ -136,12 +136,12 @@ val = { 'kaoshi_id':obj.kaoshi_id ,'subject_id':obj.subject_id - ,'nianji':obj.nianji + ,'ruxuenian':obj.ruxuenian } $.ajax({ - url:'/chengji/tongji/editdfl/'+ obj.kaoshi_id, + url:'/chengji/tongji/editdfl', data:val, - type:'PUT', + type:'POST', success: function(data, status) { layer.msg(data.msg); }, diff --git a/app/login/controller/Index.php b/app/login/controller/Index.php index db229866..a760fca3 100755 --- a/app/login/controller/Index.php +++ b/app/login/controller/Index.php @@ -1,11 +1,13 @@ view->assign('list',$list); // 渲染输出 - return View::fetch('index'); + return $this->view->fetch('index'); } - // 学生登录验证 - public function login() + // 管理员登录验证 + public function admin() { - session('onlineCategory', null); - session('user_id', null); - session('username', null); - session('password', null); + // 清除cookie + cookie('userid', null); + cookie('username', null); + cookie('password', null); + // 清除session(当前作用域) + session(null); // 获取表单数据 $list = request() @@ -58,7 +62,7 @@ class Index return json(['msg' => $msg, 'val' => 0]); } - $yz = $this->yz($list['username'], $list['password']); + $yz = yz::admin($list['username'], $list['password']); if($yz['val'] === 1) { @@ -81,39 +85,100 @@ class Index } - // 获学生帐号密码信息 - public function yz($username, $password) + // 学生登录验证 + public function teacher() { - // 获取服务器密码 - $admin = new \app\admin\model\Admin; - $userinfo = $admin::where('username', $username) - ->where('status', 1) - ->field('id, lastip, username, ip, denglucishu, lasttime, thistime, password') - ->find(); - if ($userinfo == null) - { - // 验证结果; - $data = ['msg' => '管理员帐号不存在或被禁用', 'val' => 0]; - return $data; + // 清除cookie + cookie('userid', null); + cookie('username', null); + cookie('password', null); + // 清除session(当前作用域) + session(null); + + // 获取表单数据 + $list = request() + ->only([ + 'username' + ,'password' + ,'category' + ]); + + + $validate = new \app\login\validate\Yanzheng; + $result = $validate->scene('admin')->check($list); + $msg = $validate->getError(); + if(!$result){ + return json(['msg' => $msg, 'val' => 0]); } - // 验证用户名和密码 - $check = loginCheck($password, $userinfo->password); + $yz = yz::teacher($list['username'], $list['password']); - if ($check === true) + if($yz['val'] === 1) { - session('onlineCategory', 'admin'); - session('user_id', $userinfo->id); - session('username', $username); - session('password', $password); - // 跳转到首页 - $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\']; - } else { - // 提示错误信息 - $data = ['msg' => '用户名或密码错误', 'val' => 0]; + // 获取服务器密码 + $ter = new \app\teacher\model\Teacher; + $userinfo = $ter::where('phone', $list['username']) + ->where('status', 1) + ->field('id, lastip, phone, ip, denglucishu, lasttime, thistime, password') + ->find(); + // 将本次信息上传到服务器上 + $userinfo->lastip = $userinfo->ip; + $userinfo->ip = request()->ip(); + $userinfo->denglucishu = ['inc', 1]; + $userinfo->lasttime = $userinfo->getData('thistime'); + $userinfo->thistime = time(); + $userinfo->save(); } - return $data; + return json($yz); + } + + + // 学生登录验证 + public function student() + { + // 清除cookie + cookie('userid', null); + cookie('username', null); + cookie('password', null); + // 清除session(当前作用域) + session(null); + + // 获取表单数据 + $list = request() + ->only([ + 'username' + ,'password' + ,'category' + ]); + + $validate = new \app\login\validate\Yanzheng; + $result = $validate->scene('admin')->check($list); + $msg = $validate->getError(); + if(!$result){ + return json(['msg' => $msg, 'val' => 0]); + } + + $yz = yz::student($list['username'], $list['password']); + + if($yz['val'] === 1) + { + // 获取服务器密码 + $stu = new \app\student\model\Student; + $userinfo = $stu::where('shenfenzhenghao', $list['username']) + ->where('status', 1) + ->field('id, lastip, shenfenzhenghao, ip, denglucishu, lasttime, thistime, password') + ->find(); + // 将本次信息上传到服务器上 + $userinfo->lastip = $userinfo->ip; + $userinfo->ip = request()->ip(); + $userinfo->denglucishu = ['inc', 1]; + $userinfo->lasttime = $userinfo->getData('thistime'); + $userinfo->thistime = time(); + $userinfo->save(); + } + + return json($yz); } @@ -121,7 +186,7 @@ class Index public function shangmaLog() { // 渲染模板 - return View::fetch(); + return $this->view->fetch(); } @@ -132,10 +197,10 @@ class Index $list['webtitle'] = config('shangma.webtitle'); $list['version'] = config('shangma.version'); - View::assign('list',$list); + $this->view->assign('list',$list); // 渲染输出 - return View::fetch(); + return $this->view->fetch(); } @@ -150,8 +215,8 @@ class Index ,'version' => config('shangma.version') ]; - View::assign('list',$list); - return View::fetch(); + $this->view->assign('list',$list); + return $this->view->fetch(); } } diff --git a/app/login/controller/Student.php b/app/login/controller/Student.php deleted file mode 100755 index e8322c29..00000000 --- a/app/login/controller/Student.php +++ /dev/null @@ -1,87 +0,0 @@ -only([ - 'username' - ,'password' - ,'category' - ]); - - $validate = new \app\login\validate\Yanzheng; - $result = $validate->scene('admin')->check($list); - $msg = $validate->getError(); - if(!$result){ - return json(['msg' => $msg, 'val' => 0]); - } - - $yz = $this->yz($list['username'], $list['password']); - - if($yz['val'] === 1) - { - // 获取服务器密码 - $stu = new \app\student\model\Student; - $userinfo = $stu::where('shenfenzhenghao', $list['username']) - ->where('status', 1) - ->field('id, lastip, shenfenzhenghao, ip, denglucishu, lasttime, thistime, password') - ->find(); - // 将本次信息上传到服务器上 - $userinfo->lastip = $userinfo->ip; - $userinfo->ip = request()->ip(); - $userinfo->denglucishu = ['inc', 1]; - $userinfo->lasttime = $userinfo->getData('thistime'); - $userinfo->thistime = time(); - $userinfo->save(); - } - - return json($yz); - } - - - // 获学生帐号密码信息 - public function yz($username, $password) - { - // 获取服务器密码 - $stu = new \app\student\model\Student; - $userinfo = $stu::where('shenfenzhenghao', $username) - ->where('status', 1) - ->field('id, lastip, shenfenzhenghao, ip, denglucishu, lasttime, thistime, password') - ->find(); - if ($userinfo == null) - { - // 验证结果; - $data = ['msg' => '学生帐号不存在或被禁用', 'val' => 0]; - return $data; - } - - // 验证用户名和密码 - $check = loginCheck($password, $userinfo->password); - - if ($check === true) - { - session('onlineCategory', 'student'); - session('user_id', $userinfo->id); - session('username', $username); - session('password', $password); - // 跳转到首页 - $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\studentSearchChengji\\index\\index']; - } else { - // 提示错误信息 - $data = ['msg' => '用户名或密码错误', 'val' => 0]; - } - - return $data; - } - -} diff --git a/app/login/controller/Teacher.php b/app/login/controller/Teacher.php deleted file mode 100755 index a3aa9eee..00000000 --- a/app/login/controller/Teacher.php +++ /dev/null @@ -1,91 +0,0 @@ -only([ - 'username' - ,'password' - ,'category' - ]); - - - $validate = new \app\login\validate\Yanzheng; - $result = $validate->scene('admin')->check($list); - $msg = $validate->getError(); - if(!$result){ - return json(['msg' => $msg, 'val' => 0]); - } - - $yz = $this->yz($list['username'], $list['password']); - - if($yz['val'] === 1) - { - // 获取服务器密码 - $ter = new \app\teacher\model\Teacher; - $userinfo = $ter::where('phone', $list['username']) - ->where('status', 1) - ->field('id, lastip, phone, ip, denglucishu, lasttime, thistime, password') - ->find(); - // 将本次信息上传到服务器上 - $userinfo->lastip = $userinfo->ip; - $userinfo->ip = request()->ip(); - $userinfo->denglucishu = ['inc', 1]; - $userinfo->lasttime = $userinfo->getData('thistime'); - $userinfo->thistime = time(); - $userinfo->save(); - } - - return json($yz); - } - - - // 获学生帐号密码信息 - public function yz($username, $password) - { - // 获取服务器密码 - $ter = new \app\teacher\model\Teacher; - $userinfo = $ter::where('phone', $username) - ->where('status', 1) - ->field('id, lastip, phone, ip, denglucishu, lasttime, thistime, password') - ->find(); - if ($userinfo == null) - { - // 验证结果; - $data = ['msg' => '教师帐号不存在或被禁用', 'val' => 0]; - return $data; - } - - // 验证用户名和密码 - $check = loginCheck($password, $userinfo->password); - - if ($check === true) - { - session('onlineCategory', 'teacher'); - session('user_id', $userinfo->id); - session('username', $username); - session('password', $password); - // 跳转到首页 - $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\teacherSearchChengji\\index\\index']; - } else { - // 提示错误信息 - $data = ['msg' => '用户名或密码错误', 'val' => 0]; - } - - return $data; - } - -} diff --git a/app/login/controller/YanZheng.php b/app/login/controller/YanZheng.php new file mode 100644 index 00000000..d85908cf --- /dev/null +++ b/app/login/controller/YanZheng.php @@ -0,0 +1,114 @@ +where('status', 1) + ->field('id, lastip, username, ip, denglucishu, lasttime, thistime, password') + ->find(); + if ($userinfo == null) + { + // 验证结果; + $data = ['msg' => '管理员帐号不存在或被禁用', 'val' => 0]; + return $data; + } + + // 验证用户名和密码 + $check = loginCheck($password, $userinfo->password); + + if ($check === true) + { + session('onlineCategory', 'admin'); + session('user_id', $userinfo->id); + session('username', $username); + session('password', $password); + // 跳转到首页 + $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'/']; + } else { + // 提示错误信息 + $data = ['msg' => '用户名或密码错误', 'val' => 0]; + } + + return $data; + } + + + // 获学生帐号密码信息 + public static function teacher($username, $password) + { + // 获取服务器密码 + $ter = new \app\teacher\model\Teacher; + $userinfo = $ter::where('phone', $username) + ->where('status', 1) + ->field('id, lastip, phone, ip, denglucishu, lasttime, thistime, password') + ->find(); + if ($userinfo == null) + { + // 验证结果; + $data = ['msg' => '教师帐号不存在或被禁用', 'val' => 0]; + return $data; + } + + // 验证用户名和密码 + $check = loginCheck($password, $userinfo->password); + + if ($check === true) + { + session('onlineCategory', 'teacher'); + session('user_id', $userinfo->id); + session('username', $username); + session('password', $password); + // 跳转到首页 + $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\teacherSearchChengji\\index\\index']; + } else { + // 提示错误信息 + $data = ['msg' => '用户名或密码错误', 'val' => 0]; + } + + return $data; + } + + + // 获学生帐号密码信息 + public static function student($username, $password) + { + // 获取服务器密码 + $stu = new \app\student\model\Student; + $userinfo = $stu::where('shenfenzhenghao', $username) + ->where('status', 1) + ->field('id, lastip, shenfenzhenghao, ip, denglucishu, lasttime, thistime, password') + ->find(); + if ($userinfo == null) + { + // 验证结果; + $data = ['msg' => '学生帐号不存在或被禁用', 'val' => 0]; + return $data; + } + + // 验证用户名和密码 + $check = loginCheck($password, $userinfo->password); + + if ($check === true) + { + session('onlineCategory', 'student'); + session('user_id', $userinfo->id); + session('username', $username); + session('password', $password); + // 跳转到首页 + $data = ['msg' => '验证成功', 'val' => 1, 'url' =>'\\studentSearchChengji\\index\\index']; + } else { + // 提示错误信息 + $data = ['msg' => '用户名或密码错误', 'val' => 0]; + } + + return $data; + } + +} diff --git a/app/login/route/login.php b/app/login/route/login.php index 685abb69..f6a40f93 100755 --- a/app/login/route/login.php +++ b/app/login/route/login.php @@ -14,18 +14,10 @@ use think\facade\Route; // 系统设置systembase Route::group('', function () { Route::rule('', 'Index/index', 'get'); - Route::rule('', 'Index/login', 'post'); + Route::rule('', 'Index/admin', 'post'); + Route::rule('teacher', 'Index/teacher', 'post'); + Route::rule('student', 'Index/student', 'post'); Route::rule('log', 'Index/shangmaLog', 'get'); # 配置更新 Route::rule('err', 'Index/myerror', 'get'); //错误页 Route::rule('weihu', 'Index/weihu', 'get'); //错误页 -}); - -// 学生查询成绩登录 -Route::group('student', function () { - Route::rule('', 'Student/login', 'post'); -}); - -// 学生查询成绩登录 -Route::group('teacher', function () { - Route::rule('', 'Teacher/login', 'post'); }); \ No newline at end of file diff --git a/app/login/view/index/index.html b/app/login/view/index/index.html index df1aa33f..5a65fea5 100755 --- a/app/login/view/index/index.html +++ b/app/login/view/index/index.html @@ -73,19 +73,19 @@ var url = '/login'; - form.on('radio(category)', function(data){ - switch(data.value){ - case 'admin': - url = '/login'; - break; - case 'teacher': - url = '/login/teacher'; - break; - case 'student': - url = '/login/student'; - break; - }; - }); + // form.on('radio(category)', function(data){ + // switch(data.value){ + // case 'admin': + // url = '/login'; + // break; + // case 'teacher': + // url = '/login/teacher'; + // break; + // case 'student': + // url = '/login/student'; + // break; + // }; + // }); //监听提交 diff --git a/app/login/view/index/shangma_log.html b/app/login/view/index/shangma_log.html index d1e62f85..546e018c 100755 --- a/app/login/view/index/shangma_log.html +++ b/app/login/view/index/shangma_log.html @@ -49,7 +49,7 @@

V1.3.8 2021-1-17

- 修改:超过算法、权限
+ 修改:超过算法、权限、登录验证、考试更多操作上移
修复已知错误:表格上传教师错误、phinx、登录页面、已录成绩……
优化:雷达图学科显示、成绩位置算法、部分统计表显示……
增加:学生帐号显示成绩或等级设置、统计项目
diff --git a/app/luru/controller/Index.php b/app/luru/controller/Index.php index f1b4d65d..e2e85421 100755 --- a/app/luru/controller/Index.php +++ b/app/luru/controller/Index.php @@ -5,7 +5,7 @@ declare (strict_types = 1); namespace app\luru\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\ToolBase; use app\chengji\model\Chengji; use app\teach\model\Subject; @@ -17,31 +17,8 @@ use app\kaoshi\model\KaoshiSet as ksset; use PhpOffice\PhpSpreadsheet\Spreadsheet; -class Index extends BaseController +class Index extends ToolBase { - protected $middleware = []; - protected $luruTeacherId = ''; - protected $online = ''; - - protected function initialize() - { - $this->online = session('onlineCategory'); - if($this->online == 'teacher') - { - $this->middleware = [ - 'online' - ,'login' - ]; - }else{ - $this->middleware = [ - 'online' - ,'login' - ,'auth' - ]; - } - $this->luruTeacherId = session('user_id'); - } - // 成绩列表 public function index() { diff --git a/app/middleware/Login.php b/app/middleware/Login.php index 9d73a5ac..6e6ea6d7 100755 --- a/app/middleware/Login.php +++ b/app/middleware/Login.php @@ -3,6 +3,8 @@ declare (strict_types = 1); namespace app\middleware; +use \app\login\controller\YanZheng as yz; + class Login { /** @@ -15,24 +17,22 @@ class Login public function handle($request, \Closure $next) { $category = session('onlineCategory'); + $ya = 0; switch ($category) { case 'admin': - $yz = new \app\login\controller\Index; - $yz = $yz->yz(session('username'), session('password')); + $yz = yz::admin(session('username'), session('password')); break; case 'teacher': - $yz = new \app\login\controller\Teacher; - $yz = $yz->yz(session('username'), session('password')); + $yz = yz::teacher(session('username'), session('password')); break; case 'student': - $yz = new \app\login\controller\Student; - $yz = $yz->yz(session('username'), session('password')); + $yz = yz::student(session('username'), session('password')); break; default: \app\facade\OnLine::jump('/login', '请选择用户角色'); break; } - if($yz['val'] == 0) + if($yz['val'] === 0) { \app\facade\OnLine::jump('/login', $yz['msg']); } diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 6e594d53..df94d5a8 100755 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -76,7 +76,7 @@ class Rule extends Seeder ['id' => 103 ,'title' => '已录列表' ,'name' => 'luru/index/index' - ,'paixu' => 2 + ,'paixu' => 4 ,'ismenu' => 1 ,'pid' => 1 ,'url' => '/luru/index/index' @@ -95,13 +95,13 @@ class Rule extends Seeder ,'pid' => 103 ], ['id' => 105 - ,'title' => '已录统计' - ,'name' => 'chengji/tongji/yilucnt' - ,'paixu' => 5 - ,'ismenu' => 1 - ,'pid' => 1 - ,'url' => '/chengji/tongji/yilucnt' - ], + ,'title' => '已录统计' + ,'name' => 'chengji/tongji/yilucnt' + ,'paixu' => 5 + ,'ismenu' => 1 + ,'pid' => 1 + ,'url' => '/chengji/tongji/yilucnt' + ], // 占位 ['id' => 10501 ,'title' => '占位' @@ -118,12 +118,27 @@ class Rule extends Seeder ,'url' => '/kaohao/excel/biaoqian' ], // 占位 - ['id' => 10561 + ['id' => 10601 ,'title' => '占位' ,'name' => 'biaoqian1' ,'paixu' => 1 ,'pid' => 106 ], + ['id' => 107 + ,'title' => '在线录入' + ,'name' => 'luru/index/online' + ,'paixu' => 3 + ,'ismenu' => 1 + ,'pid' => 1 + ,'url' => '/luru/index/online' + ], + // 占位 + ['id' => 10701 + ,'title' => '占位' + ,'name' => 'zaixian1' + ,'paixu' => 1 + ,'pid' => 106 + ], /*====================================================================== * 考试管理 @@ -240,12 +255,12 @@ class Rule extends Seeder ,'paixu' => 6 ,'pid' => 3020101 ], - ['id' => 302010108 - ,'title' => '统计得分率' - ,'name' => 'chengji/tongji/editdefenlv' - ,'paixu' => 4 - ,'pid' => 3020101 - ], + // ['id' => 302010108 + // ,'title' => '统计得分率' + // ,'name' => 'chengji/tongji/editdefenlv' + // ,'paixu' => 4 + // ,'pid' => 3020101 + // ], ['id' => 302010109 ,'title' => '更新得分率' ,'name' => 'chengji/tongji/updatedefenLv'

{$i} {$vo.title} - + 等待统计