['except' => [] ] ]; /** * 消息通知列表 */ public function list($page=1,$limit=10){ $where['status'] = 1; $where['user_id'] = $this->request->uid; $res = Db::table('cms_notice') ->where($where) ->field('id,user_id,title,content,create_time,is_read,read_time') ->page($page, $limit) ->select(); $this->apiSuccess('获取成功',$res); } /** * 未读消息数 */ public function count(){ $where['status'] = 1; $where['is_read'] = 0; $where['user_id'] = $this->request->uid; $res = Db::table('cms_notice') ->where($where) ->count(); $this->apiSuccess('获取成功',$res); } /** * 消息详情 */ public function info(){ $id = get_params('id'); if(empty($id)){ $this->apiError('缺少参数'); } $where['id'] = $id; $where['user_id'] = $this->request->uid; $res = Db::table('cms_notice') ->where($where) ->find(); if($res){ $res['nickname'] = Db::table('fa_szxc_information_usermsg')->where('user_id',$res['user_id'])->value('name'); $res['create_time'] = date('Y-m-d H:i:s',$res['create_time']); $data['is_read'] = 1; $data['read_time'] = time(); Db::table('cms_notice')->where($where)->update($data); $this->apiSuccess('获取成功',$res); }else{ $this->apiError('未找到该数据'); } } }