Просмотр исходного кода

Wesmiler 校企小程序源代码部署

wesmiler 4 лет назад
Родитель
Сommit
920b8ad1cb

+ 39 - 0
app/api/controller/School.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\School as SchoolModel;
+
+/**
+ * 学校控制器
+ * Class School
+ * @package app\api\controller
+ */
+class School extends Controller
+{
+    /**
+     * 学校列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function list()
+    {
+        // 获取列表数据
+        $model = new SchoolModel();
+        $pageSize = $this->request->param('pageSize', 15);
+        $list = $model->getList($this->request->param(), $pageSize);
+        return $this->renderSuccess(compact('list'));
+    }
+
+    /**
+     * 选项列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function options()
+    {
+        $model = new SchoolModel();
+        $list = $model->getOptionList($this->request->param());
+        return $this->renderSuccess(compact('list'));
+    }
+}

+ 21 - 0
app/api/controller/SchoolSpeciality.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\SchoolSpeciality as SchoolSpecialityModel;
+use think\response\Json;
+
+/**
+ * 学校专业控制器
+ * Class SchoolSpeciality
+ * @package app\api\controller
+ */
+class SchoolSpeciality extends Controller
+{
+
+    public function options(): Json
+    {
+        $model = new SchoolSpecialityModel;
+
+    }
+}

+ 39 - 0
app/api/controller/SourceShool.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\SourceShool as SourceShoolModel;
+
+/**
+ * 学校控制器
+ * Class School
+ * @package app\api\controller
+ */
+class SourceShool extends Controller
+{
+    /**
+     * 学校列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function list()
+    {
+        // 获取列表数据
+        $model = new SourceShoolModel();
+        $pageSize = $this->request->param('pageSize', 15);
+        $list = $model->getList($this->request->param(), $pageSize);
+        return $this->renderSuccess(compact('list'));
+    }
+
+    /**
+     * 选项列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function options()
+    {
+        $model = new SourceShoolModel();
+        $list = $model->getOptionList($this->request->param());
+        return $this->renderSuccess(compact('list'));
+    }
+}

+ 100 - 0
app/api/model/School.php

@@ -11,6 +11,8 @@
 declare (strict_types=1);
 
 namespace app\api\model;
+use app\common\library\helper;
+use app\common\model\Region;
 use app\common\model\School as SchoolModel;
 
 /**
@@ -32,6 +34,102 @@ class School extends SchoolModel
     ];
 
     /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 整理查询参数
+        $params = array_merge($param, ['audit_status' => 1]);
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+        // 隐藏冗余的字段
+        $list->hidden(array_merge($this->hidden, ['albums']));
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
+     * 设置展示的数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setListDataFromApi($info)
+    {
+        $specialityModel = new SchoolSpeciality;
+        return $this->setListData($info, function ($data) use($specialityModel) {
+            $data['speciality'] = $specialityModel->getHots($data['id']);
+
+            // 整理数据 api模块
+            $this->setDataFromApi($data);
+        });
+    }
+
+    /**
+     * 整理数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setDataFromApi($info)
+    {
+        return $this->setData($info, function ($data) {
+            // logo封面
+            $data['logo'] = $data['logo']? getPreview($data['logo']) : '';
+            $data['labels'] = $data['labels']? explode(',', $data['labels']) : [];
+
+            // 图片列表
+            $data['albums'] = helper::getArrayColumn($data['albums'], 'album_url');
+
+            // 地区
+            $data['province_name'] = $data['province_id']? Region::getNameById($data['province_id']) : '';
+            $data['city_name'] = $data['city_id']? Region::getNameById($data['city_id']) : '';
+            $data['region_name'] = $data['region_id']? Region::getNameById($data['region_id']) : '';
+
+            // 分类等级
+            $data['education_levels_text'] = isset($this->levelTypes[$data['education_levels']])? $this->levelTypes[$data['education_levels']] : '无';
+
+            // 距离
+            if(!is_null($data['distance'])){
+                $data['distance'] = $data['distance']? ($data['distance']<1000? "{$data['distance']}m" : ($data['distance']/1000).'km') :'';
+            }
+
+            // 浏览数
+            if(!is_null($data['views'])){
+                $data['views'] = $data['views']? ($data['views']<10000? "{$data['views']}" : round($data['views']/10000,1).'w') :'';
+            }
+
+
+        });
+    }
+
+    /**
+     * 获取选项列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getOptionList(array $param = [], string $field='')
+    {
+        return $this->where(['audit_status'=> 1])
+            ->where(function ($query) use ($param){
+                $keyword = isset($param['keyword'])? trim($param['keyword']) : '';
+                if($keyword){
+                    $query->where('school_name','like',"%{$keyword}%");
+                }
+            })
+            ->field($field?:'id,school_name,type,level,hot_order')
+            ->order('hot_order desc,views desc')
+            ->select();
+    }
+
+    /**
      * 获取学校信息
      * @param $where
      * @param array $with
@@ -47,4 +145,6 @@ class School extends SchoolModel
         }
         return static::get($filter, $with);
     }
+
+
 }

+ 33 - 0
app/api/model/SchoolAlbum.php

@@ -0,0 +1,33 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+use app\common\model\SchoolAlbum as SchoolAlbumModel;
+
+/**
+ * 学校图库模型类
+ * Class SchoolAlbum
+ * @package app\api\model
+ */
+class SchoolAlbum extends SchoolAlbumModel
+{
+
+    protected $globalScope = [''];
+
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'update_time'
+    ];
+}

+ 52 - 0
app/api/model/SchoolSpeciality.php

@@ -0,0 +1,52 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+use app\common\model\SchoolSpeciality as SchoolSpecialityModel;
+
+/**
+ * 学校专业模型类
+ * Class SchoolSpeciality
+ * @package app\api\model
+ */
+class SchoolSpeciality extends SchoolSpecialityModel
+{
+
+    protected $globalScope = [''];
+
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'update_time'
+    ];
+
+    /**
+     * 获取学校的专业
+     * @param int $school_id  学校ID
+     * @param string $field 返回字段
+     * @param int $limit 返回数量
+     * @return SchoolSpeciality[]|array|\think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getHots(int $school_id, $field='', $limit=3)
+    {
+        return $this->where(['school_id'=>$school_id])
+            ->field($field?:'speciality_id,speciality_name,school_id,recruit_num')
+            ->order('views desc,speciality_id desc')
+            ->limit($limit?? 3)
+            ->select()??[];
+    }
+}

+ 131 - 0
app/api/model/SourceShool.php

@@ -0,0 +1,131 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+use app\api\service\User as UserService;
+use app\common\model\SourceShool as SourceShoolModel;
+
+/**
+ * 生源学校模型类
+ * Class SourceShool
+ * @package app\api\model
+ */
+class SourceShool extends SourceShoolModel
+{
+
+    protected $globalScope = [''];
+
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+    ];
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 整理查询参数
+        $params = array_merge($param, []);
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+        // 隐藏冗余的字段
+        $list->hidden(array_merge($this->hidden, ['province_id']));
+
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
+     * 设置展示的数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setListDataFromApi($info)
+    {
+        $userInfo = UserService::getCurrentLoginUser(true);
+        return $this->setListData($info, function ($data) use ($userInfo) {
+            // 整理数据 api模块
+            $this->setDataFromApi($data, $userInfo);
+        });
+    }
+
+    /**
+     * 整理数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setDataFromApi($info, User $userInfo)
+    {
+        return $this->setData($info, function ($data) use ($userInfo) {
+            // 解锁统计
+            $lockedNum = rand(10, 100);
+            $data['locked_num'] = $lockedNum;
+            $data['unlock_num'] = max(0, $data['students_num'] - $lockedNum);
+
+            // 区域
+            $data['city_name'] = Region::getNameById($data['city_id']);
+            $data['region_name'] = Region::getNameById($data['region_id']);
+
+            $data->hidden(array_merge($this->hidden,['province_id']));
+        });
+    }
+
+    /**
+     * 获取选项列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getOptionList(array $param = [], string $field='')
+    {
+        return $this->where(function ($query) use ($param){
+                $keyword = isset($param['keyword'])? trim($param['keyword']) : '';
+                if($keyword){
+                    $query->where('source_shools_name','like',"%{$keyword}%")
+                        ->whereOr('address','like',"%{$keyword}%");
+                }
+            })
+            ->field($field?:'source_shools_id as id,source_shools_name as school_name,students_num')
+            ->order('students_num desc,source_shools_id desc')
+            ->select();
+    }
+
+    /**
+     * 获取学校信息
+     * @param $where
+     * @param array $with
+     * @return static|array|false|null
+     */
+    public static function detail($where, array $with = [])
+    {
+        $filter = [];
+        if (is_array($where)) {
+            $filter = array_merge($filter, $where);
+        } else {
+            $filter['user_id'] = (int)$where;
+        }
+        return static::get($filter, $with);
+    }
+
+
+}

