From d281d2a702d78513d44055a2712f31b2a7e95a68 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 13 Oct 2023 15:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8C=BB=E7=94=9F=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controller/userDoctor.go | 20 ++--- api/dao/userDoctor.go | 147 +++++++++++++++++++---------------- api/dto/UserDoctor.go | 43 ++++++++++ api/model/userDoctor.go | 7 +- 4 files changed, 139 insertions(+), 78 deletions(-) diff --git a/api/controller/userDoctor.go b/api/controller/userDoctor.go index 1fe98ff..6747da5 100644 --- a/api/controller/userDoctor.go +++ b/api/controller/userDoctor.go @@ -16,28 +16,28 @@ type UserDoctor struct{} // GetUserDoctorPage 获取医生列表-分页 func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) { - userDoctorRequest := requests.UserDoctorRequest{} - if err := c.ShouldBind(&userDoctorRequest.GetUserDoctorPage); err != nil { + req := requests.UserDoctorRequest{} + if err := c.ShouldBind(&req.GetUserDoctorPage); err != nil { responses.FailWithMessage(err.Error(), c) return } // 参数验证 - if err := global.Validate.Struct(userDoctorRequest.GetUserDoctorPage); err != nil { + if err := global.Validate.Struct(req.GetUserDoctorPage); err != nil { responses.FailWithMessage(utils.Translate(err), c) return } - if userDoctorRequest.GetUserDoctorPage.Page == 0 { - userDoctorRequest.GetUserDoctorPage.Page = 1 + if req.GetUserDoctorPage.Page == 0 { + req.GetUserDoctorPage.Page = 1 } - if userDoctorRequest.GetUserDoctorPage.PageSize == 0 { - userDoctorRequest.GetUserDoctorPage.PageSize = 20 + if req.GetUserDoctorPage.PageSize == 0 { + req.GetUserDoctorPage.PageSize = 20 } userDoctorDao := dao.UserDoctorDao{} - userDoctor, total, err := userDoctorDao.GetUserDoctorPageSearch(userDoctorRequest.GetUserDoctorPage, userDoctorRequest.GetUserDoctorPage.Page, userDoctorRequest.GetUserDoctorPage.PageSize) + userDoctor, total, err := userDoctorDao.GetUserDoctorPageSearch(req.GetUserDoctorPage, req.GetUserDoctorPage.Page, req.GetUserDoctorPage.PageSize) if err != nil { responses.FailWithMessage(err.Error(), c) @@ -48,8 +48,8 @@ func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) { getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor) result := make(map[string]interface{}) - result["page"] = userDoctorRequest.GetUserDoctorPage.Page - result["page_size"] = userDoctorRequest.GetUserDoctorPage.PageSize + result["page"] = req.GetUserDoctorPage.Page + result["page_size"] = req.GetUserDoctorPage.PageSize result["total"] = total result["data"] = getUserDoctorPageResponses responses.OkWithData(result, c) diff --git a/api/dao/userDoctor.go b/api/dao/userDoctor.go index 62e907f..20b1019 100644 --- a/api/dao/userDoctor.go +++ b/api/dao/userDoctor.go @@ -75,7 +75,7 @@ func (r *UserDoctorDao) GetUserDoctorList(maps interface{}) (m []*model.UserDoct } // GetUserDoctorPageSearch 获取医生列表-分页 -func (r *UserDoctorDao) GetUserDoctorPageSearch(getUserDoctorPage requests.GetUserDoctorPage, page, pageSize int) (m []*model.UserDoctor, total int64, err error) { +func (r *UserDoctorDao) GetUserDoctorPageSearch(req requests.GetUserDoctorPage, page, pageSize int) (m []*model.UserDoctor, total int64, err error) { var totalRecords int64 // 构建查询条件 @@ -91,115 +91,132 @@ func (r *UserDoctorDao) GetUserDoctorPageSearch(getUserDoctorPage requests.GetUs return db.Select("hospital_id,hospital_name,hospital_level_name") }) + // 医生问诊配置 + query = query.Preload("DoctorInquiryConfig") + + // 医生问诊配置 + if req.InquiryService != "" { + result := strings.Split(req.InquiryService, ",") + if len(result) > 0 { + subQuery := global.Db.Model(&model.DoctorInquiryConfig{}). + Where("gdxz_doctor_inquiry_config.doctor_id = gdxz_user_doctor.doctor_id"). + Where("gdxz_doctor_inquiry_config.inquiry_type IN (?)", req.InquiryService). + Where("gdxz_doctor_inquiry_config.inquiry_mode = ?", 1). + Where("gdxz_doctor_inquiry_config.is_enable = ?", 1).Select("1") + + query = query.Where("EXISTS (?)", subQuery) + } + } + // 手机号 - if getUserDoctorPage.Mobile != "" { + if req.Mobile != "" { subQuery := global.Db.Model(&model.User{}). Select("user_id"). - Where("mobile LIKE ?", "%"+getUserDoctorPage.Mobile+"%") + Where("mobile LIKE ?", "%"+req.Mobile+"%") query = query.Where(gorm.Expr("user_id IN (?)", subQuery)) } // 用户名称 - if getUserDoctorPage.UserName != "" { - query = query.Where("user_name LIKE ?", "%"+getUserDoctorPage.UserName+"%") + if req.UserName != "" { + query = query.Where("user_name LIKE ?", "%"+req.UserName+"%") } // 状态 - if getUserDoctorPage.UserStatus != nil { - query = query.Where("status = ?", getUserDoctorPage.UserStatus) + if req.UserStatus != nil { + query = query.Where("status = ?", req.UserStatus) } // 医院名称 - if getUserDoctorPage.HospitalName != "" { + if req.HospitalName != "" { subQuery := global.Db.Model(&model.Hospital{}). Select("hospital_id"). - Where("hospital_name LIKE ?", "%"+getUserDoctorPage.HospitalName+"%") + Where("hospital_name LIKE ?", "%"+req.HospitalName+"%") query = query.Where(gorm.Expr("hospital_id IN (?)", subQuery)) } // 科室名称 - if getUserDoctorPage.DepartmentCustomName != "" { - query = query.Where("department_custom_name = ?", getUserDoctorPage.DepartmentCustomName) + if req.DepartmentCustomName != "" { + query = query.Where("department_custom_name = ?", req.DepartmentCustomName) } // 实名认证状态 - if getUserDoctorPage.IDCardStatus != nil { - query = query.Where("idcard_status = ?", getUserDoctorPage.IDCardStatus) + if req.IDCardStatus != nil { + query = query.Where("idcard_status = ?", req.IDCardStatus) } // 身份认证状态 - if getUserDoctorPage.IdenAuthStatus != nil { - query = query.Where("iden_auth_status = ?", getUserDoctorPage.IdenAuthStatus) + if req.IdenAuthStatus != nil { + query = query.Where("iden_auth_status = ?", req.IdenAuthStatus) } // 医生多点执业认证状态 - if getUserDoctorPage.MultiPointStatus != nil { - query = query.Where("multi_point_status = ?", getUserDoctorPage.MultiPointStatus) + if req.MultiPointStatus != nil { + query = query.Where("multi_point_status = ?", req.MultiPointStatus) } // 是否首页推荐 - if getUserDoctorPage.IsRecommend != nil { - query = query.Where("is_recommend = ?", getUserDoctorPage.IsRecommend) + if req.IsRecommend != nil { + query = query.Where("is_recommend = ?", req.IsRecommend) } - if getUserDoctorPage.DoctorTitle != nil { - query = query.Where("doctor_title = ?", getUserDoctorPage.DoctorTitle) + if req.DoctorTitle != nil { + query = query.Where("doctor_title = ?", req.DoctorTitle) } - // 问诊类型 - if getUserDoctorPage.InquiryService != "" { - result := strings.Split(getUserDoctorPage.InquiryService, ",") - if len(result) > 0 { - subQuery := global.Db - for _, v := range result { - if v == "1" { - subQuery = subQuery.Where("is_img_expert_reception = ?", 1) - } - - if v == "2" { - if subQuery != nil { - subQuery = subQuery.Or("is_img_quick_reception = ?", 1) - } else { - subQuery = subQuery.Where("is_img_quick_reception = ?", 1) - } - } - - if v == "3" { - if subQuery != nil { - subQuery = subQuery.Or("is_img_welfare_reception = ?", 1) - } else { - subQuery = subQuery.Where("is_img_welfare_reception = ?", 1) - } - } - - if v == "4" { - if subQuery != nil { - subQuery = subQuery.Or("multi_point_status = ?", 1) - } else { - subQuery = subQuery.Where("multi_point_status = ?", 1) - } - } - - } - query = query.Where(subQuery) - } - } + // // 问诊类型 + // if req.InquiryService != "" { + // result := strings.Split(req.InquiryService, ",") + // if len(result) > 0 { + // subQuery := global.Db + // for _, v := range result { + // if v == "1" { + // subQuery = subQuery.Where("is_img_expert_reception = ?", 1) + // } + // + // if v == "2" { + // if subQuery != nil { + // subQuery = subQuery.Or("is_img_quick_reception = ?", 1) + // } else { + // subQuery = subQuery.Where("is_img_quick_reception = ?", 1) + // } + // } + // + // if v == "3" { + // if subQuery != nil { + // subQuery = subQuery.Or("is_img_welfare_reception = ?", 1) + // } else { + // subQuery = subQuery.Where("is_img_welfare_reception = ?", 1) + // } + // } + // + // if v == "4" { + // if subQuery != nil { + // subQuery = subQuery.Or("multi_point_status = ?", 1) + // } else { + // subQuery = subQuery.Where("multi_point_status = ?", 1) + // } + // } + // + // } + // query = query.Where(subQuery) + // } + // } // 排序 query = query.Order("created_at desc") - if getUserDoctorPage.IsEnterpriseDeepCooperation != nil { - query = query.Where("is_enterprise_deep_cooperation = ?", getUserDoctorPage.IsEnterpriseDeepCooperation) + if req.IsEnterpriseDeepCooperation != nil { + query = query.Where("is_enterprise_deep_cooperation = ?", req.IsEnterpriseDeepCooperation) } - if getUserDoctorPage.IsPlatformDeepCooperation != nil { - query = query.Where("is_platform_deep_cooperation = ?", getUserDoctorPage.IsPlatformDeepCooperation) + if req.IsPlatformDeepCooperation != nil { + query = query.Where("is_platform_deep_cooperation = ?", req.IsPlatformDeepCooperation) } - if getUserDoctorPage.IsSysDiagnoCooperation != nil { - query = query.Where("is_sys_diagno_cooperation = ?", getUserDoctorPage.IsSysDiagnoCooperation) + if req.IsSysDiagnoCooperation != nil { + query = query.Where("is_sys_diagno_cooperation = ?", req.IsSysDiagnoCooperation) } // 查询总数量 diff --git a/api/dto/UserDoctor.go b/api/dto/UserDoctor.go index a21e4ec..a65a2e4 100644 --- a/api/dto/UserDoctor.go +++ b/api/dto/UserDoctor.go @@ -6,6 +6,7 @@ import ( "hospital-admin-api/api/model" "hospital-admin-api/utils" "strconv" + "strings" ) type UserDoctorDto struct { @@ -55,6 +56,7 @@ type UserDoctorDto struct { UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情 DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长 DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡 + InquiryType string `json:"inquiry_type"` // 服务类型 } type UserDoctorPendingDto struct { @@ -176,6 +178,13 @@ func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto { response = response.LoadUserCreatedBy(v.User) } + // 加载医生服务类型 + if v.User != nil { + response = response.LoadDoctorInquiryType(v.DoctorInquiryConfig) + } else { + response.InquiryType = "暂无" + } + // 将转换后的结构体添加到新切片中 responses[i] = response } @@ -301,6 +310,40 @@ func (r *UserDoctorDto) LoadHospital(m *model.Hospital) *UserDoctorDto { return r } +// LoadDoctorInquiryType 加载医生服务类型 +func (r *UserDoctorDto) LoadDoctorInquiryType(m []*model.DoctorInquiryConfig) *UserDoctorDto { + var inquiryTypes []string + + if len(m) > 0 { + for _, v := range m { + if v.InquiryType == 1 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "专家问诊") + } + + if v.InquiryType == 2 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "快速问诊") + } + + if v.InquiryType == 3 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "公益问诊") + } + + if v.InquiryType == 4 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "问诊购药") + } + } + } + + inquiryType := "暂无" + + if len(inquiryTypes) > 0 { + inquiryType = strings.Join(inquiryTypes, ", ") + } + + r.InquiryType = inquiryType + return r +} + // LoadHospital 加载医院 func (r *UserDoctorPendingDto) LoadHospital(m *model.Hospital) *UserDoctorPendingDto { if m != nil { diff --git a/api/model/userDoctor.go b/api/model/userDoctor.go index ac2cbc9..2fba183 100644 --- a/api/model/userDoctor.go +++ b/api/model/userDoctor.go @@ -45,9 +45,10 @@ type UserDoctor struct { BeGoodAt string `gorm:"column:be_good_at;type:text;comment:擅长" json:"be_good_at"` BriefIntroduction string `gorm:"column:brief_introduction;type:text;comment:医生简介" json:"brief_introduction"` Model - User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户 - Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院 - UserDoctorInfo *UserDoctorInfo `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor_info"` // 详情 + User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户 + Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院 + UserDoctorInfo *UserDoctorInfo `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor_info"` // 详情 + DoctorInquiryConfig []*DoctorInquiryConfig `gorm:"foreignKey:DoctorId;references:doctor_id" json:"doctor_inquiry_config"` // 问诊配置 } func (m *UserDoctor) TableName() string {