120 lines
3.2 KiB
PHP
120 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Schools;
|
|
|
|
use App\Http\Controllers\BaseController;
|
|
use App\Http\Requests\Admin\Schools\SchoolCampusRequest;
|
|
use App\Services\Schools\SchoolCampusService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* 校区控制器
|
|
*/
|
|
class SchoolCampusController extends BaseController
|
|
{
|
|
public function __construct(
|
|
private SchoolCampusService $schoolCampusService
|
|
) {}
|
|
|
|
/**
|
|
* 获取校区列表
|
|
*/
|
|
public function list(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->getList($params);
|
|
|
|
return $this->SuccessPage($result->items(), $result->total());
|
|
}
|
|
|
|
/**
|
|
* 获取简单列表
|
|
*/
|
|
public function simpleList(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->getSimpleList($params['school_id'] ?? null);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 获取校区详情
|
|
*/
|
|
public function detail(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->detail($params['id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 创建校区
|
|
*/
|
|
public function create(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$data = $request->validated();
|
|
$result = $this->schoolCampusService->create($data);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 更新校区
|
|
*/
|
|
public function update(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->update($params['id'], $params);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 删除校区
|
|
*/
|
|
public function delete(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$this->schoolCampusService->delete($params['id']);
|
|
return $this->Success();
|
|
}
|
|
|
|
/**
|
|
* 批量删除校区
|
|
*/
|
|
public function batchDelete(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$this->schoolCampusService->batchDelete($params['ids']);
|
|
return $this->Success();
|
|
}
|
|
|
|
/**
|
|
* 获取用户管理的校区列表
|
|
*/
|
|
public function userCampuses(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$userId = $request->user()->id;
|
|
$result = $this->schoolCampusService->getUserCampuses($userId);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 获取校区的班级列表
|
|
*/
|
|
public function classes(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->getCampusClasses($params['id']);
|
|
return $this->Success($result);
|
|
}
|
|
|
|
/**
|
|
* 获取校区统计信息
|
|
*/
|
|
public function stats(SchoolCampusRequest $request): JsonResponse
|
|
{
|
|
$params = $request->validated();
|
|
$result = $this->schoolCampusService->getCampusStats($params['id']);
|
|
return $this->Success($result);
|
|
}
|
|
}
|