ZxcZxc123 před 1 rokem
rodič
revize
30f6c78ed6
2 změnil soubory, kde provedl 15 přidání a 32 odebrání
  1. 14 31
      app/api/controller/Education.php
  2. 1 1
      app/api/route/education.php

+ 14 - 31
app/api/controller/Education.php

@@ -122,41 +122,24 @@ class Education
     }
 
 
-    /**
-     * 获取课程详细信息
-     * @param $gr_id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function getCourseInfo($gr_id) {
-        $courses = DB::table('table_education_course')
-            ->where('course_status', 1)
-            ->whereIn('gr_id', (array) $gr_id)
+    public function getCourseList($gr_id)
+    {
+        // 根据gr_id获取课程目录
+        $courseList = EducationCourse::where('course_status', 1)
+            ->where('gr_id', $gr_id)
             ->where('course_audit', 1)
-            ->select()
-            ->toArray();
-        $course_list = [];
-        foreach ($courses as $course) {
-            $course_info = [
-                'course_id' => $course->course_id,
-                'course_name' => $course->course_name,
-                'course_cover' => $course->course_cover,
-                // 其他课程相关信息
-            ];
-            $course_list[] = $course_info;
-        }
-        $count_and_all = $this->getCountAndAlll($gr_id);
-        $result = [
-            'course_list' => $course_list,
-            'count' => $count_and_all[0]['count'],
-            'alll' => $count_and_all[0]['alll']
-        ];
-        return $result;
+            ->select();
+
+        // 返回课程目录给前端
+        return json([
+            'code' => 0,
+            'msg' => 'success',
+            'data' => $courseList
+        ]);
     }
 
 
 
 
+
 }

+ 1 - 1
app/api/route/education.php

@@ -19,7 +19,7 @@ Route::group('Education', function () {
     //获取轮播列表
     Route::rule('recommend','Education/recommend');
     //获取课程详情
-    Route::rule('getCourseInfo','Education/getCourseInfo');
+    Route::rule('getCourseList','Education/getCourseList');