diff --git a/app/api/controller/Notice.php b/app/api/controller/Notice.php new file mode 100644 index 0000000..2bd1cf6 --- /dev/null +++ b/app/api/controller/Notice.php @@ -0,0 +1,76 @@ + ['except' => [] ] + ]; + + /** + * 消息通知列表 + */ + public function list($page=1,$limit=10){ + $where['status'] = 1; + $where['user_id'] = JWT_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'] = JWT_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'] = JWT_UID; + $res = Db::table('cms_notice') + ->where($where) + ->find(); + if($res){ + $data['is_read'] = 1; + $data['read_time'] = time(); + Db::table('cms_notice')->where($where)->update($data); + $this->apiSuccess('获取成功',$res); + }else{ + $this->apiError('未找到该数据'); + } + } + + + + +}