加载医生专长1

This commit is contained in:
wucongxing8150 2024-03-27 16:46:52 +08:00
parent 593ecb7db2
commit 5a7b7e0812
2 changed files with 63 additions and 33 deletions

View File

@ -89,33 +89,33 @@ type UserDoctorPendingDto struct {
// UserDoctorIntroductionDto 简介
type UserDoctorIntroductionDto struct {
DoctorID string `json:"doctor_id"` // 主键id
UserID string `json:"user_id"` // 用户id
UserName string `json:"user_name"` // 用户名称
Status int `json:"status"` // 状态0:禁用 1:正常 2:删除)
IntroductionStatus int `json:"introduction_status"` // 个人简介审核状态0:未审核 1:审核通过 2:审核中 3:审核失败)
IntroductionTime model.LocalTime `json:"introduction_time"` // 审核时间
Avatar string `json:"avatar"` // 头像
DoctorTitle int `json:"doctor_title"` // 医生职称1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
DepartmentCustomID string `json:"department_custom_id"` // 科室id-自定义
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
HospitalID string `json:"hospital_id"` // 所属医院id
HospitalName string `json:"hospital_name"` // 医院名称
Mobile string `json:"mobile"` // 手机号
Age uint `json:"age"` // 年龄
Sex int `json:"sex"` // 性别0:未知 1:男 2:女)
Email string `json:"email"` // 邮箱
RegisterMethod int `json:"register_method"` // 注册方式1:微信小程序 2:后台添加
ApplyTime model.LocalTime `json:"apply_time"` // 申请时间
BeGoodAt string `json:"be_good_at"` // 擅长
BriefIntroduction string `json:"brief_introduction"` // 医生简介
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
User *UserDto `json:"user"` // 用户
Hospital *HospitalDto `json:"hospital"` // 医院
UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情
DoctorExpertise []string `json:"doctor_expertise"` // 医生专长
DoctorID string `json:"doctor_id"` // 主键id
UserID string `json:"user_id"` // 用户id
UserName string `json:"user_name"` // 用户名称
Status int `json:"status"` // 状态0:禁用 1:正常 2:删除)
IntroductionStatus int `json:"introduction_status"` // 个人简介审核状态0:未审核 1:审核通过 2:审核中 3:审核失败)
IntroductionTime model.LocalTime `json:"introduction_time"` // 审核时间
Avatar string `json:"avatar"` // 头像
DoctorTitle int `json:"doctor_title"` // 医生职称1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
DepartmentCustomID string `json:"department_custom_id"` // 科室id-自定义
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
HospitalID string `json:"hospital_id"` // 所属医院id
HospitalName string `json:"hospital_name"` // 医院名称
Mobile string `json:"mobile"` // 手机号
Age uint `json:"age"` // 年龄
Sex int `json:"sex"` // 性别0:未知 1:男 2:女)
Email string `json:"email"` // 邮箱
RegisterMethod int `json:"register_method"` // 注册方式1:微信小程序 2:后台添加
ApplyTime model.LocalTime `json:"apply_time"` // 申请时间
BeGoodAt string `json:"be_good_at"` // 擅长
BriefIntroduction string `json:"brief_introduction"` // 医生简介
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
User *UserDto `json:"user"` // 用户
Hospital *HospitalDto `json:"hospital"` // 医院
UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情
DoctorExpertise []*DiseaseClassExpertiseDto `json:"doctor_expertise"` // 医生专长
}
func GetUserDoctorDto(m *model.UserDoctor) *UserDoctorDto {

View File

@ -1641,6 +1641,28 @@ func (r *UserDoctorService) GetUserDoctorIntroduction(doctorId int64) (g *dto.Us
}
}
var diseaseClassExpertiseDto []*dto.DiseaseClassExpertiseDto
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
if len(expertiseIds) > 0 {
for _, id := range expertiseIds {
// 将 id 转换为 int64 类型
expertiseId, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return nil, errors.New("专长数据错误")
}
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
if err != nil || diseaseClassExpertise == nil {
return nil, errors.New("专长数据错误")
}
res := dto.GetDiseaseClassExpertiseDto(diseaseClassExpertise)
diseaseClassExpertiseDto = append(diseaseClassExpertiseDto, res)
}
}
// 处理返回值
g = dto.GetUserDoctorIntroductionDto(userDoctor)
@ -1663,7 +1685,7 @@ func (r *UserDoctorService) GetUserDoctorIntroduction(doctorId int64) (g *dto.Us
g.LoadHospital(userDoctor.Hospital)
// 加载医生专长
g.DoctorExpertise = expertiseIds
g.DoctorExpertise = diseaseClassExpertiseDto
// 加载医生详情
g.LoadUserDoctorInfo(userDoctor.UserDoctorInfo)
@ -1796,15 +1818,23 @@ func (r *UserDoctorService) PutDoctorIntroduction(doctorId int64, req requests.P
// 医生专长
if doctorIntroductionRecord.ExpertiseIds != "" {
// 删除医生专长
maps = make(map[string]interface{})
maps["doctor_id"] = doctorId
err = doctorExpertiseDao.DeleteDoctorExpertise(tx, maps)
// 获取医生专长
doctorExpertises, err := doctorExpertiseDao.GetDoctorExpertiseListByDoctorId(doctorId)
if err != nil {
tx.Rollback()
return false, errors.New("审核失败")
}
if len(doctorExpertises) > 0 {
// 删除医生专长
maps = make(map[string]interface{})
maps["doctor_id"] = doctorId
err = doctorExpertiseDao.DeleteDoctorExpertise(tx, maps)
if err != nil {
tx.Rollback()
return false, errors.New("审核失败")
}
}
// 新增医生专长
expertiseIds := strings.Split(doctorIntroductionRecord.ExpertiseIds, ",")
for _, id := range expertiseIds {