From 65a5f6bc4d5daaeed4bf817d481c0bbf0848ef91 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 20 Nov 2023 15:35:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PatientFamilyController.php | 12 +------ .../PatientPathographyController.php | 32 +++++++++++++++++ app/Request/PatientPathographyRequest.php | 13 +++---- app/Services/PatientFamilyService.php | 23 ------------ app/Services/PatientPathographyService.php | 36 +++++++++++++++++++ config/routes.php | 7 ++-- 6 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 app/Controller/PatientPathographyController.php create mode 100644 app/Services/PatientPathographyService.php diff --git a/app/Controller/PatientFamilyController.php b/app/Controller/PatientFamilyController.php index ec83eb2..443da1b 100644 --- a/app/Controller/PatientFamilyController.php +++ b/app/Controller/PatientFamilyController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Constants\HttpEnumCode; use App\Request\PatientFamilyRequest; use App\Services\PatientFamilyService; +use App\Services\PatientPathographyService; use GuzzleHttp\Exception\GuzzleException; use Hyperf\Validation\Contract\ValidatorFactoryInterface; use Psr\Container\ContainerExceptionInterface; @@ -250,15 +251,4 @@ class PatientFamilyController extends AbstractController $data = $patientFamilyService->getFamilyCase(); return $this->response->json($data); } - - /** - * 检测家庭成员是否存在病情记录 - * @return ResponseInterface - */ - public function existFamilyPathography(): ResponseInterface - { - $patientFamilyService = new PatientFamilyService(); - $data = $patientFamilyService->existFamilyPathography(); - return $this->response->json($data); - } } \ No newline at end of file diff --git a/app/Controller/PatientPathographyController.php b/app/Controller/PatientPathographyController.php new file mode 100644 index 0000000..ea2b7bf --- /dev/null +++ b/app/Controller/PatientPathographyController.php @@ -0,0 +1,32 @@ +container->get(PatientPathographyRequest::class); + $request->scene('existFamilyPathography')->validateResolved(); + + $PatientPathographyService = new PatientPathographyService(); + $data = $PatientPathographyService->existFamilyPathography(); + return $this->response->json($data); + }catch (\Throwable $e){ + return $this->response->json(fail()); + } + } +} \ No newline at end of file diff --git a/app/Request/PatientPathographyRequest.php b/app/Request/PatientPathographyRequest.php index 8433af7..7ba440b 100644 --- a/app/Request/PatientPathographyRequest.php +++ b/app/Request/PatientPathographyRequest.php @@ -8,9 +8,9 @@ use Hyperf\Validation\Request\FormRequest; class PatientPathographyRequest extends FormRequest { protected array $scenes = [ -// 'existFamilyPathography' => [ // 获取患者优惠卷列表 -// 'user_coupon_status', -// ], + 'existFamilyPathography' => [ // 获取患者优惠卷列表 + 'family_id', + ], ]; /** @@ -27,9 +27,7 @@ class PatientPathographyRequest extends FormRequest public function rules(): array { return [ -// 'user_coupon_status' => 'required|numeric|min:0|max:3', -// 'product_id' => 'required', -// 'shopping_cart_num' => 'required|numeric|min:0|max:999', + 'family_id' => 'required', ]; } @@ -39,8 +37,7 @@ class PatientPathographyRequest extends FormRequest public function messages(): array { return [ -// 'user_coupon_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), -// 'user_coupon_status.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), // 'user_coupon_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), // 'user_coupon_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), // 'product_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), diff --git a/app/Services/PatientFamilyService.php b/app/Services/PatientFamilyService.php index 91abc4c..4d06ae9 100644 --- a/app/Services/PatientFamilyService.php +++ b/app/Services/PatientFamilyService.php @@ -1044,28 +1044,5 @@ class PatientFamilyService extends BaseService return success($result); } - /** - * 检测家庭成员是否存在病情记录 - * @return array - */ - public function existFamilyPathography(): array - { - $user_info = $this->request->getAttribute("userInfo") ?? []; - $family_id = $this->request->route('family_id'); - $result = array(); - $result['is_exist'] = 0; - - // 获取病情记录 - $params = array(); - $params['user_id'] = $user_info['user_id']; - $params['patient_id'] = $user_info['client_user_id']; - $params['family_id'] = $family_id; - $patient_pathography = PatientPathography::getLastOne($params); - if (!empty($patient_pathography)){ - $result['is_exist'] = 1; - } - - return success($result); - } } \ No newline at end of file diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php new file mode 100644 index 0000000..b61dcbb --- /dev/null +++ b/app/Services/PatientPathographyService.php @@ -0,0 +1,36 @@ +request->getAttribute("userInfo") ?? []; + $family_id = $this->request->input('family_id'); + + $result = array(); + $result['is_exist'] = 0; + + // 获取病情记录 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['family_id'] = $family_id; + $patient_pathography = PatientPathography::getLastOne($params); + if (!empty($patient_pathography)){ + $result['is_exist'] = 1; + } + + return success($result); + } +} \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 2d6553d..ad9aa58 100644 --- a/config/routes.php +++ b/config/routes.php @@ -25,6 +25,7 @@ use App\Controller\PatientCenterController; use App\Controller\PatientDoctorController; use App\Controller\PatientFamilyController; use App\Controller\PatientOrderController; +use App\Controller\PatientPathographyController; use App\Controller\SafeController; use App\Controller\SystemController; use App\Controller\TestController; @@ -384,10 +385,10 @@ Router::addGroup('/patient', function () { // 病情记录 Router::addGroup('/pathography', function () { // 检测家庭成员是否存在病情记录 - Router::get('/exist/{family_id:\d+}', [PatientFamilyController::class, 'existFamilyPathography']); + Router::get('/exist', [PatientPathographyController::class, 'existFamilyPathography']); -// // 获取家庭成员病情记录列表-分页 -// Router::get('/exist/{family_id:\d+}', [PatientPathographyController::class, 'existFamilyPathography']); + // 获取家庭成员病情记录列表-分页 + Router::get('/{family_id:\d+}', [PatientPathographyController::class, 'existFamilyPathography']); }); });