新增获取医院详情
This commit is contained in:
parent
5c76941abf
commit
b4051676d5
@ -28,7 +28,7 @@ func (r *UserDoctor) GetMultiDoctor(c *gin.Context) {
|
||||
|
||||
// 获取数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctor(req.GetMultiDoctor)
|
||||
userDoctor, err := userDoctorDao.GetMultiUserDoctor(req.GetMultiDoctor)
|
||||
if err != nil && userDoctor == nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
@ -38,3 +38,30 @@ func (r *UserDoctor) GetMultiDoctor(c *gin.Context) {
|
||||
getMultiDoctorResponse := userDoctorResponse.GetMultiDoctorResponse(userDoctor)
|
||||
responses.OkWithData(getMultiDoctorResponse, c)
|
||||
}
|
||||
|
||||
// GetDoctor 获取医生详情
|
||||
func (r *UserDoctor) GetDoctor(c *gin.Context) {
|
||||
req := v1.UserDoctorRequest{}
|
||||
if err := c.ShouldBind(&req.GetDoctor); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req.GetDoctor); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctor(req.GetDoctor)
|
||||
if err != nil && userDoctor == nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getMultiDoctorResponse := userDoctorResponse.GetDoctorResponse(userDoctor)
|
||||
responses.OkWithData(getMultiDoctorResponse, c)
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@ func (r *UserDoctorDao) GetUserDoctorPreloadById(doctorId int64) (m *model.UserD
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctor 获取医生详情
|
||||
func (r *UserDoctorDao) GetUserDoctor(req v1.GetMultiDoctor) (m *model.UserDoctor, err error) {
|
||||
// GetMultiUserDoctor 获取多点医生详情
|
||||
func (r *UserDoctorDao) GetMultiUserDoctor(req v1.GetMultiDoctor) (m *model.UserDoctor, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key")
|
||||
|
||||
@ -76,3 +76,54 @@ func (r *UserDoctorDao) GetUserDoctor(req v1.GetMultiDoctor) (m *model.UserDocto
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctor 获取医生详情
|
||||
func (r *UserDoctorDao) GetUserDoctor(req v1.GetDoctor) (m *model.UserDoctor, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key")
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 医院
|
||||
query = query.Preload("Hospital", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("hospital_id,hospital_name,hospital_level_name")
|
||||
})
|
||||
|
||||
// 问诊配置
|
||||
query = query.Preload("DoctorInquiryConfig")
|
||||
|
||||
// 状态
|
||||
query = query.Where("status = ?", 1)
|
||||
|
||||
// 实名认证状态
|
||||
query = query.Where("idcard_status = ?", 1)
|
||||
|
||||
// 身份认证状态
|
||||
query = query.Where("iden_auth_status = ?", 1)
|
||||
|
||||
// 是否已绑定结算银行卡
|
||||
query = query.Where("is_bind_bank = ?", 1)
|
||||
|
||||
// 姓名
|
||||
if req.UserName != "" {
|
||||
query = query.Where("user_name = ?", req.UserName)
|
||||
}
|
||||
|
||||
// 手机号
|
||||
if req.Mobile != "" {
|
||||
subQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
err = query.First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
39
api/model/doctorInquiryConfig.go
Normal file
39
api/model/doctorInquiryConfig.go
Normal file
@ -0,0 +1,39 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorInquiryConfig 医生接诊配置表
|
||||
type DoctorInquiryConfig struct {
|
||||
InquiryConfigId int64 `gorm:"column:inquiry_config_id;type:bigint(19);primary_key;comment:主键id" json:"inquiry_config_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);default:1;comment:接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药);NOT NULL" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);default:1;comment:接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||
IsEnable int `gorm:"column:is_enable;type:tinyint(1);default:0;comment:是否启用(0:否 1:是)" json:"is_enable"`
|
||||
LastEnableMethod int `gorm:"column:last_enable_method;type:tinyint(1);default:1;comment:最后开启方式(1:自己 2:后台)" json:"last_enable_method"`
|
||||
WorkNumDay int `gorm:"column:work_num_day;type:int(10);default:0;comment:每日接诊数量" json:"work_num_day"`
|
||||
InquiryPrice float64 `gorm:"column:inquiry_price;type:decimal(10,2);comment:接诊价格(专家问诊-公益问诊)" json:"inquiry_price"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryConfig) TableName() string {
|
||||
return "gdxz_doctor_inquiry_config"
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryConfig) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.InquiryConfigId == 0 {
|
||||
m.InquiryConfigId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -21,8 +21,10 @@ type User struct {
|
||||
Age uint `gorm:"column:age;type:int(10) unsigned;comment:年龄" json:"age"`
|
||||
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
IsOnline int `gorm:"column:is_online;type:tinyint(1);default:0;comment:是否在线(0:不在线 1:在线)" json:"is_online"`
|
||||
LoginAt LocalTime `gorm:"column:login_at;type:datetime;comment:小程序登陆时间" json:"login_at"`
|
||||
ImLoginAt LocalTime `gorm:"column:im_login_at;type:datetime;comment:im登陆时间" json:"im_login_at"`
|
||||
LoginIp string `gorm:"column:login_ip;type:varchar(255);comment:登陆ip" json:"login_ip"`
|
||||
LastLoginAt LocalTime `gorm:"column:last_login_at;type:datetime;comment:最后登陆时间" json:"last_login_at"`
|
||||
CreatedBy string `gorm:"column:created_by;type:varchar(100);comment:创建者id(后台用户表id null:自己注册)" json:"created_by"`
|
||||
Model
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ type UserDoctor struct {
|
||||
PraiseRate float64 `gorm:"column:praise_rate;type:float(10,2);default:0.00;comment:好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)" json:"praise_rate"`
|
||||
AvgResponseTime float64 `gorm:"column:avg_response_time;type:float(10,2);default:0.00;comment:平均响应时间(分钟制)" json:"avg_response_time"`
|
||||
NumberOfFans uint `gorm:"column:number_of_fans;type:int(10) unsigned;default:0;comment:被关注数量" json:"number_of_fans"`
|
||||
IsOnline int `gorm:"column:is_online;type:tinyint(1);default:0;comment:是否在线(0:不在线 1:在线)" json:"is_online"`
|
||||
IsImgExpertReception int `gorm:"column:is_img_expert_reception;type:tinyint(1);default:0;comment:是否参加专家图文接诊(0:否 1:是)" json:"is_img_expert_reception"`
|
||||
IsImgWelfareReception int `gorm:"column:is_img_welfare_reception;type:tinyint(1);default:0;comment:是否参加公益图文问诊(0:否 1:是)" json:"is_img_welfare_reception"`
|
||||
IsImgQuickReception int `gorm:"column:is_img_quick_reception;type:tinyint(1);default:0;comment:是否参加快速图文接诊(0:否 1:是)" json:"is_img_quick_reception"`
|
||||
@ -45,8 +44,9 @@ 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"` // 医院
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
|
||||
Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院
|
||||
DoctorInquiryConfig []*DoctorInquiryConfig `gorm:"foreignKey:DoctorId;references:doctor_id" json:"doctor_inquiry_config"` // 问诊配置
|
||||
}
|
||||
|
||||
func (m *UserDoctor) TableName() string {
|
||||
|
||||
@ -2,6 +2,7 @@ package v1
|
||||
|
||||
type UserDoctorRequest struct {
|
||||
GetMultiDoctor // 获取多点执业医生详情
|
||||
GetDoctor // 获取医生详情
|
||||
}
|
||||
|
||||
// GetMultiDoctor 获取多点执业医生详情
|
||||
@ -9,3 +10,9 @@ type GetMultiDoctor struct {
|
||||
Mobile string `json:"mobile" form:"mobile" validate:"required,Mobile" label:"手机号"`
|
||||
UserName string `json:"user_name" form:"user_name" validate:"required" label:"用户名"`
|
||||
}
|
||||
|
||||
// GetDoctor 获取医生详情
|
||||
type GetDoctor struct {
|
||||
Mobile string `json:"mobile" form:"mobile" validate:"required,Mobile" label:"手机号"`
|
||||
UserName string `json:"user_name" form:"user_name" validate:"required" label:"用户名"`
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package doctotInquiryConfigResponse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-open-api/api/model"
|
||||
)
|
||||
|
||||
type DoctorInquiryConfig struct {
|
||||
InquiryConfigId string `json:"inquiry_config_id"` // 主键id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
InquiryType int `json:"inquiry_type"` // 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药);NOT NULL
|
||||
InquiryMode int `json:"inquiry_mode"` // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL
|
||||
IsEnable int `json:"is_enable"` // 是否启用(0:否 1:是)
|
||||
LastEnableMethod int `json:"last_enable_method"` // 最后开启方式(1:自己 2:后台)
|
||||
WorkNumDay int `json:"work_num_day"` // 每日接诊数量
|
||||
InquiryPrice float64 `json:"inquiry_price"` // 接诊价格(专家问诊-公益问诊)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
MobileMask string `json:"mobile_mask"` // 医生电话(掩码)
|
||||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称
|
||||
DoctorTitle *int `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
}
|
||||
|
||||
func GetDoctorInquiryConfigListResponse(m []*model.DoctorInquiryConfig) []*DoctorInquiryConfig {
|
||||
// 处理返回值
|
||||
responses := make([]*DoctorInquiryConfig, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &DoctorInquiryConfig{
|
||||
InquiryConfigId: fmt.Sprintf("%d", v.InquiryConfigId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
IsEnable: v.IsEnable,
|
||||
LastEnableMethod: v.LastEnableMethod,
|
||||
WorkNumDay: v.WorkNumDay,
|
||||
InquiryPrice: v.InquiryPrice,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
@ -2,6 +2,7 @@ package userDoctorResponse
|
||||
|
||||
import (
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/api/responses/v1/doctotInquiryConfigResponse"
|
||||
"hospital-open-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
@ -38,6 +39,39 @@ type GetMultiDoctor struct {
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetDoctor 获取医生详情
|
||||
type GetDoctor 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 []*doctotInquiryConfigResponse.DoctorInquiryConfig `json:"doctor_inquiry_config"` // 医生问诊配置
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetMultiDoctorResponse 获取多点执业医生详情
|
||||
func GetMultiDoctorResponse(userDoctor *model.UserDoctor) GetMultiDoctor {
|
||||
res := GetMultiDoctor{
|
||||
@ -79,3 +113,52 @@ func GetMultiDoctorResponse(userDoctor *model.UserDoctor) GetMultiDoctor {
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// GetDoctorResponse 获取医生详情
|
||||
func GetDoctorResponse(userDoctor *model.UserDoctor) GetDoctor {
|
||||
res := GetDoctor{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
IdenAuthStatus: userDoctor.IdenAuthStatus,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
Avatar: utils.AddOssDomain(userDoctor.Avatar),
|
||||
DoctorTitle: utils.DoctorTitleToStr(userDoctor.DoctorTitle),
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
ServedPatientsNum: userDoctor.ServedPatientsNum,
|
||||
PraiseRate: userDoctor.PraiseRate,
|
||||
AvgResponseTime: userDoctor.AvgResponseTime,
|
||||
NumberOfFans: userDoctor.NumberOfFans,
|
||||
IsImgExpertReception: userDoctor.IsImgExpertReception,
|
||||
IsImgWelfareReception: userDoctor.IsImgWelfareReception,
|
||||
IsImgQuickReception: userDoctor.IsImgQuickReception,
|
||||
IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation,
|
||||
IsEnterpriseDeepCooperation: userDoctor.IsEnterpriseDeepCooperation,
|
||||
QrCode: utils.AddOssDomain(userDoctor.QrCode),
|
||||
BeGoodAt: userDoctor.BeGoodAt,
|
||||
BriefIntroduction: userDoctor.BriefIntroduction,
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
}
|
||||
|
||||
// 用户数据
|
||||
if userDoctor.User != nil {
|
||||
res.Mobile = userDoctor.User.Mobile
|
||||
res.Age = userDoctor.User.Age
|
||||
res.Sex = userDoctor.User.Sex
|
||||
}
|
||||
|
||||
// 医院名称
|
||||
if userDoctor.Hospital != nil {
|
||||
res.HospitalName = userDoctor.Hospital.HospitalName
|
||||
}
|
||||
|
||||
// 问诊配置
|
||||
if len(userDoctor.DoctorInquiryConfig) > 0 {
|
||||
res.DoctorInquiryConfig = doctotInquiryConfigResponse.GetDoctorInquiryConfigListResponse(userDoctor.DoctorInquiryConfig)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@ -84,6 +84,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
{
|
||||
doctorGroup := userGroup.Group("/doctor")
|
||||
{
|
||||
// 获取医生详情
|
||||
doctorGroup.GET("", api.V1.UserDoctor.GetDoctor)
|
||||
|
||||
// 获取多点执业医生详情
|
||||
doctorGroup.GET("/multi", api.V1.UserDoctor.GetMultiDoctor)
|
||||
}
|
||||
|
||||
@ -22,9 +22,9 @@ log:
|
||||
|
||||
# [redis]
|
||||
redis:
|
||||
host: '121.5.206.61'
|
||||
port: 6379
|
||||
password: Wucongxing1..
|
||||
host: '139.155.127.177'
|
||||
port: 30002
|
||||
password: gdxz2022&dj.
|
||||
pool-size: 100
|
||||
|
||||
# [jwt]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user