160 lines
4.5 KiB
PHP
160 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Students;
|
|
|
|
use App\Http\Controllers\BaseController;
|
|
use App\Http\Requests\Admin\Students\StudentClassRequest;
|
|
use App\Services\Students\StudentClassService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* 学生班级关联控制器
|
|
*/
|
|
class StudentClassController extends BaseController
|
|
{
|
|
public function __construct(
|
|
private StudentClassService $studentClassService
|
|
) {}
|
|
|
|
/**
|
|
* 获取学生班级关联列表
|
|
*/
|
|
public function list(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->getList($params);
|
|
|
|
return $this->SuccessPage($result->items(), $result->total());
|
|
}
|
|
|
|
/**
|
|
* 获取学生班级关联详情
|
|
*/
|
|
public function detail(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->detail($params['id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 创建学生班级关联
|
|
*/
|
|
public function create(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$data = $request->validated();
|
|
$result = $this->studentClassService->create($data);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 更新学生班级关联
|
|
*/
|
|
public function update(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->update($params['id'], $params);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 删除学生班级关联
|
|
*/
|
|
public function delete(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$this->studentClassService->delete($params['id']);
|
|
return $this->Success();
|
|
}
|
|
|
|
/**
|
|
* 批量删除学生班级关联
|
|
*/
|
|
public function batchDelete(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$this->studentClassService->batchDelete($params['ids']);
|
|
return $this->Success();
|
|
}
|
|
|
|
/**
|
|
* 获取学生的班级列表
|
|
*/
|
|
public function studentClasses(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->getStudentClasses($params['student_id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 获取班级的学生列表
|
|
*/
|
|
public function classStudents(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->getClassStudents($params['class_id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 获取学校的学生列表
|
|
*/
|
|
public function schoolStudents(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->getSchoolStudents($params['school_id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 批量分配学生到班级
|
|
*/
|
|
public function batchAssign(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->batchAssignStudentsToClass(
|
|
$params['student_ids'],
|
|
$params['class_id']
|
|
);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 批量移除学生班级关联
|
|
*/
|
|
public function batchRemove(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->batchRemoveStudentsFromClass(
|
|
$params['student_ids'],
|
|
$params['class_id']
|
|
);
|
|
return $this->Success(['removed_count' => $result]);
|
|
}
|
|
|
|
/**
|
|
* 转移学生到新班级
|
|
*/
|
|
public function transfer(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->transferStudentToClass(
|
|
$params['student_id'],
|
|
$params['old_class_id'],
|
|
$params['new_class_id']
|
|
);
|
|
return $this->Success(['transferred' => $result]);
|
|
}
|
|
|
|
/**
|
|
* 获取学生班级统计信息
|
|
*/
|
|
public function stats(StudentClassRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->studentClassService->getStudentClassStats($params['student_id']);
|
|
return $this->Success($result);
|
|
}
|
|
}
|