|
@@ -14,6 +14,8 @@ use App\Models\Topic;
|
|
|
use Dingo\Api\Http\Response;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Database\QueryException;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
+use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
class TopicRepository {
|
|
|
public function __construct(Topic $topic,CategoryTopic $categoryTopic){
|
|
@@ -78,6 +80,7 @@ class TopicRepository {
|
|
|
}
|
|
|
}
|
|
|
DB::commit();
|
|
|
+ Redis::zadd('topic.name', $topicInfo->name, $topicInfo->id);
|
|
|
return Response::create();
|
|
|
}catch (QueryException $exception){
|
|
|
DB::rollBack();
|
|
@@ -183,4 +186,25 @@ class TopicRepository {
|
|
|
public function getTopics($ids = []){
|
|
|
return $this->topic->whereIn('id', $ids)->select('id','name')->get();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置话题redis
|
|
|
+ */
|
|
|
+ public function resetRedis()
|
|
|
+ {
|
|
|
+ $TopicName = $this->topic->pluck('id', 'name')->toArray();
|
|
|
+
|
|
|
+ $res = Redis::zadd('topic.name', $TopicName);
|
|
|
+ if($res){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '重置话题成功',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '重置话题失败',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|