|
@@ -1434,10 +1434,11 @@ class PostRepository
|
|
|
$toTopicId = $request['to_topic_id'];
|
|
|
|
|
|
|
|
|
+ $num = 0;
|
|
|
$this->post
|
|
|
->whereIn('id',$request['ids'])
|
|
|
->whereRaw('FIND_IN_SET(' . $topicId . ',topic_ids)')
|
|
|
- ->chunk(100, function ($posts) use ($uid, $username, $topicId, $toTopicId) {
|
|
|
+ ->chunk(100, function ($posts) use ($uid, $username, $topicId, $toTopicId, &$num) {
|
|
|
foreach($posts as $post){
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
@@ -1460,20 +1461,20 @@ class PostRepository
|
|
|
'content' => json_encode(['change_topic' => "{$post->id}:{$topicId} => {$toTopicId}"]),
|
|
|
]);
|
|
|
|
|
|
-
|
|
|
- Log::debug("post_id".$post->id);
|
|
|
-
|
|
|
DB::commit();
|
|
|
Redis::HSET('post_info_' . $post->id, 'topic_ids', $post->topic_ids);
|
|
|
Redis::zincrby('topic.just_use_count', 1, $toTopicId);
|
|
|
+ $num ++;
|
|
|
|
|
|
} catch (QueryException $exception) {
|
|
|
DB::rollBack();
|
|
|
Log::debug('替换内容话题失败:' . $exception->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return Response::create();
|
|
|
});
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '替换内容话题成功 ' . $num . ' 条',
|
|
|
+ 'status_code' => 200
|
|
|
+ ]);
|
|
|
}
|
|
|
}
|