xiaogang 4 سال پیش
والد
کامیت
57880ad69d

+ 12 - 0
app/Http/Controllers/Api/NoticeController.php

xqd
@@ -92,4 +92,16 @@ class NoticeController extends Controller
         }
         return response()->json($res);
     }
+
+    /**
+     * 删除系统消息
+     */
+    public function del_system_message(Request $request){
+        try {
+            $this->noticeService->del_message($request->id);
+        } catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json(['message'=>"操作成功"]);
+    }
 }

+ 1 - 1
app/Models/UserSystemMessageModel.php

xqd
@@ -7,6 +7,6 @@ namespace App\Models;
 class UserSystemMessageModel extends BaseModel
 {
     protected $table = 'users_system_message';
-    protected $fillable = ['user_id', 'content','status'];
+    protected $fillable = ['user_id', 'content','status','title','status','is_delete'];
 
 }

+ 10 - 0
app/Repositories/ImMessage.php

xqd
@@ -0,0 +1,10 @@
+<?php
+
+
+namespace App\Repositories;
+
+
+class ImMessage
+{
+
+}

+ 16 - 0
app/Services/NoticeService.php

xqd xqd
@@ -7,6 +7,7 @@ namespace App\Services;
 use App\Models\DynamicZanModel;
 use App\Models\UserLikeModel;
 use App\Models\UserSystemMessageModel;
+use PHPUnit\Util\Exception;
 use function Symfony\Component\Translation\t;
 
 class NoticeService
@@ -90,5 +91,20 @@ class NoticeService
         return $query;
     }
 
+    /**
+     * 删除消息
+     */
+    public function del_message($id){
+        if(empty($id)){
+            throw new Exception("参数错误");
+        }
+        if(!$message = UserSystemMessageModel::query()->find($id)){
+            throw new Exception("消息不存在");
+        }
+        $message->is_delete = 1;
+        $message->save();
+        return true;
+    }
+
 
 }

+ 1 - 0
routes/api.php

xqd
@@ -147,6 +147,7 @@ $api->version('v1', [
             $api->post('/get_like_list', 'NoticeController@get_like_list')->name('notice.get_like_list');
             $api->post('/get_zan_list', 'NoticeController@get_zan_list')->name('notice.get_zan_list');
             $api->post('/get_system_message', 'NoticeController@get_system_message')->name('notice.get_system_message');
+            $api->post('/del_system_message', 'NoticeController@del_system_message')->name('notice.del_system_message');
         });
 
         /*