From 45d14e44c3eb6aad6a743da1a18737b0440e80db Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 15 Sep 2023 17:21:11 +0800 Subject: [PATCH] 1 --- api/controller/userPatient.go | 28 ++++++++++++++++++++++++++++ api/router/router.go | 2 +- api/service/userPatient.go | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 api/service/userPatient.go diff --git a/api/controller/userPatient.go b/api/controller/userPatient.go index 3e78e14..7bdc995 100644 --- a/api/controller/userPatient.go +++ b/api/controller/userPatient.go @@ -6,8 +6,10 @@ import ( "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" "hospital-admin-api/api/responses/userPatientResponse" + "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" + "strconv" ) type UserPatient struct{} @@ -52,3 +54,29 @@ func (r *UserPatient) GetUserPatientPage(c *gin.Context) { result["data"] = getUserDoctorPageResponses responses.OkWithData(result, c) } + +// GetUserPatient 患者详情 +func (r *UserPatient) GetUserPatient(c *gin.Context) { + id := c.Param("patient_id") + if id == "" { + responses.FailWithMessage("缺少参数", c) + return + } + + // 将 id 转换为 int64 类型 + patientId, err := strconv.ParseInt(id, 10, 64) + if err != nil { + responses.Fail(c) + return + } + + // 业务处理 + userDoctorService := service.UserDoctorService{} + getUserDoctorResponses, err := userDoctorService.GetUserDoctor(patientId) + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + responses.OkWithData(getUserDoctorResponses, c) +} diff --git a/api/router/router.go b/api/router/router.go index 34a31d3..6950a0f 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -419,7 +419,7 @@ func privateRouter(r *gin.Engine, api controller.Api) { patientGroup.GET("", api.UserPatient.GetUserPatientPage) // 患者详情 - patientGroup.GET("/:patient_id", api.UserDoctor.GetUserDoctor) + patientGroup.GET("/:patient_id", api.UserPatient.GetUserPatient) // 修改患者状态 patientGroup.PUT("/status/:patient_id", api.UserDoctor.GetUserDoctor) diff --git a/api/service/userPatient.go b/api/service/userPatient.go new file mode 100644 index 0000000..b3ee75c --- /dev/null +++ b/api/service/userPatient.go @@ -0,0 +1,4 @@ +package service + +type UserPatientService struct { +}