Browse Source

消息首页接口

lizhen_gitee 1 year ago
parent
commit
5640981551
1 changed files with 23 additions and 0 deletions
  1. 23 0
      application/api/controller/Message.php

+ 23 - 0
application/api/controller/Message.php

@@ -12,6 +12,29 @@ class Message extends Api
     protected $noNeedLogin = [];
     protected $noNeedRight = ['*'];
 
+    //消息页信息
+    public function index(){
+        $rs = [
+            'msg_first'      => Db::name('message')->where('user_id',$this->auth->id)->order('status asc,id desc')->find(),
+            'msg_unread_num' => Db::name('message')->where('user_id',$this->auth->id)->where('infotype','neq','newfriend')->where('status',0)->count(),
+            'msgsys_first'   => Db::name('message_sys')->order('id desc')->find(),
+        ];
+
+        $this->success(1,$rs);
+    }
+
+    //个人消息全部改为已读
+    public function message_read(){
+        //读取即为已读
+        $map = [
+            'user_id'  => $this->auth->id,
+            'status'   => 0,
+            'infotype' => ['neq','newfriend']
+        ];
+        Db::name('message')->where($map)->update(['status'=>1]);
+        $this->success();
+    }
+
     //我的个人消息列表
     public function mylist(){
         $list = Db::name('message')->where('user_id',$this->auth->id)->autopage()->order('id desc')->select();