Files
2026-03-20 18:00:19 +08:00

32 lines
926 B
PHP

<?php
namespace app\api\controller;
use app\api\logic\ChatNotifyLogic;
/**
* 聊天相关接口(C端-患者)
*/
class ChatController extends BaseApiController
{
public array $notNeedLogin = ['notifyOpen'];
/**
* 患者打开会话时通知医生
* 无需登录,通过参数传递
*/
public function notifyOpen()
{
$doctorId = (int) ($this->request->post('doctor_id') ?: $this->request->post('doctorId'));
$patientId = trim((string) ($this->request->post('patient_id') ?: $this->request->post('patientId') ?: ''));
$patientName = trim((string) ($this->request->post('patient_name') ?: $this->request->post('patientName') ?: '患者'));
if ($doctorId <= 0) {
return $this->fail('医生ID无效');
}
ChatNotifyLogic::addNotify($doctorId, $patientId ?: '0', $patientName);
return $this->success('已通知');
}
}