修正医生列表
This commit is contained in:
parent
13986fc43c
commit
d281d2a702
@ -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)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
// 查询总数量
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user