|
@@ -288,6 +288,44 @@ class PostRepositories
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除评论
|
|
|
+ */
|
|
|
+ public function commentDelete($request)
|
|
|
+ {
|
|
|
+ $userInfo = $this->getUserInfo();
|
|
|
+ if (empty($userInfo)) {
|
|
|
+ return jsonError('获取用户信息失败');
|
|
|
+ }
|
|
|
+ $comment = $this->postComment->find($request['id']);
|
|
|
+ if (!$comment) {
|
|
|
+ return jsonError('获取评论信息失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ if($userInfo['uid'] != $comment->uid){
|
|
|
+ return jsonError('只能删除自己的评论');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($comment->is_delete == 1) {
|
|
|
+ return jsonError('该评论已经删除');
|
|
|
+ }
|
|
|
+
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $comment->is_delete = 1;
|
|
|
+ $comment->save();
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+ Redis::SADD('delete_post_comment_ids', $comment->id);
|
|
|
+ return jsonSuccess('删除评论成功');
|
|
|
+
|
|
|
+ } catch (QueryException $exception) {
|
|
|
+ DB::rollBack();
|
|
|
+ Log::debug('删除评论:' . $request['id'] . $exception->getMessage());
|
|
|
+ return jsonError('删除评论失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 内容列表
|
|
|
*/
|