From 822756c39c4f6876e4e0c776c62388c4a47e13b4 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 26 Jul 2023 16:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=90=88?= =?UTF-8?q?=E4=BD=9C=E5=85=AC=E5=8F=B8=E6=A3=80=E6=B5=8B=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=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 | 13 +++++++++ app/Services/DetectionService.php | 40 ++++++++++++++++++++++---- config/routes.php | 3 ++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/Controller/DetectionController.php b/app/Controller/DetectionController.php index b0f990c..20a3644 100644 --- a/app/Controller/DetectionController.php +++ b/app/Controller/DetectionController.php @@ -25,4 +25,17 @@ class DetectionController extends AbstractController $data = $detectionService->getDetectionProjectList(); return $this->response->json($data); } + + /** + * 获取合作公司检测项目 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDetectionProject(): ResponseInterface + { + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionProject(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php index 282c4f0..2556027 100644 --- a/app/Services/DetectionService.php +++ b/app/Services/DetectionService.php @@ -13,9 +13,7 @@ class DetectionService extends BaseService */ public function getDetectionProjectList(): array { - $user_info = $this->request->getAttribute("userInfo") ?? []; $company_id = $this->request->input("company_id",1); -// $detection_project_id = $this->request->input("detection_project_id",1); // 获取合作公司数据 $params = array(); @@ -28,14 +26,44 @@ class DetectionService extends BaseService // 获取项目数据 $params = array(); $params['company_id'] = $company_id; - $detection_project = DetectionProject::getList($params); + $detection_projects = DetectionProject::getList($params); + if (empty($detection_projects)){ + return fail(); + } + + foreach ($detection_projects as &$value){ + $value['img_path'] = addAliyunOssWebsite($value['img_path']); + } + + return success($detection_projects->toArray()); + } + + /** + * 获取合作公司检测项目 + * @return array + */ + public function getDetectionProject(): array + { + $company_id = $this->request->input("company_id",1); + $detection_project_id = $this->request->route('detection_project_id',1); + + // 获取合作公司数据 + $params = array(); + $params['company_id'] = $company_id; + $basic_company = BasicCompany::getOne($params); + if (empty($basic_company)){ + return fail(); + } + + // 获取项目数据 + $params = array(); + $params['detection_project_id'] = $detection_project_id; + $detection_project = DetectionProject::getOne($params); if (empty($detection_project)){ return fail(); } - foreach ($detection_project as &$value){ - $value['img_path'] = addAliyunOssWebsite($value['img_path']); - } + $detection_project['img_path'] = addAliyunOssWebsite($detection_project['img_path']); return success($detection_project->toArray()); } diff --git a/config/routes.php b/config/routes.php index 32163a4..659cb03 100644 --- a/config/routes.php +++ b/config/routes.php @@ -276,6 +276,9 @@ Router::addGroup('/patient', function () { // 获取合作公司检测项目列表 Router::get('/project', [DetectionController::class, 'getDetectionProjectList']); + + // 获取合作公司检测项目列表 + Router::get('/project/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']); }); // 医生数据