修正医生列表

This commit is contained in:
wucongxing 2023-10-13 15:28:31 +08:00
parent 13986fc43c
commit d281d2a702
4 changed files with 139 additions and 78 deletions

View File

@ -16,28 +16,28 @@ type UserDoctor struct{}
// GetUserDoctorPage 获取医生列表-分页 // GetUserDoctorPage 获取医生列表-分页
func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) { func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) {
userDoctorRequest := requests.UserDoctorRequest{} req := requests.UserDoctorRequest{}
if err := c.ShouldBind(&userDoctorRequest.GetUserDoctorPage); err != nil { if err := c.ShouldBind(&req.GetUserDoctorPage); err != nil {
responses.FailWithMessage(err.Error(), c) responses.FailWithMessage(err.Error(), c)
return 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) responses.FailWithMessage(utils.Translate(err), c)
return return
} }
if userDoctorRequest.GetUserDoctorPage.Page == 0 { if req.GetUserDoctorPage.Page == 0 {
userDoctorRequest.GetUserDoctorPage.Page = 1 req.GetUserDoctorPage.Page = 1
} }
if userDoctorRequest.GetUserDoctorPage.PageSize == 0 { if req.GetUserDoctorPage.PageSize == 0 {
userDoctorRequest.GetUserDoctorPage.PageSize = 20 req.GetUserDoctorPage.PageSize = 20
} }
userDoctorDao := dao.UserDoctorDao{} 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 { if err != nil {
responses.FailWithMessage(err.Error(), c) responses.FailWithMessage(err.Error(), c)
@ -48,8 +48,8 @@ func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) {
getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor) getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor)
result := make(map[string]interface{}) result := make(map[string]interface{})
result["page"] = userDoctorRequest.GetUserDoctorPage.Page result["page"] = req.GetUserDoctorPage.Page
result["page_size"] = userDoctorRequest.GetUserDoctorPage.PageSize result["page_size"] = req.GetUserDoctorPage.PageSize
result["total"] = total result["total"] = total
result["data"] = getUserDoctorPageResponses result["data"] = getUserDoctorPageResponses
responses.OkWithData(result, c) responses.OkWithData(result, c)

View File

