ZxcZxc123 1 yıl önce
ebeveyn
işleme
5075cde236

+ 15 - 7
app/api/controller/Education.php

@@ -122,20 +122,28 @@ class Education
     }
 
 
+    /**
+     * 获取课程列表
+     * @param $gr_id
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function getCourseList($gr_id)
     {
-        // 根据gr_id获取课程目录
+
         $courseList = EducationCourse::where('course_status', 1)
             ->where('gr_id', $gr_id)
             ->where('course_audit', 1)
             ->select();
 
-        // 返回课程目录给前端
-        return json([
-            'code' => 200,
-            'msg' => 'ok',
-            'data' => $courseList
-        ]);
+        return app('json') -> success($courseList);
+//        return json([
+//            'code' => 200,
+//            'msg' => 'ok',
+//            'data' => $courseList
+//        ]);
     }
 
 

+ 14 - 0
app/model/api/CourseModel.php

@@ -99,6 +99,20 @@ class CourseModel extends Model
         return $result;
     }
 
+    /**
+     * 修改课程审核状态
+     * @param $course_id
+     * @param $course_audit
+     * @return mixed
+     */
+    public function updateCourseAudit($course_id, $course_audit)
+    {
+        $result = Db::table($this->table)->where('course_id', $course_id)->update(['course_audit' => $course_audit]);
+        return $result;
+    }
+
+
+
     /**
      * 修改课程信息
      * @param $course_id

+ 19 - 0
app/system/controller/CourseController.php

@@ -179,6 +179,25 @@ class CourseController
     }
 
 
+
+    /**
+     * 修改课程审核状态
+     */
+    public function updateCourseAudit()
+    {
+        $course_id = Request::param('course_id');
+        $course_status = Request::param('course_audit');
+
+        $courseModel = new CourseModel();
+        $result = $courseModel->updateCourseAudit($course_id, $course_status);
+
+        if ($result) {
+            return json(['code' => 200, 'msg' => '修改成功', 'data' => $result]);
+        } else {
+            return json(['code' => 500, 'msg' => '修改失败', 'data' => '']);
+        }
+    }
+
     /**
      * 课程是否轮播
      *

+ 2 - 0
app/system/route/course.php

@@ -28,6 +28,8 @@ Route::group('courseController', function () {
     Route::rule('getCourseList','courseController/getCourseList');
     //修改课程状态
     Route::rule('updateCourseStatus','courseController/updateCourseStatus');
+    //修改课程审核状态
+    Route::rule('updateCourseAudit','courseController/updateCourseAudit');
     //修改课程信息
     Route::rule('updateCourseInfo','courseController/updateCourseInfo');
     //获取课程详情并编辑课程