getToken($this->getToken()); $user['autograph_url'] = $this->makeFileUrl($user['autograph'],$user['autograph_type']); $user['attachment_url'] = $this->makeFileUrl($user['attachment'],$user['attachment_type']); return $this->success($user); } catch (Exception $exception){ $this->throwError('系统异常',0001); } } public function changePwd(DoctorService $service) { // try{ $params = $this->getParams(); DoctorValidate::checkPwd($params); $info = $service->changePwd($params,$this->getToken()); return $this->success($info); // } catch (Exception $exception){ // $this->throwError('系统异常',0001); // } } public function changeinfo(DoctorService $service) { try{ $params = $this->getParams(); DoctorValidate::check($params); $info = $service->changeInfo($params,$this->getToken()); return $this->success($info); } catch (Exception $exception){ $this->throwError('系统异常',0001); } } public function attachmentUpload() { try{ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('attachment'); // 移动到框架应用根目录/public/uploads/ 目录下 if($file) { $fildInfo = $file->getInfo(); $name = $fildInfo['name']; $search = '/.php$/'; if(preg_match($search,$name)) { // php文件批量不允许通过 return ''; } $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if ($info) { // $url = '/' . 'uploads' . '/' . $info->getSaveName(); // return $this->success($url); $key = 'attachment/' . $info->getFilename(); $source_file = './' . 'uploads' . '/' . $info->getSaveName(); $upload = new uploadToCloud();; $s = $upload->upload($key,$source_file); if(($s['@metadata']['statusCode'] ?? '') == '200') { gc_collect_cycles(); unset($info); unlink($source_file); $success = ['url'=>$key,'type'=>'2','tokenUrl'=>$upload->makeUrl($key)]; return $this->success($success); }else{ return '上传云失败'; } } else { // 上传失败获取错误信息 echo $file->getError(); } } }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function autographUpload() { try{ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('autograph'); // 移动到框架应用根目录/public/uploads/ 目录下 if($file) { $fildInfo = $file->getInfo(); $name = $fildInfo['name']; $search = '/.php$/'; if(preg_match($search,$name)) { // php文件批量不允许通过 return ''; } // $type = explode('/',$file->getInfo()['type'])[1]; // $name = md5(time().rand(1,10000)).'.'.$type; // $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads',$name); $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if ($info) { // $url = '/' . 'uploads' . '/' . $info->getSaveName(); // return $this->success($url); $key = 'autograph/' . $info->getFilename(); $source_file = './' . 'uploads' . '/' . $info->getSaveName(); $upload = new uploadToCloud();; $s = $upload->upload($key,$source_file); if(($s['@metadata']['statusCode'] ?? '') == '200') { gc_collect_cycles(); unset($info); unlink($source_file); $success = ['url'=>$key,'type'=>'2','tokenUrl'=>$upload->makeUrl($key)]; return $this->success($success); }else{ return '上传云失败'; } } else { // 上传失败获取错误信息 echo $file->getError(); } } }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function getPower(DoctorService $service) { try{ $user = $service->getToken($this->getToken()); $id = $user['id']; $info = $service->getPower($id); return $this->success($info); }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function getLoginCode(DoctorService $service) { $token = $this->getToken(); $info = $service->getLoginCode($token); return $this->success($info); } public function doctorList(DoctorService $service) { $token = $this->getToken(); $user = $this->getCache($token); $info = $service->doctorList($user['institution_id']); return $this->success($info); } public function downData() { $params = $this->getParams(); $upload = new uploadToCloud(); $s = $upload->makeUrl($params['path'] ?? ''); if(empty($s)) { $this->throwError('下载获取失败,请联系管理员','0303'); } return $this->success($s); } }