@ -75,7 +75,7 @@ func (r *UserDoctorDao) GetUserDoctorList(maps interface{}) (m []*model.UserDoct
} }
// GetUserDoctorPageSearch 获取医生列表-分页 // 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 var totalRecords int64
// 构建查询条件 // 构建查询条件
@ -91,115 +91,132 @@ func (r *UserDoctorDao) GetUserDoctorPageSearch(getUserDoctorPage requests.GetUs
return db.Select("hospital_id,hospital_name,hospital_level_name") 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{}). subQuery := global.Db.Model(&model.User{}).
Select("user_id"). Select("user_id").
Where("mobile LIKE ?", "%"+getUserDoctorPage.Mobile+"%") Where("mobile LIKE ?", "%"+req.Mobile+"%")
query = query.Where(gorm.Expr("user_id IN (?)", subQuery)) query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
} }
// 用户名称 // 用户名称
if getUserDoctorPage.UserName != "" { if req.UserName != "" {
query = query.Where("user_name LIKE ?", "%"+getUserDoctorPage.UserName+"%") query = query.Where("user_name LIKE ?", "%"+req.UserName+"%")
} }
// 状态 // 状态
if getUserDoctorPage.UserStatus != nil { if req.UserStatus != nil {
query = query.Where("status = ?", getUserDoctorPage.UserStatus) query = query.Where("status = ?", req.UserStatus)
} }
// 医院名称 // 医院名称
if getUserDoctorPage.HospitalName != "" { if req.HospitalName != "" {
subQuery := global.Db.Model(&model.Hospital{}). subQuery := global.Db.Model(&model.Hospital{}).
Select("hospital_id"). Select("hospital_id").
Where("hospital_name LIKE ?", "%"+getUserDoctorPage.HospitalName+"%") Where("hospital_name LIKE ?", "%"+req.HospitalName+"%")
query = query.Where(gorm.Expr("hospital_id IN (?)", subQuery)) query = query.Where(gorm.Expr("hospital_id IN (?)", subQuery))
} }
// 科室名称 // 科室名称
if getUserDoctorPage.DepartmentCustomName != "" { if req.DepartmentCustomName != "" {
query = query.Where("department_custom_name = ?", getUserDoctorPage.DepartmentCustomName) query = query.Where("department_custom_name = ?", req.DepartmentCustomName)
} }
// 实名认证状态 // 实名认证状态
if getUserDoctorPage.IDCardStatus != nil { if req.IDCardStatus != nil {
query = query.Where("idcard_status = ?", getUserDoctorPage.IDCardStatus) query = query.Where("idcard_status = ?", req.IDCardStatus)
} }
// 身份认证状态 // 身份认证状态
if getUserDoctorPage.IdenAuthStatus != nil { if req.IdenAuthStatus != nil {
query = query.Where("iden_auth_status = ?", getUserDoctorPage.IdenAuthStatus) query = query.Where("iden_auth_status = ?", req.IdenAuthStatus)
} }
// 医生多点执业认证状态 // 医生多点执业认证状态
if getUserDoctorPage.MultiPointStatus != nil { if req.MultiPointStatus != nil {
query = query.Where("multi_point_status = ?", getUserDoctorPage.MultiPointStatus) query = query.Where("multi_point_status = ?", req.MultiPointStatus)
} }
// 是否首页推荐 // 是否首页推荐
if getUserDoctorPage.IsRecommend != nil { if req.IsRecommend != nil {
query = query.Where("is_recommend = ?", getUserDoctorPage.IsRecommend) query = query.Where("is_recommend = ?", req.IsRecommend)
} }
if getUserDoctorPage.DoctorTitle != nil { if req.DoctorTitle != nil {
query = query.Where("doctor_title = ?", getUserDoctorPage.DoctorTitle) query = query.Where("doctor_title = ?", req.DoctorTitle)
} }
// 问诊类型 // // 问诊类型
if getUserDoctorPage.InquiryService != "" { // if req.InquiryService != "" {
result := strings.Split(getUserDoctorPage.InquiryService, ",") // result := strings.Split(req.InquiryService, ",")
if len(result) > 0 { // if len(result) > 0 {
subQuery := global.Db // subQuery := global.Db
for _, v := range result { // for _, v := range result {
if v == "1" { // if v == "1" {
subQuery = subQuery.Where("is_img_expert_reception = ?", 1) // subQuery = subQuery.Where("is_img_expert_reception = ?", 1)
} // }
//
if v == "2" { // if v == "2" {
if subQuery != nil { // if subQuery != nil {
subQuery = subQuery.Or("is_img_quick_reception = ?", 1) // subQuery = subQuery.Or("is_img_quick_reception = ?", 1)
} else { // } else {
subQuery = subQuery.Where("is_img_quick_reception = ?", 1) // subQuery = subQuery.Where("is_img_quick_reception = ?", 1)
} // }
} // }
//
if v == "3" { // if v == "3" {
if subQuery != nil { // if subQuery != nil {
subQuery = subQuery.Or("is_img_welfare_reception = ?", 1) // subQuery = subQuery.Or("is_img_welfare_reception = ?", 1)
} else { // } else {
subQuery = subQuery.Where("is_img_welfare_reception = ?", 1) // subQuery = subQuery.Where("is_img_welfare_reception = ?", 1)
} // }
} // }
//
if v == "4" { // if v == "4" {
if subQuery != nil { // if subQuery != nil {
subQuery = subQuery.Or("multi_point_status = ?", 1) // subQuery = subQuery.Or("multi_point_status = ?", 1)
} else { // } else {
subQuery = subQuery.Where("multi_point_status = ?", 1) // subQuery = subQuery.Where("multi_point_status = ?", 1)
} // }
} // }
//
} // }
query = query.Where(subQuery) // query = query.Where(subQuery)
} // }
} // }
// 排序 // 排序
query = query.Order("created_at desc") query = query.Order("created_at desc")
if getUserDoctorPage.IsEnterpriseDeepCooperation != nil { if req.IsEnterpriseDeepCooperation != nil {
query = query.Where("is_enterprise_deep_cooperation = ?", getUserDoctorPage.IsEnterpriseDeepCooperation) query = query.Where("is_enterprise_deep_cooperation = ?", req.IsEnterpriseDeepCooperation)
} }
if getUserDoctorPage.IsPlatformDeepCooperation != nil { if req.IsPlatformDeepCooperation != nil {
query = query.Where("is_platform_deep_cooperation = ?", getUserDoctorPage.IsPlatformDeepCooperation) query = query.Where("is_platform_deep_cooperation = ?", req.IsPlatformDeepCooperation)
} }
if getUserDoctorPage.IsSysDiagnoCooperation != nil { if req.IsSysDiagnoCooperation != nil {
query = query.Where("is_sys_diagno_cooperation = ?", getUserDoctorPage.IsSysDiagnoCooperation) query = query.Where("is_sys_diagno_cooperation = ?", req.IsSysDiagnoCooperation)
} }
// 查询总数量 // 查询总数量

View File

@ -6,6 +6,7 @@ import (
"hospital-admin-api/api/model" "hospital-admin-api/api/model"
"hospital-admin-api/utils" "hospital-admin-api/utils"
"strconv" "strconv"
"strings"
) )
type UserDoctorDto struct { type UserDoctorDto struct {
@ -55,6 +56,7 @@ type UserDoctorDto struct {
UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情 UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情
DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长 DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长
DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡 DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡
InquiryType string `json:"inquiry_type"` // 服务类型
} }
type UserDoctorPendingDto struct { type UserDoctorPendingDto struct {
@ -176,6 +178,13 @@ func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto {
response = response.LoadUserCreatedBy(v.User) response = response.LoadUserCreatedBy(v.User)
} }
// 加载医生服务类型
if v.User != nil {
response = response.LoadDoctorInquiryType(v.DoctorInquiryConfig)
} else {
response.InquiryType = "暂无"
}
// 将转换后的结构体添加到新切片中 // 将转换后的结构体添加到新切片中
responses[i] = response responses[i] = response
} }
@ -301,6 +310,40 @@ func (r *UserDoctorDto) LoadHospital(m *model.Hospital) *UserDoctorDto {
return r 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 加载医院 // LoadHospital 加载医院
func (r *UserDoctorPendingDto) LoadHospital(m *model.Hospital) *UserDoctorPendingDto { func (r *UserDoctorPendingDto) LoadHospital(m *model.Hospital) *UserDoctorPendingDto {
if m != nil { if m != nil {

View File

@ -48,6 +48,7 @@ type UserDoctor struct {
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户 User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院 Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院
UserDoctorInfo *UserDoctorInfo `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor_info"` // 详情 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 { func (m *UserDoctor) TableName() string {