+ 25 - 25
app/api/model/Store.php

@@ -1,27 +1,27 @@
-<?php
-// +----------------------------------------------------------------------
-// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
-// +----------------------------------------------------------------------
-// | Author: 萤火科技 <admin@yiovo.com>
-// +----------------------------------------------------------------------
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
 declare (strict_types=1);
-
-namespace app\api\model;
-
-use app\common\model\Store as StoreModel;
+
+namespace app\api\model;
+
+use app\common\model\Store as StoreModel;
 use think\model\relation\HasOne;
-
-/**
- * 商家记录表模型
- * Class Store
- * @package app\store\model
- */
-class Store extends StoreModel
-{
+
+/**
+ * 商家记录表模型
+ * Class Store
+ * @package app\store\model
+ */
+class Store extends StoreModel
+{
     /**
      * 隐藏的字段
      * @var string[]
@@ -33,7 +33,7 @@ class Store extends StoreModel
         'create_time',
         'update_time'
     ];
-
+
     /**
      * 关联logo图片
      * @return HasOne
@@ -45,11 +45,11 @@ class Store extends StoreModel
     }
 
     /**
-     * 获取当前商城的基本信息
+     * 获取当前平台基本信息
      * @return Store|array|null
      */
     public static function getInfo()
     {
         return static::detail(static::$storeId);
     }
-}
+}

