diff --git a/app/BaseModel.php b/app/BaseModel.php index 4de5f86b..0f722bee 100644 --- a/app/BaseModel.php +++ b/app/BaseModel.php @@ -9,7 +9,6 @@ use think\model\concern\SoftDelete; class BaseModel extends Model { - // 开启全局自动时间戳 protected $autoWriteTimestamp = true; diff --git a/app/admin/controller/AuthGroup.php b/app/admin/controller/AuthGroup.php index 8d3b0822..8349c60f 100644 --- a/app/admin/controller/AuthGroup.php +++ b/app/admin/controller/AuthGroup.php @@ -3,12 +3,12 @@ namespace app\admin\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用角色数据模型类 use app\admin\model\AuthGroup as AG; -class AuthGroup extends BaseController +class AuthGroup extends AdminBase { // 角色列表 public function index() diff --git a/app/admin/controller/AuthGroupAccess.php b/app/admin/controller/AuthGroupAccess.php index 3abe5b54..8d7ef9d2 100644 --- a/app/admin/controller/AuthGroupAccess.php +++ b/app/admin/controller/AuthGroupAccess.php @@ -3,12 +3,12 @@ namespace app\admin\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用用户权限关联数据模型 use app\admin\model\AuthGroupAccess as AGA; -class AuthGroupAccess extends BaseController +class AuthGroupAccess extends AdminBase { // 用户列表 public function index($group_id) @@ -94,7 +94,7 @@ class AuthGroupAccess extends BaseController $msg = $validate->getError(); if(!$result){ continue; - } + } // 查询数据是否存在 $tempObj = $aga ->where('uid', $value) diff --git a/app/admin/controller/AuthRule.php b/app/admin/controller/AuthRule.php index a7499ded..36828193 100644 --- a/app/admin/controller/AuthRule.php +++ b/app/admin/controller/AuthRule.php @@ -3,11 +3,11 @@ namespace app\admin\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用权限数据模型类 use app\admin\model\AuthRule as AR; -class AuthRule extends BaseController +class AuthRule extends AdminBase { // 显示权限列表 public function index() diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 21773e4d..875b049d 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -3,13 +3,13 @@ namespace app\admin\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用用户数据模型 use app\admin\model\Admin as AD; // 引用加密类 use WhiteHat101\Crypt\APR1_MD5; -class Index extends BaseController +class Index extends AdminBase { // 管理员列表 public function index() diff --git a/app/admin/model/Admin.php b/app/admin/model/Admin.php index bd955aad..ba8f7e4a 100644 --- a/app/admin/model/Admin.php +++ b/app/admin/model/Admin.php @@ -28,9 +28,6 @@ class Admin extends BaseModel $query->field('id, jiancheng'); } ,'glGroup' - // ,'glGroup' => function($query){ - // $query->where('status', 1)->field('title, rules, miaoshu'); - // } ]) ->hidden([ 'password' diff --git a/app/base/controller/AdminBase.php b/app/base/controller/AdminBase.php index da5e4fe3..53e00cb8 100644 --- a/app/base/controller/AdminBase.php +++ b/app/base/controller/AdminBase.php @@ -4,16 +4,19 @@ namespace app\base\controller; // 引用控制器基类 use app\BaseController; + /** * 控制器基础类 */ -abstract class AdminBase extends BaseController +abstract class AdminBase extends BaseController { /** * 控制器中间件 * @var array */ protected $middleware = [ - 'login' + 'online' + ,'login' + ,'auth' ]; } diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index 7b1dd99f..5f4377e5 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -3,11 +3,11 @@ namespace app\chengji\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用成绩统计数据模型 use app\chengji\model\TongjiBj as BTJ; -class Bjtongji extends BaseController +class Bjtongji extends AdminBase { // 班级成绩汇总 public function biaoge($kaoshi_id) @@ -438,7 +438,7 @@ class Bjtongji extends BaseController $data['xAxis'][] = (string)$value['low'].'~'.$value['high']; $data['series'][] = $value['cnt']; } - + return json($data); } diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php index 04606b45..dc73d1bd 100644 --- a/app/chengji/controller/Index.php +++ b/app/chengji/controller/Index.php @@ -1,12 +1,12 @@ array() ,'searchval' ], 'POST'); - + // 获取参与考试的班级 if (count($src['banji_id']) == 0) { $khSrc = new \app\kaohao\model\SearchMore; diff --git a/app/chengji/controller/Luru.php b/app/chengji/controller/Luru.php index 2ae193c7..42533c2c 100644 --- a/app/chengji/controller/Luru.php +++ b/app/chengji/controller/Luru.php @@ -2,12 +2,12 @@ namespace app\chengji\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; use app\chengji\model\Chengji; use app\teach\model\Subject; -class Luru extends BaseController +class Luru extends AdminBase { // 成绩列表 public function index() @@ -70,7 +70,7 @@ class Luru extends BaseController // 渲染 return $this->view->fetch(); } - + // 保存使用二维码录入的成绩 public function malusave() @@ -197,8 +197,8 @@ class Luru extends BaseController } $cjone->defen = $list['newdefen']; - $cjone->defenlv = $list['newdefen'] / $manfen * 100; - $cjone->user_id = session('admin.userid'); + $cjone->defenlv = $list['newdefen'] / $manfen * 100; + $cjone->user_id = session('admin.userid'); $data = $cjone->save(); } else { $data = [ diff --git a/app/chengji/controller/Njtongji.php b/app/chengji/controller/Njtongji.php index 23f51e54..1fba7ed3 100644 --- a/app/chengji/controller/Njtongji.php +++ b/app/chengji/controller/Njtongji.php @@ -3,11 +3,11 @@ namespace app\chengji\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用成绩统计数据模型 use app\chengji\model\TongjiNj as NTJ; -class Njtongji extends BaseController +class Njtongji extends AdminBase { // 获取各学校、各年级考试成绩 public function biaoge($kaoshi_id) diff --git a/app/chengji/controller/Schtongji.php b/app/chengji/controller/Schtongji.php index 6926a825..19f2ea07 100644 --- a/app/chengji/controller/Schtongji.php +++ b/app/chengji/controller/Schtongji.php @@ -1,11 +1,11 @@ 'update_time', - 'order'=>'desc', - 'kaoshi_id'=>'0', - 'banji_id'=>array(), - 'subject_id'=>'', - 'searchval'=>'', - 'user_id'=>session('userid'), + 'field'=>'update_time' + ,'order'=>'desc' + ,'kaoshi_id'=>'0' + ,'banji_id'=>array() + ,'subject_id'=>'' + ,'searchval'=>'' + ,'user_id'=>session('userid') ); $src = array_cover( $srcfrom , $src ) ; $src['banji_id'] = strToarray($src['banji_id']); diff --git a/app/chengji/model/TongjiBj.php b/app/chengji/model/TongjiBj.php index 71940bee..fe4913da 100644 --- a/app/chengji/model/TongjiBj.php +++ b/app/chengji/model/TongjiBj.php @@ -212,6 +212,8 @@ class TongjiBj extends KaoshiBase $src = array( 'kaoshi_id' => '' ,'banji_id' => array() + ,'page' => 0 + ,'limit' => 10 ); $src = array_cover($srcfrom, $src); $src['banji_id'] = strToarray($src['banji_id']); @@ -224,6 +226,9 @@ class TongjiBj extends KaoshiBase $tongjiJg = $this ->where('kaoshi_id', $src['kaoshi_id']) ->where('banji_id', 'in', $src['banji_id']) + ->when($src['page'] > 0, function ($query) use($src) { + $query->limit($src['limit'])->page($src['page']); + }) ->field('banji_id, kaoshi_id') ->with([ 'bjBanji'=>function($query){ diff --git a/app/common.php b/app/common.php index 8a5268e8..244fa152 100644 --- a/app/common.php +++ b/app/common.php @@ -17,7 +17,6 @@ // 查询类别 $category = new \app\system\model\Category; $list = $category->srcChild($p_id); - // 返回类别列表 return $list; } @@ -36,7 +35,7 @@ function banJiNamelist() { // 实例化年级控制器 - $bj = new \app\tools\controller\Banji; + $bj = new \app\teach\model\Banji; $njList= $bj->banJiNamelist(); return $njList; } @@ -46,7 +45,7 @@ // EXCEL表格列名 function excelColumnName() { - $excel = new \app\tools\controller\Excel; + $excel = new \app\tools\controller\File; $data = $excel->excelColumnName(); return $data; } @@ -85,10 +84,9 @@ // 整理教师名 function teacherNames($list = array()) { - if(count($list) == 0 ) - { - return ''; - } + if (count($list) == 0) { + return ''; + } $names = ''; foreach ($list as $key => $value) { @@ -104,15 +102,6 @@ } - // 给数组按多条件排序 - function sortArrByManyField(){ - $args = func_get_args(); - $tools = new \app\tools\controller\Index; - $arr = $tools->sortArrByManyField($args); - return $arr; - } - - /* * 根据键值,用数组2的值替换数组1的值 * $cover 覆盖数组,存储新值的数组 @@ -121,25 +110,11 @@ */ function array_cover($cover = array(), $covered = array()) { - $tools = new \app\tools\controller\Index; - $arr = $tools->array_cover($cover, $covered); + $arr = \app\facade\Tools::array_cover($cover, $covered); return $arr; } - /** - * 获取参加考试的学科 - * 返回 $data - * */ - function subjectList() - { - $sbj = new \app\teach\model\Subject; - $data = $sbj->kaoshi(); - - return $data; - } - - /** * 把request到的参数转换成数组,并删除空值 * @@ -149,8 +124,7 @@ */ function strToArray($str) { - $tools = new \app\tools\controller\Index; - $data = $tools->strToArray($str); + $data = \app\facade\Tools::strToArray($str); return $data; } @@ -163,8 +137,7 @@ */ function reSetObject($obj, $srcfrom) { - $tools = new \app\tools\controller\Index; - $data = $tools->reSetObject($obj, $srcfrom); + $data = \app\facade\Tools::reSetObject($obj, $srcfrom); return $data; } @@ -177,10 +150,6 @@ */ function reSetArray($arr, $srcfrom) { - $tools = new \app\tools\controller\Index; - $data = $tools->reSetArray($arr, $srcfrom); + $data = \app\facade\Tools::reSetArray($arr, $srcfrom); return $data; } - - - diff --git a/app/facade/Tools.php b/app/facade/Tools.php new file mode 100644 index 00000000..eee57d61 --- /dev/null +++ b/app/facade/Tools.php @@ -0,0 +1,12 @@ + 0) { - $data = sortArrByManyField($data, 'paixu', SORT_ASC); + $data = \app\facade\Tools::sortArrByManyField($data, 'paixu', SORT_ASC); } return $data; @@ -521,12 +521,11 @@ class SearchMore extends KaoshiBase 'schPaixu'=>$value->cjSchool->paixu, 'banTitle'=>$value->banTitle, 'banjiTitle'=>$value->banjiTitle, - // 'numTitle'=>$value->numTitle, ]; } if(count($data) > 0) { - $data = sortArrByManyField($data, 'schPaixu', SORT_ASC, 'paixu', SORT_ASC); + $data = \app\facade\Tools::sortArrByManyField($data, 'schPaixu', SORT_ASC, 'paixu', SORT_ASC); } return $data; diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index 2ee80465..752ac519 100644 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -3,14 +3,14 @@ namespace app\kaoshi\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用考试数据模型类 use app\kaoshi\model\Kaoshi as KS; use app\middleware\KaoshiStatus; -class Index extends BaseController +class Index extends AdminBase { // 显示考试列表 public function index() @@ -238,90 +238,4 @@ class Index extends BaseController // 渲染 return $this->view->fetch(); } - - - // 根据考试ID和年级获取参加考试学校 - public function cySchool() - { - // 获取变量 - $src['kaoshi_id'] = input('post.kaoshi_id'); - $src['ruxuenian'] = input('post.ruxuenian'); - - $khSrc = new \app\kaohao\model\Search; - $school = $khSrc->cySchool($src); - $cnt = count($school); - - // 重组返回内容 - $data = [ - 'count'=>$cnt // 符合条件的总数据量 - ,'data'=>$school //获取到的数据结果 - ]; - - return json($data); - } - - - // 根据考试ID和年级获取参加考试年级 - public function cyNianji() - { - // 获取变量 - $kaoshi_id = input('post.kaoshi_id'); - $ksset = new \app\kaoshi\model\KaoshiSet; - $nianji = $ksset->srcNianji($kaoshi_id); - $cnt = count($nianji); - - // 重组返回内容 - $data = [ - 'count'=>$cnt, // 符合条件的总数据量 - 'data'=>$nianji, //获取到的数据结果 - ]; - - return json($data); - } - - - // 根据考试ID和年级获取参加考试班级 - public function cyBanji() - { - // 获取参数 - $src = $this->request - ->only([ - 'school_id' => '' - ,'ruxuenian' => '' - ,'kaoshi_id' => '1' - ], 'POST'); - - $khSrc = new \app\kaohao\model\SearchMore; - $bj = $khSrc->cyBanji($src); - $cnt = count($bj); - - // 重组返回内容 - $data = [ - 'count'=>$cnt, // 符合条件的总数据量 - 'data'=>$bj, //获取到的数据结果 - ]; - - return json($data); - } - - - // 根据考试ID和年级获取参加考试学科 - public function cySubject() - { - // 获取变量 - $kaoshi_id = input('post.kaoshi_id'); - $nianji = input('post.ruxuenian'); - - $ksset = new \app\kaoshi\model\KaoshiSet; - $sbj = $ksset->srcSubject($kaoshi_id, '', $nianji); - $cnt = count($sbj); - - // 重组返回内容 - $data = [ - 'count'=>$cnt, // 符合条件的总数据量 - 'data'=>$sbj, //获取到的数据结果 - ]; - - return json($data); - } } diff --git a/app/kaoshi/controller/KaoshiSet.php b/app/kaoshi/controller/KaoshiSet.php index e17bf312..a966cb51 100644 --- a/app/kaoshi/controller/KaoshiSet.php +++ b/app/kaoshi/controller/KaoshiSet.php @@ -2,7 +2,7 @@ namespace app\kaoshi\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; // 引用考号数据模型类 use app\kaoshi\model\KaoshiSet as ksset; @@ -10,7 +10,7 @@ use app\kaoshi\model\KaoshiSet as ksset; use app\kaoshi\controller\Kaoshi as kscon; -class KaoshiSet extends BaseController +class KaoshiSet extends AdminBase { /** * 显示资源列表 @@ -30,7 +30,7 @@ class KaoshiSet extends BaseController $ksset = new ksset; $src['kaoshi_id'] = $kaoshi_id; $list['subject'] = $ksset->srcSubject($src); - $nj = $ksset->srcNianji($kaoshi_id); + $nj = $ksset->srcGrade($kaoshi_id); $kaoshi = new \app\kaoshi\model\Kaoshi; $list['sj'] = $kaoshi::where('id', $kaoshi_id)->value('bfdate'); @@ -86,9 +86,9 @@ class KaoshiSet extends BaseController ); // 获取参加考试年级 - $ks = new \app\kaoshi\model\Kaoshi; - $ksend = $ks->where('id', $kaoshi_id)->value('enddate'); - $list['set']['nianji'] = nianJiNameList($ksend); + $ksset = new ksset(); + $nianJiNameList = $ksset->srcGradeByID($kaoshi_id); + $list['set']['nianji'] = $nianJiNameList; // 模板赋值 $this->view->assign('list', $list); @@ -182,7 +182,7 @@ class KaoshiSet extends BaseController $query->field('id, title, jiancheng'); } ]) - ->find()->toArray(); + ->find(); // 设置页面标题 $list['set'] = array( @@ -211,7 +211,7 @@ class KaoshiSet extends BaseController // 获取表单数据 $list = request()->only([ 'id' - ,'kaoshi' + ,'kaoshi_id' ,'manfen' ,'youxiu' ,'jige' @@ -225,7 +225,7 @@ class KaoshiSet extends BaseController if(!$result){ return json(['msg' => $msg, 'val' => 0]);; } - event('kslu', $list['kaoshi']); + event('kslu', $list['kaoshi_id']); // 更新数据 $ksset = new ksset(); @@ -288,5 +288,5 @@ class KaoshiSet extends BaseController // 返回信息 return json($data); } - + } diff --git a/app/kaoshi/controller/TongjiLog.php b/app/kaoshi/controller/TongjiLog.php index f47bbd44..dbf419b2 100644 --- a/app/kaoshi/controller/TongjiLog.php +++ b/app/kaoshi/controller/TongjiLog.php @@ -4,9 +4,9 @@ declare (strict_types = 1); namespace app\Kaoshi\controller; // 引用控制器基类 -use app\BaseController; +use app\base\controller\AdminBase; -class TongjiLog extends BaseController +class TongjiLog extends AdminBase { /** * 显示资源列表 diff --git a/app/kaoshi/model/Kaoshi.php b/app/kaoshi/model/Kaoshi.php index 08880778..e913e802 100644 --- a/app/kaoshi/model/Kaoshi.php +++ b/app/kaoshi/model/Kaoshi.php @@ -64,15 +64,15 @@ class Kaoshi extends BaseModel } - // // 考试参加考试的学校、学科、年级、班级 - // public function kaoshiInfo($id = 0) - // { - // // 获取参考年级 - // $kaoshiList = $this->where('id', $id) - // ->field('id, title, status, luru') - // ->find(); - // return $kaoshiList; - // } + // 本次考试信息,包含ID、标题、状态、是否允许编辑成绩 + public function kaoshiInfo($id = 0) + { + // 获取参考年级 + $kaoshiList = $this->where('id', $id) + ->field('id, title, status, luru') + ->find(); + return $kaoshiList; + } // 开始时间修改器 @@ -116,14 +116,20 @@ class Kaoshi extends BaseModel $subject = $ksset->srcSubject($src); // 重新整理数据 $str = ''; - foreach ($subject as $key => $value) { - if($key == 0) - { - $str = $value['jiancheng']; - }else{ - $str = $str . '、' . $value['jiancheng']; + if(isset($subject)) + { + $i = 0; + foreach ($subject as $key => $value) { + if($i == 0) + { + $str = $value['jiancheng']; + }else{ + $str = $str . '、' . $value['jiancheng']; + } + $i = $i + 1; } } + return $str; } @@ -133,16 +139,21 @@ class Kaoshi extends BaseModel { // 查询参考年级 $ksset = new \app\kaoshi\model\KaoshiSet; - $data = $ksset->srcNianji($this->getAttr('id')); + $data = $ksset->srcGrade($this->getAttr('id')); // 重新整理数据 $str = ''; - foreach ($data as $key => $value) { - $temp = substr($value['nianjiname'], 0, 3); - if($key == 0) - { - $str = $temp; - }else{ - $str = $str . '、' . $temp; + if(isset($data)) + { + $i = 0; + foreach ($data as $key => $value) { + $temp = substr($value['nianjiname'], 0, 3); + if($i == 0) + { + $str = $temp; + }else{ + $str = $str . '、' . $temp; + } + $i = $i + 1; } } return $str; @@ -184,4 +195,5 @@ class Kaoshi extends BaseModel } + } diff --git a/app/kaoshi/model/KaoshiSet.php b/app/kaoshi/model/KaoshiSet.php index 2892df9c..4679bf71 100644 --- a/app/kaoshi/model/KaoshiSet.php +++ b/app/kaoshi/model/KaoshiSet.php @@ -66,6 +66,7 @@ class KaoshiSet extends BaseModel $src['subject_id'] = strToarray($src['subject_id']); $sbjList = $this->where('kaoshi_id', $src['kaoshi_id']) + ->where('status', 1) ->when(count($src['subject_id']) > 0, function ($query) use ($src) { $query->where('subject_id', 'in', $src['subject_id']); }) @@ -82,7 +83,6 @@ class KaoshiSet extends BaseModel $query->field('id, title, jiancheng, paixu, lieming'); } ]) - ->where('status', 1) ->select(); // 重新整理学科信息 @@ -103,10 +103,11 @@ class KaoshiSet extends BaseModel ]; } - // 按条件排序 - if(count($data) > 0){ - $data = sortArrByManyField($data, 'paixu', SORT_ASC); + if(count($data) > 0) + { + $data = \app\facade\Tools::sortArrByManyField($data, 'paixu', SORT_ASC); } + return $data; } @@ -137,10 +138,20 @@ class KaoshiSet extends BaseModel } // 按条件排序 if(count($data) > 0){ - $data = sortArrByManyField($data, 'nianji', SORT_ASC); + $data = \app\facade\Tools::sortArrByManyField($data, 'nianji', SORT_ASC); } return $data; } + // 通过考试ID生成可以参加考试年级 + public function srcGradeByID($kaoshi_id) + { + $ks = new \app\kaoshi\model\Kaoshi; + $time = $ks->where('id', $kaoshi_id)->field('bfdate, enddate')->find(); + $bj = \app\facade\Tools::gradeName('str', $time->getData('enddate')); + return $bj; + } + + } diff --git a/app/kaoshi/validate/KaoshiSetEdit.php b/app/kaoshi/validate/KaoshiSetEdit.php index f8103ab9..46950619 100644 --- a/app/kaoshi/validate/KaoshiSetEdit.php +++ b/app/kaoshi/validate/KaoshiSetEdit.php @@ -14,7 +14,8 @@ class KaoshiSetEdit extends Validate * @var */ protected $rule = [ - 'kaoshi|考试ID' => 'require|integer', + 'id|ID' => 'require|integer', + 'kaoshi_id|考试ID' => 'require|integer', 'manfen|满分' => 'require|number', 'youxiu|优秀' => 'require|number', 'jige|及格' => 'require|number', @@ -30,6 +31,6 @@ class KaoshiSetEdit extends Validate protected $message = []; protected $scene = [ - 'edit' => ['id','kaoshi','manfen','youxiu','jige'], + 'edit' => ['id','kaoshi_id','manfen','youxiu','jige'], ]; } diff --git a/app/kaoshi/validate/Kaoshiset.php b/app/kaoshi/validate/Kaoshiset.php index 59d75ea0..1c25673b 100644 --- a/app/kaoshi/validate/Kaoshiset.php +++ b/app/kaoshi/validate/Kaoshiset.php @@ -34,6 +34,5 @@ class Kaoshiset extends Validate protected $scene = [ 'create' => ['kaoshi_id', 'nianji','nianjiname', 'subject_id', 'manfen', 'youxiu', 'jige'], - 'edit' => ['id', 'kaoshi_id', 'nianji','nianjiname', 'subject_id', 'manfen', 'youxiu', 'jige'], ]; } diff --git a/app/kaoshi/view/index/create.html b/app/kaoshi/view/index/create.html index 501a41a3..9c01fdf8 100644 --- a/app/kaoshi/view/index/create.html +++ b/app/kaoshi/view/index/create.html @@ -59,7 +59,7 @@