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((int)$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(); $schoolId = $this->request->param('school_id', 0); $userInfo = UserService::getCurrentLoginUser(true); $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0; if($schoolId <= 0){ return $this->renderSuccess('您无权访问或未绑定学校信息,请先绑定'); } $list = $model->getListBySchool($schoolId, $userId, $this->request->param()); return $this->renderSuccess(compact('list')); } /** * 校园专业时态 * @return \think\response\Json * @throws \think\db\exception\DbException */ public function specialityDynamic(){ $model = new SchoolSpeciality; $schoolId = $this->request->param('school_id', 0); if($schoolId<=0){ $userInfo = UserService::getCurrentLoginUser(true); $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0; $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('您无权访问或未绑定学校信息,请先绑定'); } $list = $model->getList(['school_id'=> $schoolId]); return $this->renderSuccess(compact('list')); } /** * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function comparison() { $ids = $this->request->param('ids',''); $ids = $ids? explode(',', $ids) : []; if(empty($ids)){ return $this->renderSuccess('请先选择对比学校'); } if(count($ids) > 3){ return $this->renderSuccess('一次最多选择3个'); } $model = new SchoolModel; $list = $model->getComparisonList($ids, 3); return $this->renderSuccess(compact('list')); } /** * 校园时态 * @return \think\response\Json * @throws \think\db\exception\DbException */ public function news(){ $model = new SchoolNew(); $pageSize = $this->request->param('pageSize', 15); $list = $model->getList($this->request->param(), (int)$pageSize); return $this->renderSuccess(compact('list')); } /** * 校园时态 * @return \think\response\Json * @throws \think\db\exception\DbException */ public function newsDetail(){ $model = new SchoolNew(); $info = $model->getDetail((int)$this->request->param('news_id')); return $this->renderSuccess(compact('info')); } }