+ 161 - 0
app/common/model/School.php

@@ -13,7 +13,10 @@ declare (strict_types=1);
 namespace app\common\model;
 
 use cores\BaseModel;
+use think\model\Collection;
+use think\model\relation\HasMany;
 use think\model\relation\HasOne;
+use think\Paginator;
 
 /**
  * 学校模型类
@@ -28,5 +31,163 @@ class School extends BaseModel
     // 定义主键
     protected $pk = 'id';
 
+    protected $levelTypes = [1=>'中职',2=>'高职'];
 
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 筛选条件
+        $query = $this->getQueryFilter($param);
+        // 排序条件
+        $sort = $this->setQuerySort($param);
+
+        // 范围查询
+        $field = '*';
+        $lng = isset($param['longitude'])? $param['longitude'] : 0;
+        $lat = isset($param['latitude'])? $param['latitude'] : 0;
+        if($lng && $lat){
+            $field .= ",ROUND(
+            6378.138 * 2 * ASIN(
+                SQRT(
+                    POW(
+                        SIN(
+                            (
+                                {$lat} * PI() / 180 - ".$this->name.".`latitude` * PI() / 180
+                            ) / 2
+                        ),
+                        2
+                    ) + COS({$lat} * PI() / 180) * COS(".$this->name.".`latitude` * PI() / 180) * POW(
+                        SIN(
+                            (
+                                {$lng} * PI() / 180 - ".$this->name.".`longitude` * PI() / 180
+                            ) / 2
+                        ),
+                        2
+                    )
+                )
+                ) * 1000
+            ) AS distance";
+            $sort = ' distance desc, hot_order desc';
+        }
+
+        // 执行查询
+        $list = $query->alias($this->name)
+            ->order($sort)
+            ->field($field)
+            ->paginate($listRows);
+
+        // 整理列表数据并返回
+        return $list;
+    }
+
+    /**
+     * 设置商品展示的数据
+     * @param Collection|Paginator $list 商品列表
+     * @param callable|null $callback 回调函数
+     * @return mixed
+     */
+    protected function setListData($list, callable $callback = null)
+    {
+        if ($list->isEmpty()) return $list;
+        // 遍历商品列表整理数据
+        foreach ($list as &$item) {
+            $data = $this->setData($item, $callback);
+        }
+        return $list;
+    }
+
+    /**
+     * 整理数据
+     * @param Collection|static $info
+     * @param callable|null $callback
+     * @return mixed
+     */
+    protected function setData($info, callable $callback = null)
+    {
+        // 回调函数
+        is_callable($callback) && call_user_func($callback, $info);
+        return $info->hidden(array_merge($this->hidden, ['albums']));
+    }
+
+    /**
+     * 检索查询条件
+     * @param array $params
+     * @return \think\db\BaseQuery
+     */
+    private function getQueryFilter(array $params)
+    {
+        $filter = [];
+
+        // 实例化新查询对象
+        $query = $this->getNewQuery();
+
+        // 学校层次,类型
+        !empty($params['education_levels']) && $filter[] = ['education_levels', '=', "{$params['education_levels']}"];
+
+        // 实例化新查询对象
+        return $query->where($filter)->where(function($query) use ($params){
+            // 关键词
+            if(!empty($params['keyword'])){
+                $query->where('school_name','like', "%{$params['keyword']}%");
+//                $query->where('school_name','like', "%{$params['keyword']}%")->whereOr('address','like',"%{$params['keyword']}%");
+            }
+        });
+    }
+
+
+    /**
+     * 检索排序条件
+     * @param array $param
+     * @return array|string[]
+     */
+    private function setQuerySort(array $param = [])
+    {
+        $params = $this->setQueryDefaultValue($param, [
+            'sortType' => 'all',    // 排序类型
+            'hot_order' => false,   // 热门排序 (true高到低 false低到高)
+        ]);
+        // 排序规则
+        $sort = [];
+        if ($params['sortType'] === 'all') {
+            $sort = ['hot_order' => 'desc'];
+        } elseif ($params['sortType'] === 'view') {
+            $sort = ['views' => 'desc'];
+        }
+
+        return array_merge($sort, [$this->getPk() => 'desc']);
+    }
+
+    /**
+     * 关联图库
+     * @return HasMany
+     */
+    public function albums(): HasMany
+    {
+        return $this->hasMany('SchoolAlbum','school_id','id');
+    }
+
+
+    /**
+     * 关联地区
+     * @return HasOne
+     */
+    public function city(): HasOne
+    {
+        return $this->HasOne('region','id','city_id')->bind(['name as city_name']);
+    }
+
+    /**
+     * 关联地区
+     * @return HasOne
+     */
+    public function region(): HasOne
+    {
+        return $this->HasOne('region','id','region_id')->bind(['name as region_name']);
+    }
 }

