From d7adc01b8437d29d1c628fcb92419417919e1819 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 26 Jul 2023 15:50:46 +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?=E5=88=97=E8=A1=A8=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 | 28 ++++++++++ app/Model/BasicCompany.php | 73 +++++++++++++++++++++++++ app/Model/DetectionProject.php | 76 ++++++++++++++++++++++++++ app/Request/DetectionRequest.php | 46 ++++++++++++++++ app/Services/DetectionService.php | 42 ++++++++++++++ config/routes.php | 4 ++ 6 files changed, 269 insertions(+) create mode 100644 app/Controller/DetectionController.php create mode 100644 app/Model/BasicCompany.php create mode 100644 app/Model/DetectionProject.php create mode 100644 app/Request/DetectionRequest.php create mode 100644 app/Services/DetectionService.php diff --git a/app/Controller/DetectionController.php b/app/Controller/DetectionController.php new file mode 100644 index 0000000..b0f990c --- /dev/null +++ b/app/Controller/DetectionController.php @@ -0,0 +1,28 @@ +container->get(DetectionRequest::class); + $request->scene('getDetectionProjectList')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionProjectList(); + return $this->response->json($data); + } +} \ No newline at end of file diff --git a/app/Model/BasicCompany.php b/app/Model/BasicCompany.php new file mode 100644 index 0000000..df2e14b --- /dev/null +++ b/app/Model/BasicCompany.php @@ -0,0 +1,73 @@ +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|BasicCompany + */ + public static function addBasicCompany(array $data): \Hyperf\Database\Model\Model|BasicCompany + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editBasicCompany(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/DetectionProject.php b/app/Model/DetectionProject.php new file mode 100644 index 0000000..e295e0e --- /dev/null +++ b/app/Model/DetectionProject.php @@ -0,0 +1,76 @@ +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|DetectionProject + */ + public static function addBasicCompany(array $data): \Hyperf\Database\Model\Model|DetectionProject + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editBasicCompany(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Request/DetectionRequest.php b/app/Request/DetectionRequest.php new file mode 100644 index 0000000..39d736a --- /dev/null +++ b/app/Request/DetectionRequest.php @@ -0,0 +1,46 @@ + [ // 获取合作公司检测项目列表 + 'company_id', + ], + ]; + + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return true; + } + + /** + * Get the validation rules that apply to the request. + */ + public function rules(): array + { + return [ + 'company_id' => 'required', + 'detection_project_id' => 'required', + ]; + } + + /** + * 获取已定义验证规则的错误消息. + */ + public function messages(): array + { + return [ + 'company_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + ]; + } +} diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php new file mode 100644 index 0000000..282c4f0 --- /dev/null +++ b/app/Services/DetectionService.php @@ -0,0 +1,42 @@ +request->getAttribute("userInfo") ?? []; + $company_id = $this->request->input("company_id",1); +// $detection_project_id = $this->request->input("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['company_id'] = $company_id; + $detection_project = DetectionProject::getList($params); + if (empty($detection_project)){ + return fail(); + } + + foreach ($detection_project as &$value){ + $value['img_path'] = addAliyunOssWebsite($value['img_path']); + } + + return success($detection_project->toArray()); + } +} \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 9f66210..32163a4 100644 --- a/config/routes.php +++ b/config/routes.php @@ -13,6 +13,7 @@ declare(strict_types=1); use App\Controller\AreaController; use App\Controller\BasicDataController; use App\Controller\CallBackController; +use App\Controller\DetectionController; use App\Controller\DoctorAccountController; use App\Controller\DoctorAuthController; use App\Controller\IndexController; @@ -272,6 +273,9 @@ Router::addGroup('/patient', function () { // 获取检测机构合作医生列表 Router::get('/doctor', [InquiryController::class, 'getDetectionDoctor']); + + // 获取合作公司检测项目列表 + Router::get('/project', [DetectionController::class, 'getDetectionProjectList']); }); // 医生数据