diff --git a/app/api/model/Course.php b/app/api/model/Course.php index 5cf3de4..49000d2 100644 --- a/app/api/model/Course.php +++ b/app/api/model/Course.php @@ -8,7 +8,7 @@ use extend\ba\Random; use think\cache\driver\Redis; use support\think\Cache; use think\facade\Db; -use think\facade\Log; +use support\Log; use think\Model; class Course extends Model @@ -344,11 +344,8 @@ class Course extends Model if (!$freeWatch) { $det_db = Db::connect(DatabaseRoute::getConnection('course_user', ['user_id' => $user['user_id']])); $detailsId = $det_db->name('course_user')->where(['course_id' => $courseId, 'classify' => 2])->column('course_details_id'); - $det_db->close(); -// Log::write('123'); $detailsId = array_flip(array_flip($detailsId)); // 去重 } -// return returnSuccessData(123); // 处理剧集列表 $current = null; foreach ($courseDetailsSetVos as &$s) { @@ -371,18 +368,16 @@ class Course extends Model } // 检查是否已点赞 -// if ($s['sort'] > $startSort && $s['sort'] < $endSort) { -// $isGood_db = Db::connect(DatabaseRoute::getConnection('course_collect', ['user_id' => $user['user_id']])); -// $isGood = $isGood_db->name('course_collect') -// ->where('course_details_id', $s['courseDetailsId']) -// ->where('classify', 2) -// ->limit(1) -// ->count(); -// $isGood_db->close(); -// $s['isGood'] = empty($isGood) || $isGood == 0 ? 0 : 1; -// } + if ($s['sort'] > $startSort && $s['sort'] < $endSort) { + $isGood_db = Db::connect(DatabaseRoute::getConnection('course_collect', ['user_id' => $user['user_id']])); + $isGood = $isGood_db->name('course_collect') + ->where('course_details_id', $s['courseDetailsId']) + ->where('classify', 2) + ->limit(1) + ->count(); + $s['isGood'] = empty($isGood) || $isGood == 0 ? 0 : 1; + } } -// return returnSuccessData(999); // 如果没有当前播放集,默认第一集 if (empty($current) && !empty($courseDetailsSetVos)) { $courseDetailsSetVos[0]['current'] = 1;