|
|
@@ -18,6 +18,7 @@ use App\Models\VideoModel;
|
|
|
use App\Services\BaseService;
|
|
|
use App\Services\RedisService;
|
|
|
use BN\Red;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
/**
|
|
|
* 短视频评论管理-服务类
|
|
|
@@ -183,11 +184,11 @@ class VideoCommentService extends BaseService
|
|
|
public function publish($userId, $params)
|
|
|
{
|
|
|
$albums = isset($params['albums'])? get_format_images($params['albums']) : '';
|
|
|
-
|
|
|
+ $videoId = isset($params['video_id'])? intval($params['video_id']) : 0;
|
|
|
$data = [
|
|
|
'user_id'=> $userId,
|
|
|
'reply_id'=> isset($params['reply_id'])? intval($params['reply_id']) : 0,
|
|
|
- 'video_id'=> isset($params['video_id'])? intval($params['video_id']) : 0,
|
|
|
+ 'video_id'=> $videoId,
|
|
|
'reply_to_uid'=> isset($params['reply_to_uid'])? intval($params['reply_to_uid']) : 0,
|
|
|
'albums'=> $albums,
|
|
|
'content'=> isset($params['content'])? trim($params['content']) : '',
|
|
|
@@ -198,6 +199,7 @@ class VideoCommentService extends BaseService
|
|
|
];
|
|
|
|
|
|
if($this->model->insertGetId($data)){
|
|
|
+ VideoModel::where(['id'=> $videoId])->update(['comment_num'=>DB::raw("comment_num + 1"),'update_time'=>time()]);
|
|
|
$this->error = 2942;
|
|
|
return true;
|
|
|
}
|
|
|
@@ -236,4 +238,24 @@ class VideoCommentService extends BaseService
|
|
|
$this->error = 1003;
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param $id
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function deleteRow($id)
|
|
|
+ {
|
|
|
+ $videoId = $this->model->where(['id'=> $id])->value('video_id');
|
|
|
+ $this->model->where(['id'=> $id])->delete();
|
|
|
+ try {
|
|
|
+ if($videoId>0){
|
|
|
+ VideoModel::where(['id'=> $videoId])->update(['comment_num'=>DB::raw("comment_num - 1"),'update_time'=>time()]);
|
|
|
+ }
|
|
|
+ } catch (\Exception $exception){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|