287 lines
17 KiB
Go
287 lines
17 KiB
Go
package v1
|
||
|
||
import (
|
||
"fmt"
|
||
"hospital-open-api/api/model"
|
||
"hospital-open-api/utils"
|
||
"strconv"
|
||
)
|
||
|
||
// UserDoctorDto 医生详情
|
||
type UserDoctorDto 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:删除)
|
||
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||
IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
Avatar string `json:"avatar"` // 头像
|
||
DoctorTitle string `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||
ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计)
|
||
PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)
|
||
AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制)
|
||
NumberOfFans uint `json:"number_of_fans"` // 被关注数量
|
||
IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是)
|
||
IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是)
|
||
IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是)
|
||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是)
|
||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||
QrCode string `json:"qr_code"` // 分享二维码
|
||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||
Mobile string `json:"mobile"` // 手机号
|
||
Age uint `json:"age"` // 年龄
|
||
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
HospitalName string `json:"hospital_name"` // 医院名称
|
||
DoctorInquiryConfig []*DoctorInquiryConfigDto `json:"doctor_inquiry_config"` // 医生问诊配置
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// MultiUserDoctorDto 多点执业医生详情
|
||
type MultiUserDoctorDto 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:删除)
|
||
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||
IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
Avatar string `json:"avatar"` // 头像
|
||
DoctorTitle string `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||
ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计)
|
||
PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)
|
||
AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制)
|
||
NumberOfFans uint `json:"number_of_fans"` // 被关注数量
|
||
IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是)
|
||
IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是)
|
||
IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是)
|
||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是)
|
||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||
QrCode string `json:"qr_code"` // 分享二维码
|
||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||
Mobile string `json:"mobile"` // 手机号
|
||
Age uint `json:"age"` // 年龄
|
||
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
HospitalName string `json:"hospital_name"` // 医院名称
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// UserDoctorPageDto 获取医生列表-分页
|
||
type UserDoctorPageDto struct {
|
||
DoctorID string `json:"doctor_id"` // 主键id
|
||
UserID string `json:"user_id"` // 用户id
|
||
UserName string `json:"user_name"` // 用户名称
|
||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
Avatar string `json:"avatar"` // 头像
|
||
DoctorTitle string `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||
ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计)
|
||
PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)
|
||
AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制)
|
||
NumberOfFans uint `json:"number_of_fans"` // 被关注数量
|
||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是)
|
||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||
QrCode string `json:"qr_code"` // 分享二维码
|
||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||
Age uint `json:"age"` // 年龄
|
||
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
HospitalName string `json:"hospital_name"` // 医院名称
|
||
HospitalLevelName string `json:"hospital_level_name"` // 医院等级
|
||
IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线)
|
||
DoctorInquiryConfig []*DoctorInquiryConfigDto `json:"doctor_inquiry_config"` // 医生问诊配置
|
||
}
|
||
|
||
// GetMultiDoctorDto 获取多点执业医生详情
|
||
func GetMultiDoctorDto(m *model.UserDoctor) *MultiUserDoctorDto {
|
||
res := &MultiUserDoctorDto{
|
||
DoctorID: strconv.Itoa(int(m.DoctorId)),
|
||
UserID: strconv.Itoa(int(m.UserId)),
|
||
UserName: m.UserName,
|
||
Status: m.Status,
|
||
IDCardStatus: m.Status,
|
||
IdenAuthStatus: m.IdenAuthStatus,
|
||
MultiPointStatus: m.MultiPointStatus,
|
||
Avatar: utils.AddOssDomain(m.Avatar),
|
||
DoctorTitle: utils.DoctorTitleToStr(m.DoctorTitle),
|
||
DepartmentCustomName: m.DepartmentCustomName,
|
||
ServedPatientsNum: m.ServedPatientsNum,
|
||
PraiseRate: m.PraiseRate,
|
||
AvgResponseTime: m.AvgResponseTime,
|
||
NumberOfFans: m.NumberOfFans,
|
||
IsImgExpertReception: m.IsImgExpertReception,
|
||
IsImgWelfareReception: m.IsImgWelfareReception,
|
||
IsImgQuickReception: m.IsImgQuickReception,
|
||
IsPlatformDeepCooperation: m.IsPlatformDeepCooperation,
|
||
IsEnterpriseDeepCooperation: m.IsEnterpriseDeepCooperation,
|
||
QrCode: utils.AddOssDomain(m.QrCode),
|
||
BeGoodAt: m.BeGoodAt,
|
||
BriefIntroduction: m.BriefIntroduction,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
|
||
return res
|
||
}
|
||
|
||
// GetDoctorDto 获取医生详情
|
||
func GetDoctorDto(m *model.UserDoctor) *UserDoctorDto {
|
||
res := &UserDoctorDto{
|
||
DoctorID: strconv.Itoa(int(m.DoctorId)),
|
||
UserID: strconv.Itoa(int(m.UserId)),
|
||
UserName: m.UserName,
|
||
Status: m.Status,
|
||
IDCardStatus: m.Status,
|
||
IdenAuthStatus: m.IdenAuthStatus,
|
||
MultiPointStatus: m.MultiPointStatus,
|
||
Avatar: utils.AddOssDomain(m.Avatar),
|
||
DoctorTitle: utils.DoctorTitleToStr(m.DoctorTitle),
|
||
DepartmentCustomName: m.DepartmentCustomName,
|
||
ServedPatientsNum: m.ServedPatientsNum,
|
||
PraiseRate: m.PraiseRate,
|
||
AvgResponseTime: m.AvgResponseTime,
|
||
NumberOfFans: m.NumberOfFans,
|
||
IsImgExpertReception: m.IsImgExpertReception,
|
||
IsImgWelfareReception: m.IsImgWelfareReception,
|
||
IsImgQuickReception: m.IsImgQuickReception,
|
||
IsPlatformDeepCooperation: m.IsPlatformDeepCooperation,
|
||
IsEnterpriseDeepCooperation: m.IsEnterpriseDeepCooperation,
|
||
QrCode: utils.AddOssDomain(m.QrCode),
|
||
BeGoodAt: m.BeGoodAt,
|
||
BriefIntroduction: m.BriefIntroduction,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
|
||
return res
|
||
}
|
||
|
||
// GetUserDoctorPageListDto 获取医生列表-分页
|
||
func GetUserDoctorPageListDto(m []*model.UserDoctor) []*UserDoctorPageDto {
|
||
// 处理返回值
|
||
responses := make([]*UserDoctorPageDto, len(m))
|
||
|
||
if len(m) > 0 {
|
||
for i, v := range m {
|
||
response := &UserDoctorPageDto{
|
||
DoctorID: fmt.Sprintf("%d", v.DoctorId),
|
||
UserID: fmt.Sprintf("%d", v.UserId),
|
||
UserName: v.UserName,
|
||
MultiPointStatus: v.MultiPointStatus,
|
||
Avatar: utils.AddOssDomain(v.Avatar),
|
||
DoctorTitle: utils.DoctorTitleToStr(v.DoctorTitle),
|
||
DepartmentCustomName: v.DepartmentCustomName,
|
||
ServedPatientsNum: v.ServedPatientsNum,
|
||
PraiseRate: v.PraiseRate,
|
||
AvgResponseTime: v.AvgResponseTime,
|
||
NumberOfFans: v.NumberOfFans,
|
||
IsPlatformDeepCooperation: v.IsPlatformDeepCooperation,
|
||
CreatedAt: v.CreatedAt,
|
||
QrCode: utils.AddOssDomain(v.QrCode),
|
||
BeGoodAt: v.BeGoodAt,
|
||
BriefIntroduction: v.BriefIntroduction,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 加载用户属性
|
||
if v.User != nil {
|
||
response = response.LoadUserAttr(v.User)
|
||
}
|
||
|
||
// 加载医院属性数据
|
||
if v.Hospital != nil {
|
||
response = response.LoadHospitalAttr(v.Hospital)
|
||
}
|
||
|
||
// 加载问诊配置数据
|
||
if v.Hospital != nil {
|
||
response = response.LoadDoctorInquiryConfig(v.DoctorInquiryConfig)
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
responses[i] = response
|
||
}
|
||
}
|
||
|
||
return responses
|
||
}
|
||
|
||
// LoadUserAttr 加载用户属性数据
|
||
func (r *UserDoctorDto) LoadUserAttr(m *model.User) *UserDoctorDto {
|
||
if m != nil {
|
||
r.Mobile = m.Mobile
|
||
r.Age = m.Age
|
||
r.Sex = m.Sex
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadHospitalName 加载医院名称
|
||
func (r *UserDoctorDto) LoadHospitalName(m *model.Hospital) *UserDoctorDto {
|
||
if m != nil {
|
||
r.HospitalName = m.HospitalName
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadDoctorInquiryConfig 加载问诊配置数据
|
||
func (r *UserDoctorDto) LoadDoctorInquiryConfig(m []*model.DoctorInquiryConfig) *UserDoctorDto {
|
||
if len(m) > 0 {
|
||
r.DoctorInquiryConfig = GetDoctorInquiryConfigListDto(m)
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadUserAttr 加载用户属性数据
|
||
func (r *MultiUserDoctorDto) LoadUserAttr(m *model.User) *MultiUserDoctorDto {
|
||
if m != nil {
|
||
r.Mobile = m.Mobile
|
||
r.Age = m.Age
|
||
r.Sex = m.Sex
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadHospitalName 加载医院名称
|
||
func (r *MultiUserDoctorDto) LoadHospitalName(m *model.Hospital) *MultiUserDoctorDto {
|
||
if m != nil {
|
||
r.HospitalName = m.HospitalName
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadUserAttr 加载用户属性数据
|
||
func (r *UserDoctorPageDto) LoadUserAttr(m *model.User) *UserDoctorPageDto {
|
||
if m != nil {
|
||
r.Age = m.Age
|
||
r.Sex = m.Sex
|
||
r.IsOnline = m.IsOnline
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadHospitalAttr 加载医院属性数据
|
||
func (r *UserDoctorPageDto) LoadHospitalAttr(m *model.Hospital) *UserDoctorPageDto {
|
||
if m != nil {
|
||
r.HospitalName = m.HospitalName
|
||
r.HospitalLevelName = m.HospitalLevelName
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadDoctorInquiryConfig 加载问诊配置数据
|
||
func (r *UserDoctorPageDto) LoadDoctorInquiryConfig(m []*model.DoctorInquiryConfig) *UserDoctorPageDto {
|
||
if len(m) > 0 {
|
||
r.DoctorInquiryConfig = GetDoctorInquiryConfigListDto(m)
|
||
}
|
||
return r
|
||
}
|