新增医生问诊配置详情
This commit is contained in:
parent
61d3fa2afb
commit
9d65658ebe
@ -6,8 +6,10 @@ import (
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// InquiryConfig 问诊配置
|
||||
@ -53,3 +55,29 @@ func (r *InquiryConfig) GetDoctorInquiryConfigPage(c *gin.Context) {
|
||||
result["data"] = res
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfig 医生问诊配置详情
|
||||
func (r *InquiryConfig) GetDoctorInquiryConfig(c *gin.Context) {
|
||||
id := c.Param("inquiry_config_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
inquiryConfigId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
inquiryConfigService := service.InquiryConfigService{}
|
||||
getUserDoctorResponses, err := inquiryConfigService.GetDoctorInquiryConfig(inquiryConfigId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
|
||||
@ -19,6 +19,15 @@ func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfigListByDoctorId(doctorId i
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfigById 获取医生问诊配置数据-问诊配置id
|
||||
func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfigById(inquiryConfigId int64) (m *model.DoctorInquiryConfig, err error) {
|
||||
err = global.Db.First(&m, inquiryConfigId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorInquiryConfig 删除医生问诊配置
|
||||
func (r *DoctorInquiryConfigDao) DeleteDoctorInquiryConfig(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorInquiryConfig{}).Error
|
||||
|
||||
63
api/dao/doctorInquiryTime.go
Normal file
63
api/dao/doctorInquiryTime.go
Normal file
@ -0,0 +1,63 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorInquiryTimeDao struct {
|
||||
}
|
||||
|
||||
// GetDoctorInquiryTimeListByDoctorId 获取医生问诊时间数据列表-医生id
|
||||
func (r *DoctorInquiryTimeDao) GetDoctorInquiryTimeListByDoctorId(doctorId int64) (m []*model.DoctorInquiryTime, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorInquiryTime 删除医生问诊时间
|
||||
func (r *DoctorInquiryTimeDao) DeleteDoctorInquiryTime(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorInquiryTime{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorInquiryTimeById 修改医生问诊时间-问诊配置id
|
||||
func (r *DoctorInquiryTimeDao) EditDoctorInquiryTimeById(tx *gorm.DB, InquiryTimeId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorInquiryTime{}).Where("inquiry_time_id = ?", InquiryTimeId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryTimeList 获取医生问诊时间列表
|
||||
func (r *DoctorInquiryTimeDao) GetDoctorInquiryTimeList(maps interface{}) (m []*model.DoctorInquiryTime, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorInquiryTime 新增医生问诊时间
|
||||
func (r *DoctorInquiryTimeDao) AddDoctorInquiryTime(tx *gorm.DB, model *model.DoctorInquiryTime) (*model.DoctorInquiryTime, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryTime 获取医生问诊时间
|
||||
func (r *DoctorInquiryTimeDao) GetDoctorInquiryTime(maps interface{}) (m *model.DoctorInquiryTime, err error) {
|
||||
err = global.Db.Where(maps).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@ -22,6 +22,8 @@ type DoctorInquiryConfigDto struct {
|
||||
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:认证失败)
|
||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据
|
||||
DoctorInquiryTime []*DoctorInquiryTimeDto `json:"doctor_inquiry_time"` // 医生问诊时间配置
|
||||
}
|
||||
|
||||
func GetDoctorInquiryConfigDto(m *model.DoctorInquiryConfig) *DoctorInquiryConfigDto {
|
||||
@ -130,3 +132,27 @@ func (r *DoctorInquiryConfigDto) LoadDoctorMultiPointStatus(m *model.UserDoctor)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserDoctor 加载医生数据
|
||||
func (r *DoctorInquiryConfigDto) LoadUserDoctor(m *model.UserDoctor) *DoctorInquiryConfigDto {
|
||||
if m != nil {
|
||||
r.UserDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserDoctorHospital 加载医生医院数据
|
||||
func (r *DoctorInquiryConfigDto) LoadUserDoctorHospital(m *model.Hospital) *DoctorInquiryConfigDto {
|
||||
if m != nil && r.UserDoctor != nil {
|
||||
r.UserDoctor.Hospital = GetHospitalDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadDoctorInquiryTime 加载医生问诊时间
|
||||
func (r *DoctorInquiryConfigDto) LoadDoctorInquiryTime(m []*model.DoctorInquiryTime) *DoctorInquiryConfigDto {
|
||||
if len(m) > 0 {
|
||||
r.DoctorInquiryTime = GetDoctorInquiryTimeListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
58
api/dto/DoctotInquiryTime.go
Normal file
58
api/dto/DoctotInquiryTime.go
Normal file
@ -0,0 +1,58 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type DoctorInquiryTimeDto struct {
|
||||
InquiryTimeId string `json:"inquiry_time_id"` // 主键id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
InquiryType int `json:"inquiry_type"` // 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
InquiryMode int `json:"inquiry_mode"` // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
InquiryDate model.LocalTime `json:"inquiry_date"` // 日期(可为空)
|
||||
StartTime string `json:"start_time"` // 开始时间
|
||||
EndTime string `json:"end_time"` // 结束时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetDoctorInquiryTimeDto(m *model.DoctorInquiryTime) *DoctorInquiryTimeDto {
|
||||
return &DoctorInquiryTimeDto{
|
||||
InquiryTimeId: fmt.Sprintf("%d", m.InquiryTimeId),
|
||||
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||
InquiryType: m.InquiryType,
|
||||
InquiryMode: m.InquiryMode,
|
||||
InquiryDate: m.InquiryDate,
|
||||
StartTime: m.StartTime,
|
||||
EndTime: m.EndTime,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetDoctorInquiryTimeListDto(m []*model.DoctorInquiryTime) []*DoctorInquiryTimeDto {
|
||||
// 处理返回值
|
||||
responses := make([]*DoctorInquiryTimeDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &DoctorInquiryTimeDto{
|
||||
InquiryTimeId: fmt.Sprintf("%d", v.InquiryTimeId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
InquiryDate: v.InquiryDate,
|
||||
StartTime: v.StartTime[:2] + ":" + v.StartTime[2:],
|
||||
EndTime: v.EndTime[:2] + ":" + v.EndTime[2:],
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
37
api/model/doctorInquiryTime.go
Normal file
37
api/model/doctorInquiryTime.go
Normal file
@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorInquiryTime 医生问诊时间配置
|
||||
type DoctorInquiryTime struct {
|
||||
InquiryTimeId int64 `gorm:"column:inquiry_time_id;type:bigint(19);primary_key;comment:主键id" json:"inquiry_time_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:问诊购药)" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(4);comment:接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)" json:"inquiry_mode"`
|
||||
InquiryDate LocalTime `gorm:"column:inquiry_date;type:date;comment:日期(可为空)" json:"inquiry_date"`
|
||||
StartTime string `gorm:"column:start_time;type:varchar(30);comment:开始时间" json:"start_time"`
|
||||
EndTime string `gorm:"column:end_time;type:varchar(30);comment:结束时间" json:"end_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryTime) TableName() string {
|
||||
return "gdxz_doctor_inquiry_time"
|
||||
}
|
||||
|
||||
func (m *DoctorInquiryTime) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.InquiryTimeId == 0 {
|
||||
m.InquiryTimeId = 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
|
||||
}
|
||||
@ -2,7 +2,6 @@ package requests
|
||||
|
||||
type InquiryConfigRequest struct {
|
||||
GetDoctorInquiryConfigPage // 获取开启问诊配置医生列表-分页
|
||||
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfigPage 获取开启问诊配置医生列表-分页
|
||||
|
||||
@ -475,7 +475,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
doctorGroup.GET("", api.InquiryConfig.GetDoctorInquiryConfigPage)
|
||||
|
||||
// 医生问诊配置详情
|
||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||
doctorGroup.GET("/:inquiry_config_id", api.InquiryConfig.GetDoctorInquiryConfig)
|
||||
|
||||
// 修改医生问诊配置
|
||||
doctorGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor)
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"strconv"
|
||||
)
|
||||
@ -102,3 +103,63 @@ func (r *DoctorInquiryConfigService) HandleDoctorInquiryConfig(tx *gorm.DB, doct
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfig 医生问诊配置详情
|
||||
func (r *DoctorInquiryConfigService) GetDoctorInquiryConfig(inquiryConfigId int64) (res *dto.DoctorInquiryConfigDto, err error) {
|
||||
doctorInquiryConfigDao := dao.DoctorInquiryConfigDao{}
|
||||
|
||||
// 获取医生问诊配置
|
||||
doctorInquiryConfig, err := doctorInquiryConfigDao.GetDoctorInquiryConfigById(inquiryConfigId)
|
||||
if err != nil || doctorInquiryConfig == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorInquiryConfig.DoctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取医生医院数据
|
||||
hospitalDao := dao.Hospital{}
|
||||
hospital, err := hospitalDao.GetHospitalById(userDoctor.HospitalID)
|
||||
|
||||
// 获取系统问诊配置
|
||||
systemInquiryConfigDao := dao.SystemInquiryConfigDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
systemInquiryConfig, err := systemInquiryConfigDao.GetSystemInquiryConfig(maps)
|
||||
if err != nil || systemInquiryConfig == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取医生问诊时间
|
||||
doctorInquiryTimeDao := dao.DoctorInquiryTimeDao{}
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorInquiryConfig.DoctorId
|
||||
maps["inquiry_type"] = doctorInquiryConfig.InquiryType
|
||||
maps["inquiry_mode"] = doctorInquiryConfig.InquiryMode
|
||||
doctorInquiryTimes, err := doctorInquiryTimeDao.GetDoctorInquiryTimeList(maps)
|
||||
|
||||
// 处理返回值
|
||||
res = dto.GetDoctorInquiryConfigDto(doctorInquiryConfig)
|
||||
|
||||
// 加载医生数据
|
||||
res.LoadUserDoctor(userDoctor)
|
||||
|
||||
// 加载医生医院
|
||||
if hospital != nil {
|
||||
res.LoadUserDoctorHospital(hospital)
|
||||
}
|
||||
|
||||
// 加载医生问诊时间
|
||||
if userDoctor.IsPlatformDeepCooperation == 1 {
|
||||
res.LoadDoctorInquiryTime(doctorInquiryTimes)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user