public static function getQuestionList($courseId) { $courseModel = Course::findOneById($courseId); if (Course::isRoot($courseModel)) { return static::find()->where(['root_id' => $courseId])->orderBy('create_time DESC')->all(); } if (Course::isFile($courseModel)) { return static::find()->where(['course_id' => $courseId])->orderBy('create_time DESC')->all(); } }
public static function commentList($courseId) { $courseModel = Course::findModel($courseId); if (Course::isFile($courseModel)) { return static::find()->where(['course_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all(); } if (Course::isRoot($courseModel)) { return static::find()->where(['root_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all(); } }
protected function findModelByCoursId($courseId) { //如果没有找到这门课则返回null $model = Course::findOneById($courseId); if (empty($model) || !Course::isRoot($model)) { return null; } return $model; }