") * @ApiParams (name="param[number]", type="string", sample="", description="每页条数<必填>") * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功")) * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码") * @ApiReturnParams (name="num", type="integer", required=true, sample="0", description="所有消息条数") * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息") * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key") * @ApiReturn (data=" { 'status': ok, 'code': '0000', 'sessionid': 'a17z7a7a8f9g9rh9d89jio', 'num' : '10', 'info' : '' } *") **/ public function allMessage(){ try{ $sessionid = $_REQUEST['sessionid']; log::record('-----------------请求的session-------'); log::record($sessionid); $doctor = Cache::get($sessionid); $param = $_REQUEST['param']; $page = $param['page']; $number = $param['number']; $info = DB::table('messages')->where('doctor_id',$doctor['id'])->where('status',1)->limit($number)->page($page)->order('is_read asc,createdAt desc')->select(); $num = DB::table('messages')->where('doctor_id',$doctor['id'])->where('status',1)->count(); return json_encode(['status'=>'ok','code'=>'0000','info'=>$info,'sessionid'=>$sessionid,'num'=>$num]); }catch(\Exception $e){ return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]); } } /** * 未读消息 * * @ApiTitle (未读消息) * @ApiSummary (未读消息) * @ApiSector (远程诊断) * @ApiMethod (POST) * @ApiRoute (/inter/messages/unreadMessage) * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key") * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数") * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s") * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串") * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功")) * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码") * @ApiReturnParams (name="num", type="integer", required=true, sample="0", description="未读信息条数") * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息") * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key") * @ApiReturn (data=" { 'status': ok, 'code': '0000', 'sessionid': 'a17z7a7a8f9g9rh9d89jio', 'info' : '', 'num' : '10' } *") **/ public function unreadMessage() { try{ $sessionid = $_REQUEST['sessionid']; $doctor = Cache::get($sessionid); $info = DB::table('messages')->where('is_read', 0)->where('doctor_id', $doctor['id'])->where('status', 1)->order('createdAt desc')->limit(5)->select(); $num = DB::table('messages')->where('is_read', 0)->where('doctor_id', $doctor['id'])->where('status', 1)->count(); return json_encode(['status' => 'ok', 'code' => '0000', 'info' => $info, 'num' => $num,'sessionid'=>$sessionid]); }catch(\Exception $e){ return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]); } } /** * 消息详情页 * * @ApiTitle (消息详情页) * @ApiSummary (消息详情页) * @ApiSector (远程诊断) * @ApiMethod (POST) * @ApiRoute (/inter/messages/messageInfo) * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key") * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数") * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s") * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串") * @ApiParams (name="param", type="string", required=true, description="参数json字符串") * @ApiParams (name="param[id]", type="string", required=true, description="消息所属id<必填>") * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功")) * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码") * @ApiReturnParams (name="info", type="string", required=true, sample="返回成功", description="返回信息") * @ApiReturnParams (name="sessionid", type="object", sample="{}", description="缓存的数据key") * @ApiReturn (data=" { 'status': ok, 'code': '0000', 'sessionid': 'a17z7a7a8f9g9rh9d89jio', 'info' : '' } *") **/ //消息详情页 public function messageInfo(){ $sessionid = $_REQUEST['sessionid']; $doctor = Cache::get($sessionid); $param = $_REQUEST['param']; $id = $param['id']; $info = DB::table('messages')->where('id',$id)->where('status',1)->where('doctor_id', $doctor['id'])->field('title,content')->find(); if($info){ // 读取到消息 未读状态修改为已读 DB::table('messages')->where('id',$id)->update(['is_read'=>1]); return json_encode(['status'=>'ok','code'=>'0000','info'=>$info]); }else{ return json_encode(['status'=>'fail','code'=>'1012','msg'=>'该条信息不存在','sessionid'=>$sessionid]); } } /** * 已读 * * @ApiTitle (已读) * @ApiSummary (已读) * @ApiSector (远程诊断) * @ApiMethod (POST) * @ApiRoute (/inter/messages/changeRead) * @ApiHeaders (name="sign", type="string", required=true, description="请求头-校验key") * @ApiHeaders (name="nonce", type="string", required=true, description="请求头-随机数") * @ApiHeaders (name="timestamp", type=string, required=true, description="请求头-时间戳s") * @ApiParams (name="sessionid", type="string", required=true, description="参数json字符串") * @ApiParams (name="id", type="string", required=true, description="消息所属id<必填>") * @ApiReturnParams (name="status", type="integer", required=true, sample="0", description="返回码 fail 失败 ok成功")) * @ApiReturnParams (name="code", type="integer", required=true, sample="0", description="返回状态码") * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功", description="返回消息信息") * @ApiReturn (data=" { 'status': ok, 'code': '0000', 'msg' : '已读' } *") **/ public function changeRead(){ $id = $_REQUEST['id']; DB::table('messages')->where('id',$id)->update(['is_read'=>1]); return json_encode(['status'=>'ok','code'=>'0000','msg'=>'已读']); } }