From 13fb77f8ddfab9ba264c0ef27b3bc4fcaf80edb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Tue, 31 Jan 2023 10:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Notice.php | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 app/api/controller/Notice.php 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('未找到该数据'); + } + } + + + + +}