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.
269 lines
7.4 KiB
269 lines
7.4 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\course_schedule;
|
|
|
|
use core\base\BaseAdminController;
|
|
use app\service\admin\course_schedule\CourseScheduleService;
|
|
|
|
|
|
/**
|
|
* 课程安排控制器
|
|
* Class CourseSchedule
|
|
* @package app\adminapi\controller\course_schedule
|
|
*/
|
|
class CourseSchedule extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取课程安排列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists()
|
|
{
|
|
$data = $this->request->params([
|
|
["campus_id", ""],
|
|
["venue_id", ""],
|
|
["course_date", ""],
|
|
["time_slot", ""],
|
|
["course_id", ""],
|
|
["coach_id", ""],
|
|
["participants", ""],
|
|
["student_ids", ""],
|
|
["available_capacity", ""],
|
|
["status", ""]
|
|
]);
|
|
return success((new CourseScheduleService())->getPage($data));
|
|
}
|
|
|
|
/**
|
|
* 课程安排详情
|
|
* @param mixed $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info($id)
|
|
{
|
|
// 确保 $id 是整数类型
|
|
$id = intval($id);
|
|
return success((new CourseScheduleService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加课程安排
|
|
* @return \think\Response
|
|
*/
|
|
public function add()
|
|
{
|
|
$data = $this->request->params([
|
|
["campus_id", 0],
|
|
["venue_id", 0],
|
|
["course_date", "2025-05-16 17:28:06"],
|
|
["time_slot", ""],
|
|
["course_id", 0],
|
|
["coach_id", 0],
|
|
["participants", ""],
|
|
["student_ids", ""],
|
|
["available_capacity", 0],
|
|
["status", ""],
|
|
['auto_schedule', 1]
|
|
]);
|
|
$this->validate($data, 'app\validate\course_schedule\CourseSchedule.add');
|
|
$id = (new CourseScheduleService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 课程安排编辑
|
|
* @param $id 课程安排id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id)
|
|
{
|
|
$data = $this->request->params([
|
|
["campus_id", 0],
|
|
["venue_id", 0],
|
|
["course_date", "2025-05-16 17:28:06"],
|
|
["time_slot", ""],
|
|
["course_id", 0],
|
|
["coach_id", 0],
|
|
["participants", ""],
|
|
["student_ids", ""],
|
|
["available_capacity", 0],
|
|
["status", ""],
|
|
['auto_schedule', 1]
|
|
]);
|
|
$this->validate($data, 'app\validate\course_schedule\CourseSchedule.edit');
|
|
(new CourseScheduleService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 课程安排删除
|
|
* @param $id 课程安排id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id)
|
|
{
|
|
(new CourseScheduleService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 获取课程表数据
|
|
* @return \think\Response
|
|
*/
|
|
public function timetables()
|
|
{
|
|
$data = $this->request->params([
|
|
["start_date", ""],
|
|
["end_date", ""],
|
|
["campus_id", ""],
|
|
["venue_id", ""]
|
|
]);
|
|
return success((new CourseScheduleService())->getTimetables($data));
|
|
}
|
|
|
|
public function getCampusVenue()
|
|
{
|
|
$data = $this->request->params([
|
|
["campus_id", ""],
|
|
]);
|
|
return success((new CourseScheduleService())->getCampusVenue($data));
|
|
}
|
|
|
|
public function scheduleList(){
|
|
$data = $this->request->params([
|
|
["schedule_id",'']
|
|
]);
|
|
return success((new CourseScheduleService())->schedule_list($data));
|
|
}
|
|
|
|
|
|
public function resourceList(){
|
|
return success((new CourseScheduleService())->resourceList());
|
|
}
|
|
|
|
public function courseInfo(){
|
|
$data = $this->request->params([
|
|
["id",'']
|
|
]);
|
|
return success((new CourseScheduleService())->courseInfo($data['id']));
|
|
}
|
|
|
|
/**
|
|
* 获取完整课程安排详情(复用移动端逻辑)
|
|
* @return \think\Response
|
|
*/
|
|
public function getScheduleDetail()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0]
|
|
]);
|
|
|
|
// 复用API端的服务层逻辑
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->getScheduleDetail($data));
|
|
}
|
|
|
|
/**
|
|
* 智能搜索学员
|
|
* @return \think\Response
|
|
*/
|
|
public function searchStudents()
|
|
{
|
|
$data = $this->request->params([
|
|
['phone_number', ''],
|
|
['name', ''],
|
|
['campus_id', 0]
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->searchStudents($data));
|
|
}
|
|
|
|
/**
|
|
* 删除学员/请假处理
|
|
* @return \think\Response
|
|
*/
|
|
public function removeStudent()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0],
|
|
['person_id', 0],
|
|
['person_type', ''],
|
|
['reason', '']
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->removeStudent($data));
|
|
}
|
|
|
|
/**
|
|
* 添加学员到课程安排
|
|
* @return \think\Response
|
|
*/
|
|
public function addSchedule()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0],
|
|
['person_type', ''],
|
|
['schedule_type', 2], // 默认等待位
|
|
['student_id', 0],
|
|
['resources_id', 0],
|
|
['course_date', ''],
|
|
['time_slot', '']
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->addStudentToSchedule($data));
|
|
}
|
|
|
|
/**
|
|
* 学员升级(等待位→正式位)
|
|
* @return \think\Response
|
|
*/
|
|
public function upgradeStudent()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0],
|
|
['person_id', 0],
|
|
['from_type', 2], // 从等待位
|
|
['to_type', 1] // 到正式位
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->upgradeStudent($data));
|
|
}
|
|
|
|
/**
|
|
* 更新学员签到状态
|
|
* @return \think\Response
|
|
*/
|
|
public function updateStudentStatus()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0],
|
|
['person_id', 0],
|
|
['status', 0],
|
|
['reason', '']
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->updateStudentStatus($data));
|
|
}
|
|
|
|
/**
|
|
* 恢复学员(取消请假)
|
|
* @return \think\Response
|
|
*/
|
|
public function restoreStudent()
|
|
{
|
|
$data = $this->request->params([
|
|
['schedule_id', 0],
|
|
['person_id', 0]
|
|
]);
|
|
|
|
return success((new \app\service\api\apiService\CourseScheduleService())->restoreStudent($data));
|
|
}
|
|
}
|
|
|