香洲二院小程序
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.
mini_xzey/app/Http/Controllers/Registration/ScheduleController.php

69 lines
2.0 KiB

<?php
declare(strict_types = 1);
namespace App\Http\Controllers\Registration;
use App\Exceptions\GeneralException;
use App\Http\Logics\Registration\ScheduleLogic;
use App\Http\Resources\Registration\Schedule\DeptListsResource;
use App\Http\Resources\Registration\Schedule\DoctorListsResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ScheduleController
{
protected ScheduleLogic $schedule_logic;
/**
* Patient Construct.
*/
public function __construct()
{
$this->schedule_logic = new ScheduleLogic();
}
/**
* 获取科室列表
* @param Request $request
* @return JsonResponse
* @throws GeneralException
*/
public function dept(Request $request): JsonResponse
{
$validated = $request->validate([
'date' => 'required|date_format:Y-m-d',
],[
'date.required' => '请传入日期',
'date.date_format' => '日期格式错误',
]);
$response = $this->schedule_logic->getDeptLists($validated['date']);
return jsonResponse(Response::HTTP_OK, 'success', DeptListsResource::make($response)->toArray());
}
/**
* 获取医生排班列表
* @param Request $request
* @return JsonResponse
* @throws GeneralException
*/
public function doctor(Request $request): JsonResponse
{
$validated = $request->validate([
'date' => 'required|date_format:Y-m-d',
'dept_id' => 'required|numeric'
], [
'date.required' => '请传入日期',
'date.date_format' => '日期格式错误',
'dept_id.required' => '请传入科室ID',
'dept_id.numeric' => '科室ID格式错误',
]);
$response = $this->schedule_logic->getDoctorLists($validated['date'], $validated['dept_id']);
return jsonResponse(Response::HTTP_OK, 'success', DoctorListsResource::make($response)->toArray());
}
}