Browse Source

feat(api): 增加人员课程安排筛选功能

- 添加上课日期和场地 ID 筛选参数
- 优化状态筛选逻辑,处理关联表查询
-调整列表接口返回数据格式
master
liutong 10 months ago
parent
commit
8d8ab0e3c6
  1. 7
      niucloud/app/api/controller/apiController/PersonCourseSchedule.php
  2. 13
      niucloud/app/service/api/apiService/PersonCourseScheduleService.php

7
niucloud/app/api/controller/apiController/PersonCourseSchedule.php

@ -24,11 +24,14 @@ use function DI\string;
class PersonCourseSchedule extends BaseApiService class PersonCourseSchedule extends BaseApiService
{ {
//列表 //列表(人员与课程安排关系表)
public function index(Request $request) public function index(Request $request)
{ {
$resources_id = $request->param('resources_id', '');//客户资源ID $resources_id = $request->param('resources_id', '');//客户资源ID
$status = $request->param('status', '');//状态0待上课1已上课2请假 $status = $request->param('status', '');//状态0待上课1已上课2请假
$course_date = $request->param('course_date', '');//上课日期Y-m-d
$venue_id = $request->param('venue_id', '');//场地ID
if (empty($resources_id)) { if (empty($resources_id)) {
return fail('缺少参数'); return fail('缺少参数');
} }
@ -36,6 +39,8 @@ class PersonCourseSchedule extends BaseApiService
$where = [ $where = [
'resources_id' => $resources_id, 'resources_id' => $resources_id,
'status' => $status, 'status' => $status,
'course_date' => $course_date,
'venue_id' => $venue_id,
]; ];
$res = (new PersonCourseScheduleService())->getList($where); $res = (new PersonCourseScheduleService())->getList($where);

13
niucloud/app/service/api/apiService/PersonCourseScheduleService.php

@ -42,9 +42,20 @@ class PersonCourseScheduleService extends BaseApiService
$model = $model->where('resources_id', $where['resources_id']); $model = $model->where('resources_id', $where['resources_id']);
} }
//上课日期
if (!empty($where['course_date'])) {
$model = $model->where('course_date', $where['course_date']);
}
//判断有没有客户上课状态 //判断有没有客户上课状态
if (array_key_exists('status', $where) && $where['status'] != '') { if (array_key_exists('status', $where) && $where['status'] != '') {
$model = $model->where('status', $where['status']); // $model = $model->where('status', $where['status']);
$model = $model->where('school_person_course_schedule.status', $where['status']);
}
// 判断有没有场地ID
if (!empty($where['venue_id'])) {
$model = $model->hasWhere('courseScheduleHasOne', ['venue_id' => $where['venue_id']]);
} }
$data = $model->order('course_date','desc') $data = $model->order('course_date','desc')

Loading…
Cancel
Save