+ 32 - 0
app/common/model/SchoolAlbum.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\relation\HasOne;
+
+/**
+ * 学校图库模型类
+ * Class SchoolAlbum
+ * @package app\common\model
+ */
+class SchoolAlbum extends BaseModel
+{
+    // 定义表名
+    protected $name = 'school_album';
+
+    // 定义主键
+    protected $pk = 'album_id';
+
+
+}

+ 125 - 0
app/common/model/SourceShool.php

@@ -0,0 +1,125 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\Collection;
+use think\Paginator;
+
+/**
+ * 生源学校模型类
+ * Class SourceShool
+ * @package app\common\model
+ */
+class SourceShool extends BaseModel
+{
+    // 定义表名
+    protected $name = 'source_shools';
+
+    // 定义主键
+    protected $pk = 'source_shools_id';
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 筛选条件
+        $query = $this->getQueryFilter($param);
+        // 排序条件
+        $sort = $this->setQuerySort($param);
+
+        // 执行查询
+        $list = $query->alias($this->name)
+            ->order($sort)
+            ->paginate($listRows);
+
+        // 整理列表数据并返回
+        return $list;
+    }
+
+    /**
+     * 设置商品展示的数据
+     * @param Collection|Paginator $list 商品列表
+     * @param callable|null $callback 回调函数
+     * @return mixed
+     */
+    protected function setListData($list, callable $callback = null)
+    {
+        if ($list->isEmpty()) return $list;
+        // 遍历商品列表整理数据
+        foreach ($list as &$item) {
+            $data = $this->setData($item, $callback);
+        }
+        return $list;
+    }
+
+    /**
+     * 整理数据
+     * @param Collection|static $info
+     * @param callable|null $callback
+     * @return mixed
+     */
+    protected function setData($info, callable $callback = null)
+    {
+        // 回调函数
+        is_callable($callback) && call_user_func($callback, $info);
+        return $info->hidden(array_merge($this->hidden,['province_id']));
+    }
+
+    /**
+     * 检索查询条件
+     * @param array $params
+     * @return \think\db\BaseQuery
+     */
+    private function getQueryFilter(array $params)
+    {
+        $filter = [];
+
+        // 实例化新查询对象
+        $query = $this->getNewQuery();
+
+        // 实例化新查询对象
+        return $query->where($filter)->where(function($query) use ($params){
+            // 关键词
+            if(!empty($params['keyword'])){
+                $query->where('source_shools_name','like', "%{$params['keyword']}%");
+            }
+        });
+    }
+
+
+    /**
+     * 检索排序条件
+     * @param array $param
+     * @return array|string[]
+     */
+    private function setQuerySort(array $param = [])
+    {
+        $params = $this->setQueryDefaultValue($param, [
+            'sortType' => 'all',    // 排序类型
+            'students_num' => false,   // 热门排序 (true高到低 false低到高)
+        ]);
+        // 排序规则
+        $sort = [];
+        if ($params['sortType'] === 'all') {
+            $sort = ['students_num' => 'desc'];
+        }
+
+        return array_merge($sort, [$this->getPk() => 'desc']);
+    }
+}