From 7df80196c2251617bf46a0341d25f8a7fe7acb6d Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 20 Nov 2023 16:26:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=B6=E5=BA=AD=E6=88=90=E5=91=98=E7=97=85=E6=83=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=88=97=E8=A1=A8-=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientPathographyController.php | 22 +++++++++++- app/Controller/TestController.php | 35 +------------------ app/Model/PatientPathography.php | 24 +++++++++++++ app/Request/PatientPathographyRequest.php | 5 ++- app/Services/PatientPathographyService.php | 30 ++++++++++++++++ config/routes.php | 2 +- 6 files changed, 81 insertions(+), 37 deletions(-) diff --git a/app/Controller/PatientPathographyController.php b/app/Controller/PatientPathographyController.php index ea2b7bf..46cb092 100644 --- a/app/Controller/PatientPathographyController.php +++ b/app/Controller/PatientPathographyController.php @@ -2,7 +2,6 @@ namespace App\Controller; -use App\Constants\HttpEnumCode; use App\Request\PatientPathographyRequest; use App\Services\PatientPathographyService; use Psr\Http\Message\ResponseInterface; @@ -29,4 +28,25 @@ class PatientPathographyController extends AbstractController return $this->response->json(fail()); } } + + /** + * 获取家庭成员病情记录列表-分页 + * @return ResponseInterface + */ + public function getFamilyPathographyList(): ResponseInterface + { + try { + $request = $this->container->get(PatientPathographyRequest::class); + }catch (\Throwable $e){ + return $this->response->json(fail()); + } + + $request->scene('getFamilyPathographyList')->validateResolved(); + + $PatientPathographyService = new PatientPathographyService(); + $data = $PatientPathographyService->getFamilyPathographyList(); + return $this->response->json($data); + + + } } \ No newline at end of file diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 1c227d3..6115636 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -34,6 +34,7 @@ use App\Services\OrderProductService; use App\Services\PatientOrderService; use App\Services\UserDoctorService; use App\Utils\Data; +use App\Utils\Jwt; use App\Utils\Log; use App\Utils\Mask; use Extend\Alibaba\Oss; @@ -463,39 +464,5 @@ class TestController extends AbstractController public function test_17(){ - $re = \Hyperf\Context\ApplicationContext::getContainer()->get(CacheInterface::class); - $a = $re->set("wucongxing","1",100); - dump($a); - $b = $re->get("wucongxing"); - dump($b); - - $redis = \Hyperf\Context\ApplicationContext::getContainer()->get(Redis::class); - $c = $redis->get("wucongxing"); - dump($c); - - -// -// $weChat = new Wechat(1); -// -// $env_version = "release"; -// $app_env = \Hyperf\Support\env("APP_ENV",'dev'); -// if ($app_env == "dev"){ -// $env_version = "trial"; -// } -// -// $options = [ -// "scene" => "?doctor_id=516900370252341248",// query 参数 -// "page" => "pages/expertDetail/expertDetail", -// "check_path" => false, -// "env_version" => $env_version, -// ]; -// -// $img_buffer = $weChat->getUnlimitedQRCode($options); -// -// $oss = new Oss(); -// -// $filename = "applet/doctor/card/516900370252341248.jpg"; -// -// $oss->putObject($filename, $img_buffer); } } \ No newline at end of file diff --git a/app/Model/PatientPathography.php b/app/Model/PatientPathography.php index 79f31a2..a4caffe 100644 --- a/app/Model/PatientPathography.php +++ b/app/Model/PatientPathography.php @@ -120,4 +120,28 @@ class PatientPathography extends Model { return self::where($params)->update($data); } + + /** + * 获取家庭成员病情记录列表-分页 + * @param array $params + * @param array $fields + * @param int|null $page + * @param int|null $per_page + * @return array + */ + public static function getPatientPathographyPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $result = self::where($params) + ->orderBy("created_at",'desc') + ->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $result->currentPage();// 当前页码 + $data['total'] = $result->total();// 数据总数 + $data['data'] = $result->items();// 数据 + $data['per_page'] = $result->perPage();// 每页个数 + $data['last_page'] = $result->lastPage();// 最后一页 + + return $data; + } } diff --git a/app/Request/PatientPathographyRequest.php b/app/Request/PatientPathographyRequest.php index 7ba440b..41cc22c 100644 --- a/app/Request/PatientPathographyRequest.php +++ b/app/Request/PatientPathographyRequest.php @@ -8,7 +8,10 @@ use Hyperf\Validation\Request\FormRequest; class PatientPathographyRequest extends FormRequest { protected array $scenes = [ - 'existFamilyPathography' => [ // 获取患者优惠卷列表 + 'existFamilyPathography' => [ // 检测家庭成员是否存在病情记录 + 'family_id', + ], + 'getFamilyPathographyList' => [ // 获取家庭成员病情记录列表-分页 'family_id', ], ]; diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index b61dcbb..41a313e 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -2,6 +2,8 @@ namespace App\Services; +use App\Constants\HttpEnumCode; +use App\Model\OrderProduct; use App\Model\PatientPathography; /** @@ -33,4 +35,32 @@ class PatientPathographyService extends BaseService return success($result); } + + /** + * 获取家庭成员病情记录列表-分页 + * @return array + */ + public function getFamilyPathographyList(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $family_id = $this->request->input('family_id'); + $page = $this->request->input('page', 1); + $per_page = $this->request->input('per_page', 10); + + // 获取病情记录列表 + $fields = [ + "pathography_id", + "created_at", + "disease_class_name", + "disease_desc" + ]; + + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['family_id'] = $family_id; + $patient_pathographys = PatientPathography::getPatientPathographyPage($params, $fields, $page, $per_page); + + return success($patient_pathographys); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index ad9aa58..00ffcd3 100644 --- a/config/routes.php +++ b/config/routes.php @@ -388,7 +388,7 @@ Router::addGroup('/patient', function () { Router::get('/exist', [PatientPathographyController::class, 'existFamilyPathography']); // 获取家庭成员病情记录列表-分页 - Router::get('/{family_id:\d+}', [PatientPathographyController::class, 'existFamilyPathography']); + Router::get('', [PatientPathographyController::class, 'getFamilyPathographyList']); }); });