mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-08-01 20:39:06 +08:00
课程增加是否能够发布检查
This commit is contained in:
parent
675ee63674
commit
3efdc0698e
@ -163,6 +163,9 @@ class Course extends Service
|
||||
|
||||
if (isset($post['published'])) {
|
||||
$data['published'] = $validator->checkPublishStatus($post['published']);
|
||||
if ($post['published'] == 1) {
|
||||
$validator->checkPublishAbility($course);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['category_id']) && !empty($post['category_id'])) {
|
||||
|
@ -258,4 +258,25 @@ class Course extends Validator
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function checkPublishAbility(CourseModel $course)
|
||||
{
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$lessons = $courseRepo->findLessons($course->id);
|
||||
|
||||
$ability = false;
|
||||
|
||||
if ($lessons->count() > 0) {
|
||||
foreach ($lessons as $lesson) {
|
||||
if ($lesson->published == 1) {
|
||||
$ability = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$ability) {
|
||||
throw new BadRequestException('course.content_not_ready');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ $error['course.invalid_study_expiry'] = '无效的学习期限';
|
||||
$error['course.invalid_refund_expiry'] = '无效的退款期限';
|
||||
$error['course.invalid_feature_status'] = '无效的推荐状态';
|
||||
$error['course.invalid_publish_status'] = '无效的发布状态';
|
||||
$error['course.teacher_not_assigned'] = '尚未指定授课教师';
|
||||
$error['course.content_not_ready'] = '课程内容未就绪';
|
||||
|
||||
/**
|
||||
* 面授课程相关
|
||||
|
Loading…
x
Reference in New Issue
Block a user