From 35bb3f9f6ddce9902be2fdd3d31c67f75e03674c Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 9 Oct 2023 16:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=9B=E5=BB=BA=E8=80=85?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controller/base.go | 6 +++++ api/controller/inquiry.go | 55 +++++++++++++++++++++++++++++++++++++++ api/dto/UserDoctor.go | 39 ++++++++++++++++++++++++++- api/router/router.go | 40 ++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 api/controller/inquiry.go diff --git a/api/controller/base.go b/api/controller/base.go index 18adc42..0f9f578 100644 --- a/api/controller/base.go +++ b/api/controller/base.go @@ -11,6 +11,7 @@ type Api struct { userPatientManage // 患者管理 caseManage // 病例管理 orderPrescriptionManage // 处方管理 + inquiryManage // 问诊管理 } // SysSetting 系统设置 @@ -59,3 +60,8 @@ type caseManage struct { type orderPrescriptionManage struct { OrderPrescription // 处方列表 } + +// 问诊管理 +type inquiryManage struct { + Inquiry // 问诊管理 +} diff --git a/api/controller/inquiry.go b/api/controller/inquiry.go new file mode 100644 index 0000000..2c473dd --- /dev/null +++ b/api/controller/inquiry.go @@ -0,0 +1,55 @@ +package controller + +import ( + "github.com/gin-gonic/gin" + "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" + "hospital-admin-api/api/requests" + "hospital-admin-api/api/responses" + "hospital-admin-api/global" + "hospital-admin-api/utils" +) + +// Inquiry 问诊管理 +type Inquiry struct{} + +// GetUserDoctorPage 获取医生列表-分页 +func (r *Inquiry) GetUserDoctorPage(c *gin.Context) { + userDoctorRequest := requests.UserDoctorRequest{} + if err := c.ShouldBind(&userDoctorRequest.GetUserDoctorPage); err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 参数验证 + if err := global.Validate.Struct(userDoctorRequest.GetUserDoctorPage); err != nil { + responses.FailWithMessage(utils.Translate(err), c) + return + } + + if userDoctorRequest.GetUserDoctorPage.Page == 0 { + userDoctorRequest.GetUserDoctorPage.Page = 1 + } + + if userDoctorRequest.GetUserDoctorPage.PageSize == 0 { + userDoctorRequest.GetUserDoctorPage.PageSize = 20 + } + + userDoctorDao := dao.UserDoctorDao{} + userDoctor, total, err := userDoctorDao.GetUserDoctorPageSearch(userDoctorRequest.GetUserDoctorPage, userDoctorRequest.GetUserDoctorPage.Page, userDoctorRequest.GetUserDoctorPage.PageSize) + + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 处理返回值 + getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor) + + result := make(map[string]interface{}) + result["page"] = userDoctorRequest.GetUserDoctorPage.Page + result["page_size"] = userDoctorRequest.GetUserDoctorPage.PageSize + result["total"] = total + result["data"] = getUserDoctorPageResponses + responses.OkWithData(result, c) +} diff --git a/api/dto/UserDoctor.go b/api/dto/UserDoctor.go index 6adb4a7..a21e4ec 100644 --- a/api/dto/UserDoctor.go +++ b/api/dto/UserDoctor.go @@ -2,8 +2,10 @@ package dto import ( "fmt" + "hospital-admin-api/api/dao" "hospital-admin-api/api/model" "hospital-admin-api/utils" + "strconv" ) type UserDoctorDto struct { @@ -46,7 +48,8 @@ type UserDoctorDto struct { Mobile string `json:"mobile"` // 手机号 Age uint `json:"age"` // 年龄 Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) - RegisterMethod int `json:"register_method"` // 注册方式(1:微信小程序 ) + RegisterMethod int `json:"register_method"` // 注册方式(1:微信小程序 2:后台添加 ) + CreatedBy string `json:"created_by"` // 创建者 User *UserDto `json:"user"` // 用户 Hospital *HospitalDto `json:"hospital"` // 医院 UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情 @@ -168,6 +171,11 @@ func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto { response = response.LoadHospitalName(v.Hospital) } + // 加载创建者 + if v.User != nil { + response = response.LoadUserCreatedBy(v.User) + } + // 将转换后的结构体添加到新切片中 responses[i] = response } @@ -324,3 +332,32 @@ func (r *UserDoctorPendingDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *User } return r } + +// LoadUserCreatedBy 加载创建者 +func (r *UserDoctorDto) LoadUserCreatedBy(m *model.User) *UserDoctorDto { + if m.CreatedBy != "" { + if m.RegisterMethod == 1 { + // 注册方式-微信小程序 + r.CreatedBy = m.UserName + } else { + // 注册方式-后台添加 + userId, err := strconv.ParseInt(m.CreatedBy, 10, 64) + if err != nil { + return r + } + + // 获取用户详情 + AdminUserDao := dao.AdminUserDao{} + adminUser, err := AdminUserDao.GetAdminUserFirstById(userId) + if err != nil || adminUser == nil { + return r + } + + r.CreatedBy = adminUser.NickName + } + } else { + // 注册方式-微信小程序 + r.CreatedBy = m.UserName + } + return r +} diff --git a/api/router/router.go b/api/router/router.go index 29fc5a5..09c65b6 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -457,4 +457,44 @@ func privateRouter(r *gin.Engine, api controller.Api) { // 处方详情 prescriptionGroup.GET("/:order_prescription_id", api.OrderPrescription.GetOrderPrescription) } + + // 问诊管理 + inquiryGroup := adminGroup.Group("/inquiry") + { + // 问诊配置 + settingGroup := inquiryGroup.Group("/setting") + { + // 医生问诊配置 + doctorGroup := settingGroup.Group("/doctor") + { + // 获取开启问诊配置医生列表-分页 + doctorGroup.GET("", api.UserDoctor.GetUserDoctor) + + // 医生问诊配置详情 + doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor) + + // 修改医生问诊配置 + doctorGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor) + + // 新增医生问诊配置 + doctorGroup.POST("", api.UserDoctor.AddUserDoctor) + } + + // 系统问诊配置 + systemGroup := settingGroup.Group("/system") + { + // 获取系统问诊配置列表-分页 + systemGroup.GET("", api.UserDoctor.GetUserDoctorPage) + + // 获取系统问诊配置列表 + systemGroup.GET("/list", api.UserDoctor.GetUserDoctorPage) + + // 系统问诊配置详情 + systemGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor) + + // 修改系统问诊配置 + systemGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor) + } + } + } }