From b18bfc9a4a16eba76ba57db1e45b28ef7ed2189e Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 6 Jun 2025 19:28:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=AD=A6=E7=94=9F=E6=8E=92=E8=AF=BE=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E5=9C=BA=E5=9C=B0=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 getVenueListAll 方法获取学生排课的全部场地列表 - 在路由中添加相应的 API 路由 - 优化了查询条件,使用表名避免字段重复问题 --- .../apiController/PersonCourseSchedule.php | 15 ++++++++++ niucloud/app/api/route/route.php | 2 ++ .../PersonCourseScheduleService.php | 28 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/niucloud/app/api/controller/apiController/PersonCourseSchedule.php b/niucloud/app/api/controller/apiController/PersonCourseSchedule.php index 9b434de2..06b00e1a 100644 --- a/niucloud/app/api/controller/apiController/PersonCourseSchedule.php +++ b/niucloud/app/api/controller/apiController/PersonCourseSchedule.php @@ -108,4 +108,19 @@ class PersonCourseSchedule extends BaseApiService $res = (new PersonCourseScheduleService())->getCalendar($where); return success($res); } + + //获取学生排课的全部场地列表 + public function getVenueListAll(Request $request){ + $resources_id = $request->param('resources_id', '');//客户资源ID + $course_date = $request->param('course_date', '');//上课日期(Y-m-d) + if (empty($resources_id)) { + return fail('缺少参数'); + } + $where = [ + 'resources_id'=>$resources_id, + 'course_date'=>$course_date + ]; + $res = (new PersonCourseScheduleService())->getVenueListAll($where); + return success($res); + } } diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index aaaf5689..6493c3c0 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -367,6 +367,8 @@ Route::group(function () { Route::post('xy/personCourseSchedule/editStatus', 'apiController.PersonCourseSchedule/editStatus'); //学生端-学生课程安排-获取排课日历 Route::get('xy/personCourseSchedule/getCalendar', 'apiController.PersonCourseSchedule/getCalendar'); + //学生端-学生课程安排-获取学生排课的全部场地列表 + Route::get('xy/personCourseSchedule/getVenueListAll', 'apiController.PersonCourseSchedule/getVenueListAll'); diff --git a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php index 5fa18c15..f5508021 100644 --- a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php +++ b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php @@ -45,7 +45,7 @@ class PersonCourseScheduleService extends BaseApiService //上课日期 if (!empty($where['course_date'])) { - $model = $model->where('course_date', $where['course_date']); + $model = $model->where('school_person_course_schedule.course_date', $where['course_date']); } //判断有没有客户上课状态 @@ -239,4 +239,30 @@ class PersonCourseScheduleService extends BaseApiService } return $result; } + + //获取学生排课的全部场地列表 + public function getVenueListAll(array $where) + { + $schedule_id = PersonCourseSchedule::where('resources_id', $where['resources_id']) + ->where('course_date', $where['course_date']) + ->distinct(true) + ->column('schedule_id'); + + if(!$schedule_id){ + return []; + } + + $venue_id = CourseSchedule::whereIn('id',$schedule_id)->distinct(true)->column('venue_id'); + if(!$venue_id){ + return []; + } + + $res = Venue::whereIn('id',$venue_id) + ->with([ + 'campus' + ]) + ->select()->toArray(); + + return $res; + } }