From 5f0df9336889546d16974c21282cb9cbe424db9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=BF=E8=B0=88?= Date: Wed, 4 Aug 2021 16:12:11 +0800 Subject: [PATCH] 0 --- app/admin/controller/AdminInfo.php | 6 +-- app/admin/controller/AuthGroup.php | 6 +-- app/admin/controller/AuthGroupAccess.php | 2 +- app/admin/controller/AuthRule.php | 2 +- app/admin/controller/Index.php | 6 +-- app/admin/model/Admin.php | 17 ++++---- app/admin/model/AuthGroup.php | 4 +- app/admin/model/AuthGroupAccess.php | 4 +- app/admin/model/AuthRule.php | 4 +- app/system/controller/School.php | 17 +++++--- app/system/model/School.php | 52 ++++++++++++++++++++---- 11 files changed, 78 insertions(+), 42 deletions(-) diff --git a/app/admin/controller/AdminInfo.php b/app/admin/controller/AdminInfo.php index f24a9672..d7c3bdd1 100644 --- a/app/admin/controller/AdminInfo.php +++ b/app/admin/controller/AdminInfo.php @@ -136,7 +136,7 @@ class AdminInfo extends AdminBase ,'hjshijian' ,'update_time' ]); - $src['cnt'] = true; + $src['all'] = true; $cnt = $rongyu->srcTeacherRongyu($src['teacher_id'])->count(); $data = reset_data($data, $cnt); return json($data); @@ -159,7 +159,7 @@ class AdminInfo extends AdminBase // 查询数据 $keti = new \app\keti\model\KetiInfo; $data = $keti->srcTeacherKeti($src['teacher_id']); - $src['cnt'] = true; + $src['all'] = true; $cnt = $keti->srcTeacherKeti($src['teacher_id'])->count(); $data = reset_data($data, $cnt); @@ -183,7 +183,7 @@ class AdminInfo extends AdminBase // 查询数据 $bzr = new \app\teach\model\BanZhuRen; $data = $bzr->srcTeacher($src); - $src['cnt'] = true; + $src['all'] = true; $cnt = $bzr->srcTeacher($src)->count(); $data = reSetObject($data, $cnt); diff --git a/app/admin/controller/AuthGroup.php b/app/admin/controller/AuthGroup.php index c5e129d0..ec04070f 100755 --- a/app/admin/controller/AuthGroup.php +++ b/app/admin/controller/AuthGroup.php @@ -42,7 +42,7 @@ class AuthGroup extends AdminBase // 根据数据查询信息 $ag = new AG; $data = $ag->search($src); - $src['cnt'] = true; + $src['all'] = true; $cnt = $ag->search($src)->count(); $data = reset_data($data, $cnt); @@ -64,7 +64,7 @@ class AuthGroup extends AdminBase $rule = new \app\admin\model\AuthRule; $src = [ 'status' => 1 - ,'cnt' => true + ,'all' => true ]; $ruleList = $rule->search($src); $ruleSelect = array(); @@ -124,7 +124,7 @@ class AuthGroup extends AdminBase $rule = new \app\admin\model\AuthRule; $src = [ 'status' => 1 - ,'cnt' => true + ,'all' => true ]; $ruleList = $rule->search($src); $aglist = AG::where('id', $id) diff --git a/app/admin/controller/AuthGroupAccess.php b/app/admin/controller/AuthGroupAccess.php index 4497ef74..532c02df 100755 --- a/app/admin/controller/AuthGroupAccess.php +++ b/app/admin/controller/AuthGroupAccess.php @@ -45,7 +45,7 @@ class AuthGroupAccess extends AdminBase // 根据数据查询信息 $aga = new AGA; $data = $aga->search($src); - $src['cnt'] = true; + $src['all'] = true; $cnt = $aga->search($src)->count(); $data = reset_data($data, $cnt); diff --git a/app/admin/controller/AuthRule.php b/app/admin/controller/AuthRule.php index b64929d6..02914b2e 100755 --- a/app/admin/controller/AuthRule.php +++ b/app/admin/controller/AuthRule.php @@ -43,7 +43,7 @@ class AuthRule extends AdminBase // 根据条件查询数据 $ar = new AR; $data = $ar->search($src); - $src['cnt'] = true; + $src['all'] = true; $cnt = $ar->search($src)->count(); $data = reset_data($data, $cnt); diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 06ac4911..16cd4506 100755 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -59,7 +59,7 @@ class Index extends AdminBase ,'status' ,'update_time' ]); - $src['cnt'] = true; + $src['all'] = true; $cnt = $ad->search($src)->count(); $data = reset_data($data, $cnt); @@ -219,7 +219,6 @@ class Index extends AdminBase // 整理数据 $id = request()->delete('id'); $id = explode(',', $id); - // 启动事务 \think\facade\Db::startTrans(); @@ -349,7 +348,6 @@ class Index extends AdminBase ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false ], 'POST'); $ad = new AD(); @@ -367,7 +365,7 @@ class Index extends AdminBase ,'id' => $value->id ]; } - $src['cnt'] = true; + $src['all'] = true; $cnt = $ad->strSrcTeachers($src)->count(); $data = reset_data($data, $cnt); diff --git a/app/admin/model/Admin.php b/app/admin/model/Admin.php index eec2eac9..97a9bbbe 100755 --- a/app/admin/model/Admin.php +++ b/app/admin/model/Admin.php @@ -7,7 +7,6 @@ use app\BaseModel; class Admin extends BaseModel { - // 设置字段信息 protected $schema = [ 'xingming' => 'varchar' @@ -52,7 +51,7 @@ class Admin extends BaseModel ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false + ,'all' => false ]; $src = array_cover($srcfrom, $src); @@ -69,7 +68,7 @@ class Admin extends BaseModel } ,'glGroup' ]) - ->when($src['cnt'] == false, function ($query) use($src) { + ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']) ->order([$src['field'] => $src['order']]); @@ -146,7 +145,7 @@ class Admin extends BaseModel ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false + ,'all' => false ]; $src = array_cover($srcfrom, $src); $src['searchval'] = trim($src['searchval']); @@ -172,7 +171,7 @@ class Admin extends BaseModel } ] ) - ->when($src['cnt'] == false, function ($query) use($src) { + ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']) ->order([$src['field'] => $src['order']]); @@ -342,28 +341,28 @@ class Admin extends BaseModel // 职务关联模型 public function adZhiwu() { - return $this->belongsTo('\app\system\model\Category', 'zhiwu_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'zhiwu_id', 'id'); } // 职称关联模型 public function adZhicheng() { - return $this->belongsTo('\app\system\model\Category', 'zhicheng_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'zhicheng_id', 'id'); } // 学历关联模型 public function adXueli() { - return $this->belongsTo('\app\system\model\Category', 'xueli_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'xueli_id', 'id'); } // 学科关联模型 public function adSubject() { - return $this->belongsTo('\app\teach\model\Subject', 'subject_id', 'id'); + return $this->belongsTo(\app\teach\model\Subject::class, 'subject_id', 'id'); } diff --git a/app/admin/model/AuthGroup.php b/app/admin/model/AuthGroup.php index a093638c..58d61955 100755 --- a/app/admin/model/AuthGroup.php +++ b/app/admin/model/AuthGroup.php @@ -31,7 +31,7 @@ class AuthGroup extends BaseModel ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false + ,'all' => false ]; $src = array_cover($srcfrom, $src); @@ -40,7 +40,7 @@ class AuthGroup extends BaseModel ->when(strlen($src['searchval']) > 0, function($query) use($src){ $query->where('title', 'like', '%' . $src['searchval'] . '%'); }) - ->when($src['cnt'] == true, function ($query) { + ->when($src['all'] == true, function ($query) { $query->field('id'); }) ->select(); diff --git a/app/admin/model/AuthGroupAccess.php b/app/admin/model/AuthGroupAccess.php index 35f8754d..aaaebce0 100755 --- a/app/admin/model/AuthGroupAccess.php +++ b/app/admin/model/AuthGroupAccess.php @@ -33,7 +33,7 @@ class AuthGroupAccess extends Pivot ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false + ,'all' => false ]; // 用新值替换初始值 @@ -74,7 +74,7 @@ class AuthGroupAccess extends Pivot ]); } ]) - ->when($src['cnt'] == false, function ($query) use($src) { + ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']) ->order([$src['field'] => $src['order']]); diff --git a/app/admin/model/AuthRule.php b/app/admin/model/AuthRule.php index ef594914..d0b54038 100755 --- a/app/admin/model/AuthRule.php +++ b/app/admin/model/AuthRule.php @@ -37,7 +37,7 @@ class AuthRule extends BaseModel ,'limit' => 10 ,'field' => 'id' ,'order' => 'desc' - ,'cnt' => false + ,'all' => false ]; $src = array_cover($srcfrom, $src); @@ -55,7 +55,7 @@ class AuthRule extends BaseModel } ]) ->field('id, name, title, condition, paixu, ismenu, url, pid, type, status') - ->when($src['cnt'] == false, function ($query) use($src) { + ->when($src['all'] == false, function ($query) use($src) { $query ->page($src['page'], $src['limit']) ->order([$src['field'] => $src['order']]); diff --git a/app/system/controller/School.php b/app/system/controller/School.php index 28dcf9df..b96fa459 100755 --- a/app/system/controller/School.php +++ b/app/system/controller/School.php @@ -61,7 +61,9 @@ class School extends AdminBase ,'dwJibie'=>['title'] ,'update_time' ]); - $data = reSetObject($data, $src); + $src['all'] = true; + $cnt = $sch->search($src)->count(); + $data = reset_data($data, $cnt); return json($data); } @@ -246,8 +248,10 @@ class School extends AdminBase $src = request()->only([ 'low' => '班级' ,'high' => '其它级' - ,'order' => 'asc' - ,'limit' => 100 + ,'page' => 1 + ,'limit' => 10 + ,'field' => 'id' + ,'order' => 'desc' ], 'post'); // 实例化单位模型 @@ -258,7 +262,7 @@ class School extends AdminBase ,'title' ,'jiancheng' ]); - $src['cnt'] = true; + $src['all'] = true; $cnt = $sch->srcJibie($src)->count(); $data = reset_data($data, $cnt); @@ -279,8 +283,9 @@ class School extends AdminBase ], 'post'); // 实例化单位模型 $sch = new sch; - $data = $sch->kaoshi(); - $data = reSetObject($data, $src); + $data = $sch->kaoshi($src); + $cnt = $data->count(); + $data = reset_data($data, $cnt); return json($data); } diff --git a/app/system/model/School.php b/app/system/model/School.php index 6e99ca2a..a6acbfc6 100755 --- a/app/system/model/School.php +++ b/app/system/model/School.php @@ -10,27 +10,27 @@ class School extends BaseModel // 教师数据模型关联 public function dwAdmin() { - return $this->hasMany('\app\admin\model\Admin', 'school_id', 'id'); + return $this->hasMany(\app\admin\model\Admin::class, 'school_id', 'id'); } // 单位性质数据模型关联 public function dwXingzhi() { - return $this->belongsTo('\app\system\model\Category', 'xingzhi_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'xingzhi_id', 'id'); } // 单位级别数模型关联 public function dwJibie() { - return $this->belongsTo('\app\system\model\Category', 'jibie_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'jibie_id', 'id'); } // 单位学段数模型关联 public function dwXueduan() { - return $this->belongsTo('\app\system\model\Category', 'xueduan_id', 'id'); + return $this->belongsTo(\app\system\model\Category::class, 'xueduan_id', 'id'); } @@ -71,9 +71,18 @@ class School extends BaseModel ,'cnt' => false ]; $src = array_cover($srcfrom, $src); - $src['jibie_id'] = strToArray($src['jibie_id']); - $src['xingzhi_id'] = strToArray($src['xingzhi_id']); - $src['xueduan_id'] = strToArray($src['xueduan_id']); + $src['jibie_id'] = str_to_array($src['jibie_id']); + $src['xingzhi_id'] = str_to_array($src['xingzhi_id']); + $src['xueduan_id'] = str_to_array($src['xueduan_id']); + + // 实例化类别数据模型 + $cat = new \app\system\model\Category; + $paixuList = $cat->where('p_id', 102) + ->where('status', 1) + ->order(['paixu'=>'asc']) + ->field('id, title, paixu') + ->column(['id']); + $paixuList = implode('\', \'', $paixuList); // 查询数据 $data = $this @@ -120,17 +129,38 @@ class School extends BaseModel ->page($src['page'], $src['limit']) ->order([$src['field'] => $src['order']]); }) + ->orderRaw("field(jibie_id, $paixuList)") + // ->orderRaw("field(name,'thinkphp','onethink','kancloud')") + // ->fetchSql(true) ->select(); + return $data; } // 根据是否能组织考试查询单位 - public function kaoshi() + public function kaoshi($src) { - $data = $this->where('kaoshi', 1) + // 整理参数 + $src = [ + 'page' => '1' + ,'limit' => '10' + ,'field' => 'jibie_id' + ,'order' => 'asc' + ,'all'=> false + ]; + $src = array_cover($srcfrom, $src); + + + $data = $this->where('kaoshi&&status', 1) + ->where('status', 1) ->order(['jibie_id', 'paixu']) ->field('id, title, jiancheng, jibie_id') + ->when($src['all'] == false, function($query) { + $query + ->page($src['page'], $src['limit']) + ->order([$src['field'] => $src['order']]); + }) ->select(); return $data; } @@ -143,7 +173,11 @@ class School extends BaseModel $src = [ 'low' => '班级' ,'high' => '其他级' + ,'page' => 1 + ,'limit' => 10 + ,'field' => 'id' ,'order' => 'asc' + ,'cnt' => false ]; $src = array_cover($srcfrom, $src);