getParams(); TemplateValidate::check($params); // exam_class $examClass = $service->getExamClass($params['examId']); // 获取公有、私有模板 $public = $service->getPublicTemplate($examClass); $user = $service->getUser($this->getToken()); $private = $service->getPrivateTemplate($examClass,$user['id']); // 返回 $data = [ 'public' => $public, 'private' => $private ]; return $this->success($data); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } /** * 获取公有模板(父级) */ public function getPublic(TemplateService $service) { try{ // 参数 $params = $this->getParams(); // TemplateValidate::checkPublic($params); // exam_class $exam_class = $params['exam_class']; // 判断是否存储catch $key = $service->getPublicTemplateKey($exam_class); $public = $service->getPublicInfo($key,$exam_class); //返回 return $this->success($public); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } public function getPrivate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); // TemplateValidate::checkPublic($params); // exam_class $exam_class = $params['exam_class']; // 获取公有 $token = $this->getToken(); $user = $service->getUser($token); $private = $service->getPrivate($exam_class,$user['id']); //返回 return $this->success($private); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } public function getChild(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkId($params); // 获取子级数据 $child = $service->getChildData($params['id']); // 返回 return $this->success($child); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } public function saveParentTemplate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkSaveParent($params); $doctor = $service->getUser($this->getToken()); // 获取子级数据 $info = $service->saveParent($params,$doctor); // 返回 return $this->success($info); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } public function saveChildTemplate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkSaveChild($params); $doctor = $service->getUser($this->getToken()); // 获取子级数据 $info = $service->saveChild($params,$doctor); // 返回 return $this->success($info); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } //获取模板信息 public function getTemplateInfo(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkId($params); // 获取子级数据 $child = $service->getTemplateInfo($params['id']); // 返回 return $this->success($child); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } //修改模板 public function updateTemplate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkId($params); // 获取子级数据 $child = $service->updateTemplate($params); // 返回 return $this->success($child); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } //获取父类模板列表 public function getParent(TemplateService $service) { try{ $doctor = $service->getUser($this->getToken()); $params = $this->getParams(); // 获取列表数据 $child = $service->getParent($doctor,$params); // 返回 return $this->success($child); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } //删除私有模板 public function delTemplate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); TemplateValidate::checkId($params); $doctor = $service->getUser($this->getToken()); // 获取子级数据 $child = $service->delTemplate($doctor,$params['id']); // 返回 return $this->success($child); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } public function getHospitalTemplate(TemplateService $service) { try{ // 参数 $params = $this->getParams(); $doctor = $service->getUser($this->getToken()); // 获取子级数据 $hospital = $service->getHospitalTemplate($doctor['institution_id'],$params['exam_class'] ?? ''); // 返回 return $this->success($hospital); } catch (Exception $exception){ $this->throwError($exception->getMessage(),0001); } } }