新增专长
This commit is contained in:
parent
1e5a26b329
commit
b7528ce40f
@ -55,8 +55,8 @@ func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) {
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetPostUserDoctor 医生详情
|
||||
func (r *UserDoctor) GetPostUserDoctor(c *gin.Context) {
|
||||
// GetUserDoctor 医生详情
|
||||
func (r *UserDoctor) GetUserDoctor(c *gin.Context) {
|
||||
id := c.Param("doctor_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
@ -70,17 +70,14 @@ func (r *UserDoctor) GetPostUserDoctor(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId)
|
||||
// 业务处理
|
||||
userDoctorService := service.UserDoctorService{}
|
||||
getUserDoctorResponses, err := userDoctorService.GetUserDoctor(doctorId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("用户数据错误", c)
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getUserDoctorResponses := userDoctorResponse.GetUserDoctorResponse(userDoctor)
|
||||
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
|
||||
|
||||
72
api/dao/diseaseClassExpertise.go
Normal file
72
api/dao/diseaseClassExpertise.go
Normal file
@ -0,0 +1,72 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DiseaseClassExpertiseDao struct {
|
||||
}
|
||||
|
||||
// GetDiseaseClassExpertiseById 获取专长-专长id
|
||||
func (r *DiseaseClassExpertiseDao) GetDiseaseClassExpertiseById(expertiseId int64) (m *model.DiseaseClassExpertise, err error) {
|
||||
err = global.Db.First(&m, expertiseId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDiseaseClassExpertise 删除专长
|
||||
func (r *DiseaseClassExpertiseDao) DeleteDiseaseClassExpertise(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DiseaseClassExpertise{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDiseaseClassExpertise 修改专长
|
||||
func (r *DiseaseClassExpertiseDao) EditDiseaseClassExpertise(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.DiseaseClassExpertise{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDiseaseClassExpertiseById 修改专长-医生id
|
||||
func (r *DiseaseClassExpertiseDao) EditDiseaseClassExpertiseById(tx *gorm.DB, expertiseId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DiseaseClassExpertise{}).Where("expertise_id = ?", expertiseId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDiseaseClassExpertiseList 获取专长列表
|
||||
func (r *DiseaseClassExpertiseDao) GetDiseaseClassExpertiseList(maps interface{}) (m []*model.DiseaseClassExpertise, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDiseaseClassExpertise 新增专长
|
||||
func (r *DiseaseClassExpertiseDao) AddDiseaseClassExpertise(tx *gorm.DB, model *model.DiseaseClassExpertise) (*model.DiseaseClassExpertise, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddDiseaseClassExpertiseByMap 新增专长-map
|
||||
func (r *DiseaseClassExpertiseDao) AddDiseaseClassExpertiseByMap(tx *gorm.DB, data map[string]interface{}) (*model.DiseaseClassExpertise, error) {
|
||||
userDoctorInfo := &model.DiseaseClassExpertise{}
|
||||
if err := tx.Model(&model.DiseaseClassExpertise{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
81
api/dao/doctorExpertise.go
Normal file
81
api/dao/doctorExpertise.go
Normal file
@ -0,0 +1,81 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorExpertiseDao struct {
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseByDoctorId 获取医生专长数据-医生id
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseByDoctorId(doctorId int64) (m *model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseListByDoctorId 获取医生专长数据列表-医生id
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseListByDoctorId(doctorId int64) (m []*model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorExpertise 删除医生专长
|
||||
func (r *DoctorExpertiseDao) DeleteDoctorExpertise(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorExpertise{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorExpertise 修改医生专长
|
||||
func (r *DoctorExpertiseDao) EditDoctorExpertise(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorExpertise{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorExpertiseById 修改医生专长-医生id
|
||||
func (r *DoctorExpertiseDao) EditDoctorExpertiseById(tx *gorm.DB, doctorId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorExpertise{}).Where("doctor_id = ?", doctorId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseList 获取医生专长列表
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseList(maps interface{}) (m []*model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertise 新增医生专长
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertise(tx *gorm.DB, model *model.DoctorExpertise) (*model.DoctorExpertise, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertiseByMap 新增医生专长-map
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertiseByMap(tx *gorm.DB, data map[string]interface{}) (*model.DoctorExpertise, error) {
|
||||
userDoctorInfo := &model.DoctorExpertise{}
|
||||
if err := tx.Model(&model.DoctorExpertise{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
13
api/model/diseaseClassExpertise.go
Normal file
13
api/model/diseaseClassExpertise.go
Normal file
@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
// DiseaseClassExpertise 疾病分类表-医生专长
|
||||
type DiseaseClassExpertise struct {
|
||||
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);primary_key;comment:主键id" json:"expertise_id"`
|
||||
ExpertiseName string `gorm:"column:expertise_name;type:varchar(255);comment:专长名称" json:"expertise_name"`
|
||||
ExpertiseSort int `gorm:"column:expertise_sort;type:int(11);default:0;comment:排序(越大排序越靠前)" json:"expertise_sort"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DiseaseClassExpertise) TableName() string {
|
||||
return "gdxz_disease_class_expertise"
|
||||
}
|
||||
13
api/model/doctorExpertise.go
Normal file
13
api/model/doctorExpertise.go
Normal file
@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
// DoctorExpertise 医生专长表
|
||||
type DoctorExpertise struct {
|
||||
DoctorExpertiseId int64 `gorm:"column:doctor_expertise_id;type:bigint(19);primary_key;comment:主键id" json:"doctor_expertise_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);comment:专长id" json:"expertise_id"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorExpertise) TableName() string {
|
||||
return "gdxz_doctor_expertise"
|
||||
}
|
||||
@ -43,6 +43,7 @@ type PutUserDoctor struct {
|
||||
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||
SignImage string `json:"sign_image" form:"sign_image" label:"签名图片"`
|
||||
DoctorExpertise []string `json:"doctor_expertise" form:"doctor_expertise" label:"专长"`
|
||||
}
|
||||
|
||||
// AddUserDoctor 新增医生
|
||||
@ -67,6 +68,7 @@ type AddUserDoctor struct {
|
||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||
SignImage string `json:"sign_image" form:"sign_image" label:"签名图片"`
|
||||
CardNum string `json:"card_num" form:"card_num" validate:"required" label:"证件号码"`
|
||||
DoctorExpertise []string `json:"doctor_expertise" form:"doctor_expertise" label:"专长"`
|
||||
}
|
||||
|
||||
// GetUserDoctorPendingPage 获取医生待审核列表-分页
|
||||
|
||||
7
api/responses/doctorExpertiseResponse/doctorExpertise.go
Normal file
7
api/responses/doctorExpertiseResponse/doctorExpertise.go
Normal file
@ -0,0 +1,7 @@
|
||||
package doctorExpertiseResponse
|
||||
|
||||
type DoctorExpertise struct {
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
ExpertiseId string `json:"expertise_id"` // 专长id
|
||||
ExpertiseName string `json:"expertise_name"` // 专长名称
|
||||
}
|
||||
@ -2,6 +2,7 @@ package userDoctorResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/responses/doctorExpertiseResponse"
|
||||
"hospital-admin-api/api/responses/hospitalResponse"
|
||||
"hospital-admin-api/api/responses/userDoctorInfoResponse"
|
||||
"hospital-admin-api/api/responses/userResponse"
|
||||
@ -46,45 +47,46 @@ type getUserDoctorPage struct {
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// getUserDoctor 医生详情
|
||||
type getUserDoctor 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:认证失败)
|
||||
IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间
|
||||
IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
||||
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
||||
IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是)
|
||||
IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是)
|
||||
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
|
||||
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"` // 被关注数量
|
||||
IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线)
|
||||
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"` // 医生简介
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
User *userResponse.User `json:"user"` // 用户
|
||||
Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院
|
||||
UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情
|
||||
// GetUserDoctor 医生详情
|
||||
type GetUserDoctor 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:认证失败)
|
||||
IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间
|
||||
IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
||||
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
||||
IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是)
|
||||
IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是)
|
||||
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
|
||||
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"` // 被关注数量
|
||||
IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线)
|
||||
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"` // 医生简介
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
User *userResponse.User `json:"user"` // 用户
|
||||
Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院
|
||||
UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情
|
||||
DoctorExpertise []*doctorExpertiseResponse.DoctorExpertise `json:"doctor_expertise"` // 医生专长
|
||||
}
|
||||
|
||||
// GetUserDoctorPageResponse 获取用户列表-分页
|
||||
@ -144,62 +146,3 @@ func GetUserDoctorPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPa
|
||||
|
||||
return getUserPageResponses
|
||||
}
|
||||
|
||||
// GetUserDoctorResponse 医生详情
|
||||
func GetUserDoctorResponse(userDoctor *model.UserDoctor) *getUserDoctor {
|
||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||
if userDoctor.UserDoctorInfo != nil {
|
||||
userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo)
|
||||
}
|
||||
|
||||
// 医院
|
||||
var hospital *hospitalResponse.Hospital
|
||||
if userDoctor.Hospital != nil {
|
||||
hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital)
|
||||
}
|
||||
|
||||
// 用户
|
||||
var user *userResponse.User
|
||||
if userDoctor.User != nil {
|
||||
user = userResponse.UserResponse(userDoctor.User)
|
||||
}
|
||||
|
||||
// 将原始结构体转换为新结构体
|
||||
return &getUserDoctor{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
IdenAuthStatus: userDoctor.IdenAuthStatus,
|
||||
IdenAuthTime: userDoctor.IdenAuthTime,
|
||||
IdenAuthFailReason: userDoctor.IdenAuthFailReason,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
MultiPointTime: userDoctor.MultiPointTime,
|
||||
MultiPointFailReason: userDoctor.MultiPointFailReason,
|
||||
IsBindBank: userDoctor.IsBindBank,
|
||||
IsRecommend: userDoctor.IsRecommend,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + userDoctor.Avatar,
|
||||
DoctorTitle: userDoctor.DoctorTitle,
|
||||
DepartmentCustomID: strconv.Itoa(int(userDoctor.DepartmentCustomId)),
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
DepartmentCustomMobile: userDoctor.DepartmentCustomMobile,
|
||||
HospitalID: strconv.Itoa(int(userDoctor.HospitalID)),
|
||||
ServedPatientsNum: userDoctor.ServedPatientsNum,
|
||||
PraiseRate: userDoctor.PraiseRate,
|
||||
AvgResponseTime: userDoctor.AvgResponseTime,
|
||||
NumberOfFans: userDoctor.NumberOfFans,
|
||||
IsImgExpertReception: userDoctor.IsImgExpertReception,
|
||||
IsImgWelfareReception: userDoctor.IsImgWelfareReception,
|
||||
IsImgQuickReception: userDoctor.IsImgQuickReception,
|
||||
IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation,
|
||||
QrCode: config.C.Oss.OssCustomDomainName + userDoctor.QrCode,
|
||||
BeGoodAt: userDoctor.BeGoodAt,
|
||||
BriefIntroduction: userDoctor.BriefIntroduction,
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
User: user,
|
||||
Hospital: hospital,
|
||||
UserDoctorInfo: userDoctorInfo,
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
doctorGroup.GET("", api.UserDoctor.GetUserDoctorPage)
|
||||
|
||||
// 医生详情
|
||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetPostUserDoctor)
|
||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||
|
||||
// 修改医生
|
||||
doctorGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor)
|
||||
@ -246,7 +246,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
doctorPendingGroup.GET("", api.UserDoctor.GetUserDoctorPendingPage)
|
||||
|
||||
// 医生详情
|
||||
doctorPendingGroup.GET("/:doctor_id", api.UserDoctor.GetPostUserDoctor)
|
||||
doctorPendingGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||
|
||||
// 修改医生
|
||||
doctorPendingGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor)
|
||||
|
||||
@ -5,6 +5,11 @@ import (
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses/doctorExpertiseResponse"
|
||||
"hospital-admin-api/api/responses/hospitalResponse"
|
||||
"hospital-admin-api/api/responses/userDoctorInfoResponse"
|
||||
"hospital-admin-api/api/responses/userDoctorResponse"
|
||||
"hospital-admin-api/api/responses/userResponse"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/extend/ca"
|
||||
"hospital-admin-api/extend/tencentIm"
|
||||
@ -17,9 +22,83 @@ import (
|
||||
type UserDoctorService struct {
|
||||
}
|
||||
|
||||
// GetUserDoctor 医生详情
|
||||
func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse *userDoctorResponse.GetUserDoctor, err error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
userDoctorService := UserDoctorService{}
|
||||
doctorExpertise, err := userDoctorService.GetUserDoctorExpertiseByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||
if userDoctor.UserDoctorInfo != nil {
|
||||
userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo)
|
||||
}
|
||||
|
||||
// 医院
|
||||
var hospital *hospitalResponse.Hospital
|
||||
if userDoctor.Hospital != nil {
|
||||
hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital)
|
||||
}
|
||||
|
||||
// 用户
|
||||
var user *userResponse.User
|
||||
if userDoctor.User != nil {
|
||||
user = userResponse.UserResponse(userDoctor.User)
|
||||
}
|
||||
|
||||
getUserDoctorResponse = &userDoctorResponse.GetUserDoctor{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
IdenAuthStatus: userDoctor.IdenAuthStatus,
|
||||
IdenAuthTime: userDoctor.IdenAuthTime,
|
||||
IdenAuthFailReason: userDoctor.IdenAuthFailReason,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
MultiPointTime: userDoctor.MultiPointTime,
|
||||
MultiPointFailReason: userDoctor.MultiPointFailReason,
|
||||
IsBindBank: userDoctor.IsBindBank,
|
||||
IsRecommend: userDoctor.IsRecommend,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + userDoctor.Avatar,
|
||||
DoctorTitle: userDoctor.DoctorTitle,
|
||||
DepartmentCustomID: strconv.Itoa(int(userDoctor.DepartmentCustomId)),
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
DepartmentCustomMobile: userDoctor.DepartmentCustomMobile,
|
||||
HospitalID: strconv.Itoa(int(userDoctor.HospitalID)),
|
||||
ServedPatientsNum: userDoctor.ServedPatientsNum,
|
||||
PraiseRate: userDoctor.PraiseRate,
|
||||
AvgResponseTime: userDoctor.AvgResponseTime,
|
||||
NumberOfFans: userDoctor.NumberOfFans,
|
||||
IsImgExpertReception: userDoctor.IsImgExpertReception,
|
||||
IsImgWelfareReception: userDoctor.IsImgWelfareReception,
|
||||
IsImgQuickReception: userDoctor.IsImgQuickReception,
|
||||
IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation,
|
||||
QrCode: config.C.Oss.OssCustomDomainName + userDoctor.QrCode,
|
||||
BeGoodAt: userDoctor.BeGoodAt,
|
||||
BriefIntroduction: userDoctor.BriefIntroduction,
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
User: user,
|
||||
Hospital: hospital,
|
||||
UserDoctorInfo: userDoctorInfo,
|
||||
DoctorExpertise: doctorExpertise, // 专长
|
||||
}
|
||||
|
||||
return getUserDoctorResponse, nil
|
||||
}
|
||||
|
||||
// PutUserDoctor 修改医生
|
||||
func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest requests.PutUserDoctor) (bool, error) {
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||
@ -213,6 +292,24 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
}
|
||||
}
|
||||
|
||||
// 处理专长
|
||||
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
||||
// 检测专长是否存在
|
||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
||||
if err != nil || diseaseClassExpertise == nil {
|
||||
return false, errors.New("专长数据错误")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@ -259,6 +356,40 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
}
|
||||
}
|
||||
|
||||
// 修改专长数据
|
||||
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
||||
doctorExpertiseDao := dao.DoctorExpertiseDao{}
|
||||
|
||||
// 删除原专长
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = userDoctor.DoctorId
|
||||
err = doctorExpertiseDao.DeleteDoctorExpertise(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
|
||||
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
// 新增专长表数据
|
||||
doctorExpertise := &model.DoctorExpertise{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
ExpertiseId: expertiseId,
|
||||
}
|
||||
|
||||
doctorExpertise, err = doctorExpertiseDao.AddDoctorExpertise(tx, doctorExpertise)
|
||||
if err != nil || doctorExpertise == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断头像是否修改,同步修改im
|
||||
if userDoctor.Avatar != avatar {
|
||||
profileItem := []tencentIm.ProfileItem{
|
||||
@ -519,6 +650,24 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
||||
multiPointStatus = 2
|
||||
}
|
||||
|
||||
// 处理专长
|
||||
if len(a.DoctorExpertise) > 0 {
|
||||
// 检测专长是否存在
|
||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
for _, v := range a.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
||||
if err != nil || diseaseClassExpertise == nil {
|
||||
return false, errors.New("专长数据错误")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@ -597,6 +746,66 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 修改专长数据
|
||||
if len(a.DoctorExpertise) > 0 {
|
||||
doctorExpertiseDao := dao.DoctorExpertiseDao{}
|
||||
|
||||
for _, v := range a.DoctorExpertise {
|
||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("专长错误")
|
||||
}
|
||||
|
||||
// 新增专长表数据
|
||||
doctorExpertise := &model.DoctorExpertise{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
ExpertiseId: expertiseId,
|
||||
}
|
||||
|
||||
doctorExpertise, err = doctorExpertiseDao.AddDoctorExpertise(tx, doctorExpertise)
|
||||
if err != nil || doctorExpertise == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorExpertiseByDoctorId 获取医生专长
|
||||
func (r *UserDoctorService) GetUserDoctorExpertiseByDoctorId(doctorId int64) ([]*doctorExpertiseResponse.DoctorExpertise, error) {
|
||||
DiseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
|
||||
// 获取医生专长
|
||||
doctorExpertiseDao := dao.DoctorExpertiseDao{}
|
||||
doctorExpertises, err := doctorExpertiseDao.GetDoctorExpertiseListByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
doctorExpertisesResponses := make([]*doctorExpertiseResponse.DoctorExpertise, len(doctorExpertises))
|
||||
|
||||
if len(doctorExpertises) > 0 {
|
||||
for i, v := range doctorExpertises {
|
||||
// 获取专长
|
||||
diseaseClassExpertise, err := DiseaseClassExpertiseDao.GetDiseaseClassExpertiseById(v.ExpertiseId)
|
||||
if err != nil || diseaseClassExpertise == nil {
|
||||
return nil, errors.New("专长数据错误")
|
||||
}
|
||||
|
||||
doctorExpertisesResponse := &doctorExpertiseResponse.DoctorExpertise{
|
||||
DoctorId: strconv.FormatInt(doctorId, 10),
|
||||
ExpertiseId: strconv.FormatInt(v.ExpertiseId, 10),
|
||||
ExpertiseName: diseaseClassExpertise.ExpertiseName,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
doctorExpertisesResponses[i] = doctorExpertisesResponse
|
||||
}
|
||||
}
|
||||
|
||||
return doctorExpertisesResponses, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user