新增问诊管理-问诊配置-医生问诊配置-获取开启问诊配置医生列表-分页接口
This commit is contained in:
parent
62b58d0c7a
commit
43ae46ba15
@ -63,5 +63,5 @@ type orderPrescriptionManage struct {
|
|||||||
|
|
||||||
// 问诊管理
|
// 问诊管理
|
||||||
type inquiryManage struct {
|
type inquiryManage struct {
|
||||||
Inquiry // 问诊管理
|
InquiryConfig // 问诊配置
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,55 +0,0 @@
|
|||||||
package controller
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"hospital-admin-api/api/dao"
|
|
||||||
"hospital-admin-api/api/dto"
|
|
||||||
"hospital-admin-api/api/requests"
|
|
||||||
"hospital-admin-api/api/responses"
|
|
||||||
"hospital-admin-api/global"
|
|
||||||
"hospital-admin-api/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Inquiry 问诊管理
|
|
||||||
type Inquiry struct{}
|
|
||||||
|
|
||||||
// GetUserDoctorPage 获取医生列表-分页
|
|
||||||
func (r *Inquiry) GetUserDoctorPage(c *gin.Context) {
|
|
||||||
userDoctorRequest := requests.UserDoctorRequest{}
|
|
||||||
if err := c.ShouldBind(&userDoctorRequest.GetUserDoctorPage); err != nil {
|
|
||||||
responses.FailWithMessage(err.Error(), c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 参数验证
|
|
||||||
if err := global.Validate.Struct(userDoctorRequest.GetUserDoctorPage); err != nil {
|
|
||||||
responses.FailWithMessage(utils.Translate(err), c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if userDoctorRequest.GetUserDoctorPage.Page == 0 {
|
|
||||||
userDoctorRequest.GetUserDoctorPage.Page = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if userDoctorRequest.GetUserDoctorPage.PageSize == 0 {
|
|
||||||
userDoctorRequest.GetUserDoctorPage.PageSize = 20
|
|
||||||
}
|
|
||||||
|
|
||||||
userDoctorDao := dao.UserDoctorDao{}
|
|
||||||
userDoctor, total, err := userDoctorDao.GetUserDoctorPageSearch(userDoctorRequest.GetUserDoctorPage, userDoctorRequest.GetUserDoctorPage.Page, userDoctorRequest.GetUserDoctorPage.PageSize)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
responses.FailWithMessage(err.Error(), c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理返回值
|
|
||||||
getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor)
|
|
||||||
|
|
||||||
result := make(map[string]interface{})
|
|
||||||
result["page"] = userDoctorRequest.GetUserDoctorPage.Page
|
|
||||||
result["page_size"] = userDoctorRequest.GetUserDoctorPage.PageSize
|
|
||||||
result["total"] = total
|
|
||||||
result["data"] = getUserDoctorPageResponses
|
|
||||||
responses.OkWithData(result, c)
|
|
||||||
}
|
|
||||||
55
api/controller/inquiryConfig.go
Normal file
55
api/controller/inquiryConfig.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/dto"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
|
"hospital-admin-api/api/responses"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InquiryConfig 问诊配置
|
||||||
|
type InquiryConfig struct{}
|
||||||
|
|
||||||
|
// GetDoctorInquiryConfigPage 获取开启问诊配置医生列表-分页
|
||||||
|
func (r *InquiryConfig) GetDoctorInquiryConfigPage(c *gin.Context) {
|
||||||
|
req := requests.InquiryConfigRequest{}
|
||||||
|
if err := c.ShouldBind(&req.GetDoctorInquiryConfigPage); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(req.GetDoctorInquiryConfigPage); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetDoctorInquiryConfigPage.Page == 0 {
|
||||||
|
req.GetDoctorInquiryConfigPage.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetDoctorInquiryConfigPage.PageSize == 0 {
|
||||||
|
req.GetDoctorInquiryConfigPage.PageSize = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
doctorInquiryConfigDao := dao.DoctorInquiryConfigDao{}
|
||||||
|
doctorInquiryConfig, total, err := doctorInquiryConfigDao.GetUserDoctorPageSearch(req.GetDoctorInquiryConfigPage, req.GetDoctorInquiryConfigPage.Page, req.GetDoctorInquiryConfigPage.PageSize)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回值
|
||||||
|
res := dto.GetDoctorInquiryConfigListDto(doctorInquiryConfig)
|
||||||
|
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
result["page"] = req.GetDoctorInquiryConfigPage.Page
|
||||||
|
result["page_size"] = req.GetDoctorInquiryConfigPage.PageSize
|
||||||
|
result["total"] = total
|
||||||
|
result["data"] = res
|
||||||
|
responses.OkWithData(result, c)
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,3 +62,73 @@ func (r *DoctorInquiryConfigDao) GetDoctorInquiryConfig(maps interface{}) (m *mo
|
|||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserDoctorPageSearch 获取医生列表-分页
|
||||||
|
func (r *DoctorInquiryConfigDao) GetUserDoctorPageSearch(req requests.GetDoctorInquiryConfigPage, page, pageSize int) (m []*model.DoctorInquiryConfig, total int64, err error) {
|
||||||
|
var totalRecords int64
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
query := global.Db.Model(&model.DoctorInquiryConfig{})
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 用户表
|
||||||
|
query = query.Preload("UserDoctor.User", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("user_password", "salt")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 手机号
|
||||||
|
if req.Mobile != "" {
|
||||||
|
// 医生
|
||||||
|
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||||
|
Select("user_id").
|
||||||
|
Where("mobile = ?", req.Mobile)
|
||||||
|
|
||||||
|
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||||
|
Select("doctor_id").
|
||||||
|
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||||
|
|
||||||
|
query = query.Where("doctor_id IN (?)", doctorSubQuery)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 医生姓名
|
||||||
|
if req.DoctorName != "" {
|
||||||
|
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||||
|
Select("doctor_id").
|
||||||
|
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||||
|
|
||||||
|
query = query.Where("doctor_id IN (?)", subQuery)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊类型
|
||||||
|
if req.InquiryType != nil {
|
||||||
|
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊方式
|
||||||
|
if req.InquiryMode != nil {
|
||||||
|
query = query.Where("inquiry_mode = ?", req.InquiryMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否启用
|
||||||
|
if req.IsEnable != nil {
|
||||||
|
query = query.Where("is_enable = ?", req.IsEnable)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
query = query.Order("created_at desc")
|
||||||
|
|
||||||
|
// 查询总数量
|
||||||
|
if err := query.Count(&totalRecords).Error; err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return m, totalRecords, nil
|
||||||
|
}
|
||||||
|
|||||||
132
api/dto/DoctotInquiryConfig.go
Normal file
132
api/dto/DoctotInquiryConfig.go
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DoctorInquiryConfigDto 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 GetDoctorInquiryConfigDto(m *model.DoctorInquiryConfig) *DoctorInquiryConfigDto {
|
||||||
|
return &DoctorInquiryConfigDto{
|
||||||
|
InquiryConfigId: fmt.Sprintf("%d", m.InquiryConfigId),
|
||||||
|
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||||
|
InquiryType: m.InquiryType,
|
||||||
|
InquiryMode: m.InquiryMode,
|
||||||
|
IsEnable: m.IsEnable,
|
||||||
|
LastEnableMethod: m.LastEnableMethod,
|
||||||
|
WorkNumDay: m.WorkNumDay,
|
||||||
|
InquiryPrice: m.InquiryPrice,
|
||||||
|
CreatedAt: m.CreatedAt,
|
||||||
|
UpdatedAt: m.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDoctorInquiryConfigListDto(m []*model.DoctorInquiryConfig) []*DoctorInquiryConfigDto {
|
||||||
|
// 处理返回值
|
||||||
|
responses := make([]*DoctorInquiryConfigDto, len(m))
|
||||||
|
|
||||||
|
if len(m) > 0 {
|
||||||
|
for i, v := range m {
|
||||||
|
response := &DoctorInquiryConfigDto{
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生名称
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorName(v.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生电话
|
||||||
|
if v.UserDoctor.User != nil {
|
||||||
|
response.LoadDoctorMaskMobile(v.UserDoctor.User)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生科室名称
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorDepartmentCustomName(v.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生职称
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorTitle(v.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生多点执业认证状态
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorMultiPointStatus(v.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
responses[i] = response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return responses
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorName 加载医生名称
|
||||||
|
func (r *DoctorInquiryConfigDto) LoadDoctorName(m *model.UserDoctor) *DoctorInquiryConfigDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorName = m.UserName
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorMaskMobile 加载医生电话
|
||||||
|
func (r *DoctorInquiryConfigDto) LoadDoctorMaskMobile(m *model.User) *DoctorInquiryConfigDto {
|
||||||
|
if m != nil {
|
||||||
|
r.MobileMask = utils.MaskPhoneStr(m.Mobile)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorDepartmentCustomName 加载医生科室名称
|
||||||
|
func (r *DoctorInquiryConfigDto) LoadDoctorDepartmentCustomName(m *model.UserDoctor) *DoctorInquiryConfigDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DepartmentCustomName = m.DepartmentCustomName
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorTitle 加载医生职称
|
||||||
|
func (r *DoctorInquiryConfigDto) LoadDoctorTitle(m *model.UserDoctor) *DoctorInquiryConfigDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorTitle = &m.DoctorTitle
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorMultiPointStatus 加载医生多点执业认证状态
|
||||||
|
func (r *DoctorInquiryConfigDto) LoadDoctorMultiPointStatus(m *model.UserDoctor) *DoctorInquiryConfigDto {
|
||||||
|
if m != nil {
|
||||||
|
r.MultiPointStatus = m.MultiPointStatus
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
@ -16,6 +16,7 @@ type DoctorInquiryConfig struct {
|
|||||||
LastEnableMethod int `gorm:"column:last_enable_method;type:tinyint(1);default:1;comment:最后开启方式(1:自己 2:后台)" json:"last_enable_method"`
|
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"`
|
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"`
|
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
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
api/requests/inquiryConfig.go
Normal file
17
api/requests/inquiryConfig.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package requests
|
||||||
|
|
||||||
|
type InquiryConfigRequest struct {
|
||||||
|
GetDoctorInquiryConfigPage // 获取开启问诊配置医生列表-分页
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDoctorInquiryConfigPage 获取开启问诊配置医生列表-分页
|
||||||
|
type GetDoctorInquiryConfigPage struct {
|
||||||
|
Page int `json:"page" form:"page" label:"页码"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||||
|
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||||
|
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||||
|
InquiryType *int `json:"inquiry_type" form:"inquiry_type" label:"问诊类型"` // 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测
|
||||||
|
InquiryMode *int `json:"inquiry_mode" form:"inquiry_mode" label:"问诊方式"` // 1:图文 2:视频 3:语音 4:电话 5:会员
|
||||||
|
IsEnable *int `json:"is_enable" form:"is_enable" label:"是否启用"` // 0:否 1:是
|
||||||
|
}
|
||||||
@ -472,7 +472,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
doctorGroup := configGroup.Group("/doctor")
|
doctorGroup := configGroup.Group("/doctor")
|
||||||
{
|
{
|
||||||
// 获取开启问诊配置医生列表-分页
|
// 获取开启问诊配置医生列表-分页
|
||||||
doctorGroup.GET("", api.UserDoctor.GetUserDoctor)
|
doctorGroup.GET("", api.InquiryConfig.GetDoctorInquiryConfigPage)
|
||||||
|
|
||||||
// 医生问诊配置详情
|
// 医生问诊配置详情
|
||||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user