|
@@ -206,7 +206,8 @@ class PostRepository
|
|
|
'available_bean', $postData->available_bean,
|
|
|
'will_collect_bean', $postData->will_collect_bean,
|
|
|
'create_bean', $postData->create_bean,
|
|
|
- 'collect_bean', $postData->collect_bean);
|
|
|
+ 'collect_bean', $postData->collect_bean,
|
|
|
+ 'created_at', $post->created_at);
|
|
|
|
|
|
return Response::create();
|
|
|
|
|
@@ -430,6 +431,10 @@ class PostRepository
|
|
|
try {
|
|
|
$comment = $this->postComment->create($data);
|
|
|
|
|
|
+ if($comment->parent_id){
|
|
|
+ $this->postComment->where('id', $comment->parent_id)->increment('reply_count');
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
|
|
|
if(!$comment->parent_id){
|
|
@@ -506,6 +511,7 @@ class PostRepository
|
|
|
|
|
|
return $post
|
|
|
->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
+ ->with('data')
|
|
|
->select('post.*')
|
|
|
->where($where)
|
|
|
->where(function ($query) use ($request) {
|
|
@@ -950,7 +956,7 @@ class PostRepository
|
|
|
Carbon::parse($post->created_at)->toDateTimeString(),
|
|
|
$post->username,
|
|
|
$post->location,
|
|
|
- implode(' ', $post->topic()->toArray()),
|
|
|
+ implode(' ', $this->getTopic($post->topic_ids)),
|
|
|
subtext(strip_tags($post->content), 20),
|
|
|
$post->data->pv_real,
|
|
|
$post->data->pv,
|
|
@@ -1054,5 +1060,69 @@ class PostRepository
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑内容话题
|
|
|
+ */
|
|
|
+ public function updateTopic($request)
|
|
|
+ {
|
|
|
+ $token = JWTAuth::decode(JWTAuth::getToken());
|
|
|
+ if($token['type'] != 1){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '只有运营才能删除内容',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $post = $this->post->where('id', $request['id'])->first();
|
|
|
+ if (!$post) {
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '获取内容信息失败',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //验证话题
|
|
|
+ $topicIdsArray = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
|
|
|
+ $topicCount = count($topicIdsArray);
|
|
|
+ if ($topicCount == 0 || $topicCount > 5) {
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '所选话题必须1-5个',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $topicIds = implode(',', $topicIdsArray);
|
|
|
+
|
|
|
+ $logData = [
|
|
|
+ 'uid' => $token['user']->id,
|
|
|
+ 'operator_type' => 'admin',
|
|
|
+ 'post_id' => $request['id'],
|
|
|
+ 'username' => $token['user']->username,
|
|
|
+ 'log_type' => 'update_topic',
|
|
|
+ 'content' => json_encode(['update_topic' => $request['id'].'-'.$topicIds]),
|
|
|
+ ];
|
|
|
+
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $post->topic_ids = $topicIds;
|
|
|
+ $post->save();
|
|
|
+
|
|
|
+ $this->postLog->create($logData);
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+
|
|
|
+ Redis::HSET('post_info_'.$request['id'], 'topic_ids', $topicIds);
|
|
|
+
|
|
|
+ return Response::create();
|
|
|
+
|
|
|
+ } catch (QueryException $exception) {
|
|
|
+ DB::rollBack();
|
|
|
+ Log::debug('编辑内容话题:'.$post->id . $exception->getMessage());
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '编辑失败,请重试',
|
|
|
+ 'error' => $exception->getMessage(),
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|