diff --git a/niucloud/app/api/controller/apiController/CustomerResources.php b/niucloud/app/api/controller/apiController/CustomerResources.php index ca92ff54..b4c83424 100644 --- a/niucloud/app/api/controller/apiController/CustomerResources.php +++ b/niucloud/app/api/controller/apiController/CustomerResources.php @@ -230,5 +230,28 @@ class CustomerResources extends BaseApiService return success($res); } + //修改用户课程的主教、助教、教务 + public function updateUserCourse(Request $request) + { + $main_coach_id = $request->param('main_coach_id', ''); + $assistant_ids = $request->param('assistant_ids', ''); + $id = $request->param('id', ''); + $education_id = $request->param('education_id', '');//查询类型|resource=客户资源,six_speed=六要素 + + if (empty($customer_resource_id) || empty($course_id) || empty($staff_id) || empty($type)) { + return fail('缺少必要参数'); + } + //修改用户课程的主教、助教、教务 + $res = (new CustomerResourcesService())->updateUserCourseInfo([ + 'id' => $id, + 'main_coach_id' => $main_coach_id, + 'assistant_ids' => $assistant_ids, + 'education_id' => $education_id + ]); + if (!$res['code']) { + return fail($res['msg']); + } + return success([]); + } } diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 0f6097c4..9b49719e 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -354,7 +354,7 @@ Route::group(function () { Route::get('personnel/reimbursement_list', 'apiController.Personnel/reimbursement_list'); Route::post('personnel/reimbursement_add', 'apiController.Personnel/reimbursement_add'); Route::get('personnel/reimbursement_info', 'apiController.Personnel/reimbursement_info'); - //更新学员主教练、助教、教务 + })->middleware(ApiChannel::class) ->middleware(ApiPersonnelCheckToken::class, true) diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index f88b7b95..24b8e111 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -666,4 +666,49 @@ class CustomerResourcesService extends BaseApiService } + public function updateUserCourseInfo($data) + { + // 验证必要参数 + if (empty($data['id'])) { + return ['code' => false, 'msg' => '缺少必要参数id']; + } + + try { + // 更新school_student_courses表中的字段 + $update_data = []; + + // 更新主教练ID + if (isset($data['main_coach_id'])) { + $update_data['main_coach_id'] = $data['main_coach_id']; + } + + // 更新助教IDs + if (isset($data['assistant_ids'])) { + $update_data['assistant_ids'] = $data['assistant_ids']; + } + + // 更新教务ID + if (isset($data['education_id'])) { + $update_data['education_id'] = $data['education_id']; + } + + // 如果没有需要更新的数据,直接返回成功 + if (empty($update_data)) { + return ['code' => true, 'msg' => '更新成功']; + } + + // 执行更新操作 + $res = \think\facade\Db::name('student_courses') + ->where('id', $data['id']) + ->update($update_data); + + if ($res !== false) { + return ['code' => true, 'msg' => '更新成功']; + } else { + return ['code' => false, 'msg' => '更新失败']; + } + } catch (\Exception $e) { + return ['code' => false, 'msg' => '更新失败:' . $e->getMessage()]; + } + } }