From b3d05760134b741f64d14609ae86b85c7b7690b1 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 27 Jul 2023 16:34:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E9=A1=B9=E7=9B=AE=E7=94=A8=E9=80=94=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/DetectionController.php | 27 +++++++--- app/Model/DetectionProjectPurpose.php | 74 ++++++++++++++++++++++++++ app/Request/DetectionRequest.php | 10 ++-- app/Services/DetectionService.php | 20 +++++++ config/routes.php | 16 ++++-- 5 files changed, 129 insertions(+), 18 deletions(-) create mode 100644 app/Model/DetectionProjectPurpose.php diff --git a/app/Controller/DetectionController.php b/app/Controller/DetectionController.php index ce55016..a9ebedc 100644 --- a/app/Controller/DetectionController.php +++ b/app/Controller/DetectionController.php @@ -13,14 +13,9 @@ class DetectionController extends AbstractController /** * 获取合作公司检测项目列表 * @return ResponseInterface - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function getDetectionProjectList(): ResponseInterface { - $request = $this->container->get(DetectionRequest::class); - $request->scene('getDetectionProjectList')->validateResolved(); - $detectionService = new DetectionService(); $data = $detectionService->getDetectionProjectList(); return $this->response->json($data); @@ -40,13 +35,29 @@ class DetectionController extends AbstractController /** * 获取检测机构合作医生列表 * @return ResponseInterface - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function getDetectionDoctorList(): ResponseInterface { + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionDoctorList(); + return $this->response->json($data); + } + + /** + * 获取检测项目用途列表 + * @return ResponseInterface + */ + public function getDetectionProjectPurposeList(): ResponseInterface + { + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionProjectPurposeList(); + return $this->response->json($data); + } + + // 创建检测订单 + public function addDetectionOrder(){ $request = $this->container->get(DetectionRequest::class); - $request->scene('getDetectionDoctorList')->validateResolved(); + $request->scene('addDetectionOrder')->validateResolved(); $detectionService = new DetectionService(); $data = $detectionService->getDetectionDoctorList(); diff --git a/app/Model/DetectionProjectPurpose.php b/app/Model/DetectionProjectPurpose.php new file mode 100644 index 0000000..1045708 --- /dev/null +++ b/app/Model/DetectionProjectPurpose.php @@ -0,0 +1,74 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|DetectionProjectPurpose + */ + public static function addDetectionProjectPurpose(array $data): \Hyperf\Database\Model\Model|DetectionProjectPurpose + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editDetectionProjectPurpose(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Request/DetectionRequest.php b/app/Request/DetectionRequest.php index db33471..2a4b8e8 100644 --- a/app/Request/DetectionRequest.php +++ b/app/Request/DetectionRequest.php @@ -10,11 +10,12 @@ use Hyperf\Validation\Request\FormRequest; class DetectionRequest extends FormRequest { protected array $scenes = [ - 'getDetectionProjectList' => [ // 获取合作公司检测项目列表 - 'company_id', - ], - 'getDetectionDoctorList' => [ // 获取检测机构合作医生列表 + 'addDetectionOrder' => [ // 创建检测订单 'company_id', + 'patient_id', + 'family_id', + 'nation_id', + 'detection_disease_class_ids', ], ]; @@ -32,7 +33,6 @@ class DetectionRequest extends FormRequest public function rules(): array { return [ - 'company_id' => 'required', 'detection_project_id' => 'required', ]; } diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php index 322e3a3..6752838 100644 --- a/app/Services/DetectionService.php +++ b/app/Services/DetectionService.php @@ -5,6 +5,7 @@ namespace App\Services; use App\Model\Area; use App\Model\BasicCompany; use App\Model\DetectionProject; +use App\Model\DetectionProjectPurpose; use App\Model\UserDoctor; use App\Model\UserLocation; @@ -237,4 +238,23 @@ class DetectionService extends BaseService return success($response_data); } + + /** + * 获取检测项目用途列表 + * @return array + */ + public function getDetectionProjectPurposeList(): array + { + $detection_project_id = $this->request->input("detection_project_id",1); + + // 获取项目数据 + $params = array(); + $params['detection_project_id'] = $detection_project_id; + $detection_project_purpose = DetectionProjectPurpose::getList($params); + if (empty($detection_project_purpose)){ + return fail(); + } + + return success($detection_project_purpose->toArray()); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index dc9c6ab..5e5e2fa 100644 --- a/config/routes.php +++ b/config/routes.php @@ -269,16 +269,22 @@ Router::addGroup('/patient', function () { // 检测 Router::addGroup('/detection', function () { // 创建检测订单 - Router::post('', [InquiryController::class, 'addDetectionOrder']); + Router::post('', [DetectionController::class, 'addDetectionOrder']); // 获取检测机构合作医生列表 Router::get('/doctor', [DetectionController::class, 'getDetectionDoctorList']); - // 获取合作公司检测项目列表 - Router::get('/project', [DetectionController::class, 'getDetectionProjectList']); + // 检测项目 + Router::addGroup('/project', function () { + // 获取合作公司检测项目列表 + Router::get('', [DetectionController::class, 'getDetectionProjectList']); - // 获取合作公司检测项目详情 - Router::get('/project/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']); + // 获取合作公司检测项目详情 + Router::get('/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']); + + // 获取检测项目用途列表 + Router::get('/purpose', [DetectionController::class, 'getDetectionProjectPurposeList']); + }); }); // 医生数据