新增关注、取消关注问诊医生
This commit is contained in:
parent
a3eb0e3dd0
commit
7d57d2f94a
@ -95,4 +95,26 @@ class PatientDoctorController extends AbstractController
|
||||
$data = $PatientDoctorService->getDoctorEvaluationList();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增关注医生
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function addDoctorFollow(): ResponseInterface
|
||||
{
|
||||
$PatientDoctorService = new PatientDoctorService();
|
||||
$data = $PatientDoctorService->addDoctorFollow();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消关注医生
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function deleteDoctorFollow(): ResponseInterface
|
||||
{
|
||||
$PatientDoctorService = new PatientDoctorService();
|
||||
$data = $PatientDoctorService->deleteDoctorFollow();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -77,6 +77,25 @@ class PatientFollow extends Model
|
||||
return self::where($params)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return \Hyperf\Database\Model\Model|PatientFollow
|
||||
*/
|
||||
public static function addPatientFollow(array $data): \Hyperf\Database\Model\Model|PatientFollow
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @return int|mixed
|
||||
*/
|
||||
public static function deletePatientFollow(array $params = []): mixed
|
||||
{
|
||||
return self::where($params)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页数据
|
||||
* @param array $params
|
||||
|
||||
@ -586,6 +586,63 @@ class PatientDoctorService extends BaseService
|
||||
return success($order_evaluation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增关注医生
|
||||
* @return array
|
||||
*/
|
||||
public function addDoctorFollow(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$doctor_id = $this->request->route('doctor_id');
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$res = PatientFollow::getExists($params);
|
||||
if ($res){
|
||||
// 已关注,重复请求
|
||||
return success();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
$data['doctor_id'] = $doctor_id;
|
||||
$patient_follow = PatientFollow::addPatientFollow($data);
|
||||
if (empty($patient_follow)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消关注医生
|
||||
* @return array
|
||||
*/
|
||||
public function deleteDoctorFollow(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$doctor_id = $this->request->route('doctor_id');
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$res = PatientFollow::getExists($params);
|
||||
if (!$res){
|
||||
// 未关注,执行取消关注
|
||||
return success();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
PatientFollow::deletePatientFollow($params);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页服务过患者的医生
|
||||
* 限制条数
|
||||
|
||||
@ -231,6 +231,12 @@ Router::addGroup('/patient', function () {
|
||||
|
||||
// 获取医生评价
|
||||
Router::get('/evaluation/{doctor_id:\d+}', [PatientDoctorController::class, 'getDoctorEvaluationList']);
|
||||
|
||||
// 新增关注医生
|
||||
Router::post('/follow/{doctor_id:\d+}', [PatientDoctorController::class, 'addDoctorFollow']);
|
||||
|
||||
// 取消关注医生
|
||||
Router::delete('/follow/{doctor_id:\d+}', [PatientDoctorController::class, 'deleteDoctorFollow']);
|
||||
});
|
||||
|
||||
// 家庭成员
|
||||
@ -506,14 +512,6 @@ Router::post('/13', [CallBackController::class, 'imCallBack']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取问诊价格列表-消息-无问诊消息时
|
||||
Router::post('/19', [CallBackController::class, 'imCallBack']);
|
||||
|
||||
// 获取系统消息列表-系统消息
|
||||
Router::post('/20', [CallBackController::class, 'imCallBack']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user