|
@@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Redis;
|
|
class CircleArticleRepository
|
|
class CircleArticleRepository
|
|
{
|
|
{
|
|
|
|
|
|
- public function __construct(InterestCircleArticle $interestCircleArticle, Post $post,InterestCircle $interestCircle)
|
|
|
|
|
|
+ public function __construct(InterestCircleArticle $interestCircleArticle, Post $post, InterestCircle $interestCircle)
|
|
{
|
|
{
|
|
$this->interestCircleArticle = $interestCircleArticle;
|
|
$this->interestCircleArticle = $interestCircleArticle;
|
|
$this->post = $post;
|
|
$this->post = $post;
|
|
@@ -94,7 +94,6 @@ class CircleArticleRepository
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
$article->save();
|
|
$article->save();
|
|
-
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
return Response::create();
|
|
return Response::create();
|
|
|
|
|
|
@@ -131,11 +130,12 @@ class CircleArticleRepository
|
|
$this->interestCircle->decrement('article_count');
|
|
$this->interestCircle->decrement('article_count');
|
|
$isRef = $this->interestCircleArticle->where('post_id', $request['post_id'])->exists();
|
|
$isRef = $this->interestCircleArticle->where('post_id', $request['post_id'])->exists();
|
|
if (!$isRef) {
|
|
if (!$isRef) {
|
|
- //todo 移出后需要检测该帖子在其他圈子有没有设为精品,如没有,则删除该帖子的精品标识
|
|
|
|
- //$this->post->where('id',$request['post_id'])->update();
|
|
|
|
|
|
+ //移出后需要检测该帖子在其他圈子有没有设为精品,如没有,则删除该帖子的精品标识
|
|
|
|
+ $this->post->where('id', $request['post_id'])->update(['is_fine' => 0]);
|
|
|
|
+ Redis::HSET('post_info_' . $request['post_id'],'is_fine',0);
|
|
}
|
|
}
|
|
- $key = 'circle_articles_'.$request['circle_id'];
|
|
|
|
- Redis::zrem($key,$request['post_id']);
|
|
|
|
|
|
+ $key = 'circle_articles_' . $request['circle_id'];
|
|
|
|
+ Redis::zrem($key, $request['post_id']);
|
|
DB::commit();
|
|
DB::commit();
|
|
return Response::create();
|
|
return Response::create();
|
|
|
|
|
|
@@ -149,6 +149,7 @@ class CircleArticleRepository
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增精品文章
|
|
* 新增精品文章
|
|
*/
|
|
*/
|
|
@@ -167,11 +168,14 @@ class CircleArticleRepository
|
|
|
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
- $this->interestCircleArticle->insert(['post_id'=>$request['post_id'],'circle_id'=>$request['circle_id']]);
|
|
|
|
|
|
+ $this->interestCircleArticle->insert(['post_id' => $request['post_id'], 'circle_id' => $request['circle_id']]);
|
|
$this->interestCircle->increment('article_count');
|
|
$this->interestCircle->increment('article_count');
|
|
|
|
+ //修改帖子为精品贴
|
|
|
|
+ $this->post->where('id', $request['post_id'])->update(['is_fine' => 1]);
|
|
|
|
+ Redis::HSET('post_info_' . $request['post_id'],'is_fine',1);
|
|
//将精品文章存入该圈子的有序集合中
|
|
//将精品文章存入该圈子的有序集合中
|
|
- $key = 'circle_articles_'.$request['circle_id'];
|
|
|
|
- Redis::zadd($key,time(),$request['post_id']);
|
|
|
|
|
|
+ $key = 'circle_articles_' . $request['circle_id'];
|
|
|
|
+ Redis::zadd($key, time(), $request['post_id']);
|
|
DB::commit();
|
|
DB::commit();
|
|
return Response::create();
|
|
return Response::create();
|
|
|
|
|
|
@@ -191,7 +195,8 @@ class CircleArticleRepository
|
|
* @param $request
|
|
* @param $request
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function postList($request){
|
|
|
|
|
|
+ public function postList($request)
|
|
|
|
+ {
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
$where = [];
|
|
$where = [];
|
|
if (isset($request['type'])) {
|
|
if (isset($request['type'])) {
|
|
@@ -203,8 +208,8 @@ class CircleArticleRepository
|
|
}
|
|
}
|
|
|
|
|
|
if (isset($request['circle_id'])) {
|
|
if (isset($request['circle_id'])) {
|
|
- $circleInfo = $this->interestCircle->where('id',$request['circle_id'])->first();
|
|
|
|
- if($circleInfo && $circleInfo->limit_article_ids){
|
|
|
|
|
|
+ $circleInfo = $this->interestCircle->where('id', $request['circle_id'])->first();
|
|
|
|
+ if ($circleInfo && $circleInfo->limit_article_ids) {
|
|
$request['topic_ids'] = "{$circleInfo->limit_article_ids}";
|
|
$request['topic_ids'] = "{$circleInfo->limit_article_ids}";
|
|
}
|
|
}
|
|
}
|
|
}
|