diff --git a/niucloud/app/api/controller/apiController/Course.php b/niucloud/app/api/controller/apiController/Course.php new file mode 100644 index 00000000..7621e567 --- /dev/null +++ b/niucloud/app/api/controller/apiController/Course.php @@ -0,0 +1,36 @@ +member_id; + $data = $this->request->params([ + ["schedule_date",0] + ]); + return success((new CourseService())->list($id,$data)); + } + +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index c2221d61..130537e4 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -276,7 +276,8 @@ Route::group(function () { - + //课程列表 + Route::get('course/courseList', 'apiController.course/courseList'); //教研管理文章列表 Route::get('teachingResearch/list', 'apiController.teachingResearch/list'); //教研管理文章详情 diff --git a/niucloud/app/service/api/apiService/CourseService.php b/niucloud/app/service/api/apiService/CourseService.php new file mode 100644 index 00000000..72619710 --- /dev/null +++ b/niucloud/app/service/api/apiService/CourseService.php @@ -0,0 +1,66 @@ +model = new Course(); + } + + //获取教研管理文章列表 + public function list($id,$data) + { + $where = []; + if ($data['schedule_date']) { + $where[] = ['course_date','=', $data['schedule_date']]; + } + $CourseSchedule = new CourseSchedule(); + $search_model = $CourseSchedule + ->where('coach_id', $id) + ->where($where) + ->with(['course' => function($query) { + $query->select(); + },'venue' => function($query) { + $query->select(); + }]); + $list = $this->pageQuery($search_model); + $PersonCourseSchedule = new PersonCourseSchedule(); + foreach ($list['data'] as $k => $v) { + $student = Db::name('person_course_schedule') + ->alias('pcs') + ->where('pcs.schedule_id', $v['id']) // 建议加上表别名避免冲突 + ->join('school_student st', 'pcs.student_id = st.id') + ->join('school_customer_resources cr', 'st.user_id = cr.id') + ->join('school_member sm', 'cr.member_id = sm.member_id') + ->field('st.name, sm.headimg as avatar') // 👈 正确方式取字段 + ->select(); + $list['data'][$k]['student'] = $student; + } + return $list; + } +} +