123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- namespace app\api\servies\doctor;
- use app\api\response\ZskkErrorResponse;
- use app\api\servies\ZskkDefaultService;
- use app\api\dao\doctor\DoctorDao;
- use app\api\servies\common\CommonService;
- use think\facade\Log;
- /**
- * 后台控制器基类
- * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
- */
- class DoctorService extends ZskkDefaultService {
- protected $logName = "DoctorService";
- private $doctor = null;
- public function __construct(DoctorDao $doctorDao) {
- parent::__construct();
- $this->doctor = $doctorDao;
- }
- public function getToken($token)
- {
- $user = $this->doctor->getToken($token);
- return $user;
- }
- public function changePwd($params,$token)
- {
- if($params['newpass'] != $params['newrepass']){
- $this->throwError('修改的密码两次输出不一致,请重新填写',0030);
- }
- $pattern = '/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[\W_]).+$/';
- if(!preg_match($pattern, $params['newpass']))
- {
- // $this->throwError('密码必须由数字、字母、特殊符号一起组成',0033);
- }
- $info = $this->doctor->getToken($token);
- if($info['password'] != md5($params['password'])){
- $this->throwError('原密码输入错误,请重新输入',0031);
- }
- $data = $this->doctor->changePwd($info['id'],$params['newpass']);
- if(!$data){
- $this->throwError('密码修改失败,请重新尝试',0032);
- }
- return $data;
- }
- public function changeInfo($info,$token)
- {
- $user = $this->doctor->getToken($token);
- $id = $user['id'];
- $data = array();
- $data['realname'] = $info['realname'];
- $data['email'] = $info['email'];
- $data['phone'] = $info['phone'];
- $data['doctor_title'] = $info['doctor_title'];
- $data['message_push'] = $info['message_push'];
- $data['send_sms'] = $info['send_sms'];
- $data['attachment'] = $info['attachment'];
- $data['is_use_autograph'] = $info['is_use_autograph'];
- $data['autograph'] = $info['autograph'];
- $data['report_full'] = $info['report_full'];
- $data['autograph_type'] = $info['autograph_type'] ?? 1;
- $data['attachment_type'] = $info['attachment_type'] ?? 1;
- $return = $this->doctor->changeInfo($data,$id,$token);
- return $return;
- }
- public function getPower($id)
- {
- $info = $this->doctor->getPower($id);
- $data = [];
- if(!empty($info)){
- if(strpos($info,'2')){
- //本地写
- $data[] = 1;
- }
- if(strpos($info,'3')){
- //本地审核
- $data[] = 2;
- }
- if(strpos($info,'4')){
- //本地确认
- $data[] = 3;
- }
- if(strpos($info,'6')){
- //本地申请
- $data[] = 4;
- }
- if(strpos($info,'7')){
- //远程写
- $data[] = 5;
- }
- if(strpos($info,'8')){
- //远程审核
- $data[] = 6;
- }
- }
- return $data;
- }
- // 获取登录代码
- public function getLoginCode($token)
- {
- $doctor = $this->doctor->getCache($token);
- if(!$doctor){
- return false;
- }
- $admin = $this->doctor->getFaAdmin($doctor['phone']);
- if(!$admin){
- return false;
- }
- $login_code = $this->doctor->getLoginCode($doctor['id']);
- if($login_code){
- return [
- 'code' => $login_code,
- 'phone' => $doctor['phone']
- ];
- }
- return false;
- }
- public function doctorList($institution)
- {
- $list = $this->doctor->getDoctorList($institution);
- return $list;
- }
- }
|