|
|
@@ -59,7 +59,7 @@ class VideoCommentService extends BaseService
|
|
|
* @param int $pageSize
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getDataList($params, $pageSize = 15, $field='', $userId=0)
|
|
|
+ public function getDataList($params, $pageSize = 12, $field='', $userId=0)
|
|
|
{
|
|
|
$where = ['a.mark' => 1,'a.status'=>1];
|
|
|
$field = $field? $field : 'lev_a.*';
|
|
|
@@ -114,6 +114,9 @@ class VideoCommentService extends BaseService
|
|
|
$item['member'] = $member;
|
|
|
$isLike = RedisService::get("caches:videos:comment_{$userId}_{$item['id']}");
|
|
|
$item['is_like'] = $isLike? 1 : 0;
|
|
|
+ $replyData = $this->getReplyList($item['id'], $userId, $pageSize);
|
|
|
+ $item['reply_count'] = isset($replyData['total'])? $replyData['total'] : 0;
|
|
|
+ $item['reply_list'] = isset($replyData['list'])? $replyData['list'] : [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -125,6 +128,39 @@ class VideoCommentService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 回复列表
|
|
|
+ * @param $replyId
|
|
|
+ * @param $userId
|
|
|
+ * @param int $pageSize
|
|
|
+ * @return array|mixed
|
|
|
+ */
|
|
|
+ public function getReplyList($replyId, $userId, $pageSize=12)
|
|
|
+ {
|
|
|
+ $cacheKey = "caches:videos:comment_reply_list_{$replyId}_{$userId}_{$pageSize}";
|
|
|
+ $datas = RedisService::get($cacheKey);
|
|
|
+ if($datas){
|
|
|
+ return $datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ $model = $this->model->with(['member'])
|
|
|
+ ->from('video_comments as a')
|
|
|
+ ->where(['a.reply_id'=> $replyId,'a.status'=>1,'a.mark'=>1])
|
|
|
+ ->select(['a.*'])
|
|
|
+ ->orderBy('a.create_time','desc')
|
|
|
+ ->orderBy('a.id','desc');
|
|
|
+
|
|
|
+ $countModel = clone $model;
|
|
|
+ $total = $countModel->count('a.id');
|
|
|
+
|
|
|
+ $datas = $model->limit($pageSize)->get();
|
|
|
+ $datas = $datas? $datas->toArray() : [];
|
|
|
+ if($datas){
|
|
|
+ RedisService::set($cacheKey, ['total'=> $total,'list'=> $datas], rand(30,60));
|
|
|
+ }
|
|
|
+
|
|
|
+ return ['total'=> $total,'list'=> $datas];
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 发布评论
|
|
|
* @param $userId
|
|
|
* @param $params
|