gq 7 vuotta sitten
vanhempi
commit
384a958bf9

+ 49 - 0
server/app/Http/Controllers/Api/V1/InteractionController.php

xqd
@@ -195,4 +195,53 @@ class InteractionController extends Controller
             return $this->error(ErrorCode::OPERATION_FAILED);
         }
     }
+
+    /**
+     * @api {get} /api/comment/delete 删除评论
+     * @apiDescription 删除评论
+     * @apiGroup Interaction
+     * @apiParam {int} id       评论ID
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiSuccessExample {json} Success-Response:
+     * {
+     *  "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *   "data": ""
+     *}
+     * HTTP/1.1 200 OK
+     * @apiErrorExample {json} Error-Response:
+     * {
+     *   "status": false,
+     *   "status_code": 700,
+     *   "message": "操作失败",
+     *  "data": null
+     *}
+     * HTTP/1.1 400 Bad Request
+     */
+    public function delete(Request $request)
+    {
+        $validator = \Validator::make($request->all(),
+            [
+                'id'  => 'required',
+            ],
+            [
+                'id.required'  => '评论ID不存在',
+            ]
+        );
+
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+
+        $user = $this->getUser();
+
+
+        $ok =  CommentInfoModel::where('user_id',$user->id)->where('id',$request->id);
+
+        if ($ok) {
+            return $this->api('');
+        }else{
+            return $this->error(ErrorCode::OPERATION_FAILED);
+        }
+    }
 }

+ 4 - 0
server/routes/api.php

xqd
@@ -264,6 +264,10 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'interaction.reply',
         'uses' => 'InteractionController@reply',
     ]);
+    $api->get('/comment/delete', [  //删除评论
+        'as' => 'interaction.delete',
+        'uses' => 'InteractionController@delete',
+    ]);
 
     //支付宝支付回调
     $api->post('pay/alipay/notify', [