You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
435 lines
14 KiB
435 lines
14 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\apiController;
|
|
|
|
use app\Request;
|
|
use app\service\api\apiService\CourseService;
|
|
use core\base\BaseApiService;
|
|
|
|
|
|
/**
|
|
* 客户资源相关接口
|
|
* Class Personnel
|
|
* @package app\api\controller\apiController
|
|
*/
|
|
class Course extends BaseApiService
|
|
{
|
|
|
|
//课程列表
|
|
public function courseList(Request $request){
|
|
$id = $this->member_id;
|
|
|
|
$data = $this->request->params([
|
|
["schedule_date",0]
|
|
]);
|
|
return success((new CourseService())->list($id,$data));
|
|
}
|
|
|
|
//班级课程列表
|
|
public function classCourseList(Request $request){
|
|
$id = $this->member_id;
|
|
return success((new CourseService())->classList($id));
|
|
}
|
|
|
|
//获取课程详情
|
|
public function courseInfo(Request $request){
|
|
$data = $this->request->params([
|
|
["id",0]
|
|
]);
|
|
return success('SUCCESS',(new CourseService())->info($data['id']));
|
|
}
|
|
|
|
//获取添加学员列表
|
|
public function addStudentList(Request $request){
|
|
$data = $this->request->params([
|
|
["id",0]
|
|
]);
|
|
return success('SUCCESS',(new CourseService())->StudentList($data['id']));
|
|
}
|
|
|
|
//获取添加学员列表
|
|
public function addStudent(Request $request){
|
|
$data = $this->request->params([
|
|
["student_id",0],
|
|
["schedule_id",0],
|
|
["time_slot",0],
|
|
["resources_id",1],
|
|
["person_id",1],
|
|
["course_date",'']
|
|
]);
|
|
return success('SUCCESS',(new CourseService())->addStudent($data));
|
|
}
|
|
|
|
//请假
|
|
public function delStudentCourse(Request $request){
|
|
$data = $this->request->params([
|
|
["student_id",0],
|
|
["course_id",0]
|
|
]);
|
|
return success('SUCCESS',(new CourseService())->delStudentCourse($data));
|
|
}
|
|
|
|
|
|
public function get_date(){
|
|
$data = $this->request->params([
|
|
["date",''],
|
|
['day','']
|
|
]);
|
|
return success(( new CourseService() )->getDate($data));
|
|
}
|
|
|
|
|
|
public function courseAllList(Request $request){
|
|
$data = $this->request->params([
|
|
["schedule_date",0],
|
|
["start_date",""], // 开始日期
|
|
["end_date",""], // 结束日期
|
|
["teacher_name",""], // 教练姓名
|
|
["venue_number",""], // 场地编号
|
|
["time_hour",""] // 时间段
|
|
]);
|
|
return success((new CourseService())->listAll($data));
|
|
}
|
|
|
|
|
|
public function addSchedule(Request $request){
|
|
$data = $this->request->params([
|
|
["resources_id",''],
|
|
["student_id",''],
|
|
["person_type",''],
|
|
["schedule_id",''],
|
|
["course_date",''],
|
|
["time_slot",''],
|
|
["schedule_type", 1], // 1=正式位, 2=等待位
|
|
["course_type", 1], // 1=正式课, 2=体验课, 3=等待位
|
|
["position", ''], // 位置信息
|
|
["remark", ''] // 备注
|
|
]);
|
|
return (new CourseService())->addSchedule($data);
|
|
}
|
|
|
|
public function schedule_list(Request $request){
|
|
$data = $this->request->params([
|
|
["schedule_id",'']
|
|
]);
|
|
return success((new CourseService())->schedule_list($data));
|
|
}
|
|
|
|
public function schedule_del(Request $request)
|
|
{
|
|
$data = $this->request->params([
|
|
["id", ''],
|
|
["resources_id", ''],
|
|
["remark", '']
|
|
]);
|
|
return (new CourseService())->schedule_del($data);
|
|
}
|
|
|
|
/**
|
|
* 更新学员课程人员配置
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function updateStudentCoursePersonnel(Request $request)
|
|
{
|
|
try {
|
|
$params = $request->all();
|
|
|
|
// 验证必要参数
|
|
if (empty($params['student_course_id'])) {
|
|
return fail('学员课程ID不能为空');
|
|
}
|
|
|
|
$res = (new CourseService())->updateStudentCoursePersonnel($params);
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success($res['data'], '更新成功');
|
|
} catch (\Exception $e) {
|
|
return fail('更新学员课程人员配置失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取课程列表(用于添加课程安排)
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function getCourseList(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["keyword", ""], // 课程名称关键词搜索
|
|
["course_type", ""], // 课程类型筛选
|
|
["status", 1] // 状态筛选,默认获取有效课程
|
|
]);
|
|
|
|
$result = (new CourseService())->getCourseListForSchedule($data);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('获取成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('获取课程列表失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取课程安排详情
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function scheduleDetail(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["schedule_id", 0] // 课程安排ID
|
|
]);
|
|
|
|
if (empty($data['schedule_id'])) {
|
|
return fail('课程安排ID不能为空');
|
|
}
|
|
|
|
$result = (new CourseService())->getScheduleDetail($data['schedule_id']);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('获取成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('获取课程安排详情失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索可添加的学员
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function searchStudents(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["keyword", ""], // 搜索关键词(姓名或手机号)
|
|
["search_type", ""], // 搜索类型(name或phone)
|
|
["schedule_id", 0] // 课程安排ID(用于排除已添加的学员)
|
|
]);
|
|
|
|
if (empty($data['keyword'])) {
|
|
return success('搜索成功', []);
|
|
}
|
|
|
|
$result = (new CourseService())->searchAvailableStudents($data);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('搜索成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('搜索学员失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加学员到课程安排
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function addStudentToSchedule(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["schedule_id", 0], // 课程安排ID
|
|
["student_id", 0], // 学员ID(可选)
|
|
["resources_id", 0], // 资源ID(可选)
|
|
["person_type", ""], // 人员类型
|
|
["schedule_type", 1], // 课程安排类型:1-临时课,2-固定课
|
|
["course_type", 1], // 课程类型:1-加课,2-补课,3-等待位
|
|
["remarks", ""] // 备注
|
|
]);
|
|
|
|
if (empty($data['schedule_id'])) {
|
|
return fail('课程安排ID不能为空');
|
|
}
|
|
|
|
if (empty($data['student_id']) && empty($data['resources_id'])) {
|
|
return fail('学员ID或资源ID不能都为空');
|
|
}
|
|
|
|
$result = (new CourseService())->addStudentToSchedule($data);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('添加成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('添加学员失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 从课程安排中移除学员
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function removeStudentFromSchedule(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["person_schedule_id", 0], // 人员课程安排关系ID
|
|
["reason", ""], // 移除原因
|
|
["remark", ""] // 备注
|
|
]);
|
|
|
|
if (empty($data['person_schedule_id'])) {
|
|
return fail('人员课程安排关系ID不能为空');
|
|
}
|
|
|
|
$result = (new CourseService())->removeStudentFromSchedule($data);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('移除成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('移除学员失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 更新学员课程状态(请假等)
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function updateStudentStatus(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->request->params([
|
|
["person_schedule_id", 0], // 人员课程安排关系ID
|
|
["status", 0], // 状态:0-待上课,1-已上课,2-请假
|
|
["remark", ""] // 备注
|
|
]);
|
|
|
|
if (empty($data['person_schedule_id'])) {
|
|
return fail('人员课程安排关系ID不能为空');
|
|
}
|
|
|
|
$result = (new CourseService())->updateStudentStatus($data);
|
|
if (!$result['code']) {
|
|
return fail($result['msg']);
|
|
}
|
|
|
|
return success('更新成功', $result['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('更新学员状态失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取教练列表
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function getCoachList(Request $request)
|
|
{
|
|
try {
|
|
$campus_id = $request->param('campus_id', 0);
|
|
$res = (new CourseService())->getCoachList($campus_id);
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success($res['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('获取教练列表失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取教务人员列表
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function getEducationList(Request $request)
|
|
{
|
|
try {
|
|
$campus_id = $request->param('campus_id', 0);
|
|
$res = (new CourseService())->getEducationList($campus_id);
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success($res['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('获取教务人员列表失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 更新学员课程信息(主教练、助教、教务)
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function updateCourseInfo(Request $request)
|
|
{
|
|
try {
|
|
$data = $request->params([
|
|
["student_course_id", 0],
|
|
["main_coach_id", 0],
|
|
["assistant_ids", ""],
|
|
["education_id", 0],
|
|
["class_id", 0] // 可选,如果需要更新班级关联
|
|
]);
|
|
|
|
if (empty($data['student_course_id'])) {
|
|
return fail('学员课程ID不能为空');
|
|
}
|
|
|
|
$res = (new CourseService())->updateCourseInfo($data);
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success('更新成功', $res['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('更新失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 检查学员班级关联情况
|
|
* @param Request $request
|
|
* @return \think\Response
|
|
*/
|
|
public function checkClassRelation(Request $request)
|
|
{
|
|
try {
|
|
$resource_id = $request->param('resource_id', '');
|
|
|
|
if (empty($resource_id)) {
|
|
return fail('资源ID不能为空');
|
|
}
|
|
|
|
$res = (new CourseService())->checkClassRelation($resource_id);
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success($res['data']);
|
|
} catch (\Exception $e) {
|
|
return fail('检查班级关联失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
}
|
|
|