| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace app\api\controller;
- use app\api\model\School as SchoolModel;
- use app\api\model\SchoolNew;
- use app\api\model\UserDynamic;
- use app\api\service\User as UserService;
- use app\common\model\SchoolAlbum;
- /**
- * 学校控制器
- * 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'));
- }
- /**
- * 获取学校主页数据
- * @return \think\response\Json
- * @throws \cores\exception\BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function homeData()
- {
- $schoolId = $this->request->param('school_id', 0);
- if($schoolId<=0){
- $userInfo = UserService::getCurrentLoginUser(true);
- $schoolId = isset($userInfo['info']['school_id'])? intval($userInfo['info']['school_id']) : 0;
- $userType = isset($userInfo['user_type'])? $userInfo['user_type'] : 0;
- $schoolId = $userType != 3? 0 : $schoolId;
- }
- if($schoolId <= 0){
- return $this->renderSuccess('您无权访问或未绑定学校信息,请先绑定');
- }
- $data = [
- 'info'=> SchoolModel::detail($schoolId),
- 'albums'=> SchoolAlbum::getShowList($schoolId, 6),
- 'news'=> SchoolNew::getShowList($schoolId, 1, 3),
- 'scenery'=> SchoolNew::getShowList($schoolId, 2, 6)
- ];
- return $this->renderSuccess($data);
- }
- /**
- * 校园时态
- * @return \think\response\Json
- * @throws \think\db\exception\DbException
- */
- public function dynamic(){
- $model = new UserDynamic();
- $list = $model->getList($this->request->param());
- return $this->renderSuccess(compact('list'));
- }
- }
|