新增系统问诊配置
This commit is contained in:
parent
5c77f6da99
commit
eda63e716e
@ -146,3 +146,74 @@ func (r *InquiryConfig) AddDoctorInquiryConfig(c *gin.Context) {
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigPage 获取系统问诊配置列表-分页
|
||||
func (r *InquiryConfig) GetSystemInquiryConfigPage(c *gin.Context) {
|
||||
inquiryConfigRequest := requests.InquiryConfigRequest{}
|
||||
req := inquiryConfigRequest.GetSystemInquiryConfigPage
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Page == 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
systemInquiryConfigDao := dao.SystemInquiryConfigDao{}
|
||||
systemInquiryConfig, total, err := systemInquiryConfigDao.GetSystemInquiryConfigPageSearch(req, req.Page, req.PageSize)
|
||||
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := dto.GetSystemInquiryConfigListDto(systemInquiryConfig)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = res
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfig 系统问诊配置详情
|
||||
func (r *InquiryConfig) GetSystemInquiryConfig(c *gin.Context) {
|
||||
id := c.Param("system_inquiry_config_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
systemInquiryConfigId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
systemInquiryConfigDao := dao.SystemInquiryConfigDao{}
|
||||
systemInquiryConfig, err := systemInquiryConfigDao.GetSystemInquiryConfigById(systemInquiryConfigId)
|
||||
if err != nil || systemInquiryConfig == nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := dto.GetSystemInquiryConfigDto(systemInquiryConfig)
|
||||
|
||||
responses.OkWithData(res, c)
|
||||
}
|
||||
|
||||
@ -3,14 +3,15 @@ package dao
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type SystemInquiryConfigDao struct {
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigListByDoctorId 获取系统问诊配置数据列表-系统id
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfigListByDoctorId(systemInquiryConfigId int64) (m *model.SystemInquiryConfig, err error) {
|
||||
// GetSystemInquiryConfigById 获取系统问诊配置数据列表-系统问诊配置id
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfigById(systemInquiryConfigId int64) (m *model.SystemInquiryConfig, err error) {
|
||||
err = global.Db.First(&m, systemInquiryConfigId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -61,3 +62,35 @@ func (r *SystemInquiryConfigDao) GetSystemInquiryConfig(maps interface{}) (m *mo
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigPageSearch 获取系统问诊配置列表-分页
|
||||
func (r *SystemInquiryConfigDao) GetSystemInquiryConfigPageSearch(req requests.GetSystemInquiryConfigPage, page, pageSize int) (m []*model.SystemInquiryConfig, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.SystemInquiryConfig{})
|
||||
|
||||
// 问诊类型
|
||||
if req.InquiryType != nil {
|
||||
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||
}
|
||||
|
||||
// 问诊方式
|
||||
if req.InquiryMode != nil {
|
||||
query = query.Where("inquiry_mode = ?", req.InquiryMode)
|
||||
}
|
||||
|
||||
// 排序
|
||||
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
|
||||
}
|
||||
|
||||
78
api/dto/SystemInquiryConfig.go
Normal file
78
api/dto/SystemInquiryConfig.go
Normal file
@ -0,0 +1,78 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type SystemInquiryConfigDto struct {
|
||||
SystemInquiryConfigId string `json:"system_inquiry_config_id"` // 主键id
|
||||
InquiryType int `json:"inquiry_type"` // 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
InquiryMode int `json:"inquiry_mode"` // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
MaxWorkNumDay int `json:"max_work_num_day"` // 每日最大接诊数量
|
||||
InquiryPrice string `json:"inquiry_price"` // 接诊价格
|
||||
MinInquiryPrice *float64 `json:"min_inquiry_price"` // 最低接诊价格(专家问诊)
|
||||
MaxInquiryPrice *float64 `json:"max_inquiry_price"` // 最高接诊价格(专家问诊)
|
||||
TimesNumber int `json:"times_number"` // 沟通次数(0为不限制次数)
|
||||
Duration int `json:"duration"` // 沟通时长(分钟,0为不限制时长)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetSystemInquiryConfigDto(m *model.SystemInquiryConfig) *SystemInquiryConfigDto {
|
||||
MinInquiryPrice := &m.MinInquiryPrice
|
||||
MaxInquiryPrice := &m.MaxInquiryPrice
|
||||
if m.InquiryType == 2 || m.InquiryType == 3 || m.InquiryType == 4 {
|
||||
MinInquiryPrice = nil
|
||||
MaxInquiryPrice = nil
|
||||
}
|
||||
|
||||
return &SystemInquiryConfigDto{
|
||||
SystemInquiryConfigId: fmt.Sprintf("%d", m.SystemInquiryConfigId),
|
||||
InquiryType: m.InquiryType,
|
||||
InquiryMode: m.InquiryMode,
|
||||
MaxWorkNumDay: m.MaxWorkNumDay,
|
||||
InquiryPrice: m.InquiryPrice,
|
||||
MinInquiryPrice: MinInquiryPrice,
|
||||
MaxInquiryPrice: MaxInquiryPrice,
|
||||
TimesNumber: m.TimesNumber,
|
||||
Duration: m.Duration,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetSystemInquiryConfigListDto(m []*model.SystemInquiryConfig) []*SystemInquiryConfigDto {
|
||||
// 处理返回值
|
||||
responses := make([]*SystemInquiryConfigDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
MinInquiryPrice := &v.MinInquiryPrice
|
||||
MaxInquiryPrice := &v.MaxInquiryPrice
|
||||
if v.InquiryType == 2 || v.InquiryType == 3 || v.InquiryType == 4 {
|
||||
MinInquiryPrice = nil
|
||||
MaxInquiryPrice = nil
|
||||
}
|
||||
|
||||
response := &SystemInquiryConfigDto{
|
||||
SystemInquiryConfigId: fmt.Sprintf("%d", v.SystemInquiryConfigId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
MaxWorkNumDay: v.MaxWorkNumDay,
|
||||
InquiryPrice: v.InquiryPrice,
|
||||
MinInquiryPrice: MinInquiryPrice,
|
||||
MaxInquiryPrice: MaxInquiryPrice,
|
||||
TimesNumber: v.TimesNumber,
|
||||
Duration: v.Duration,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
@ -4,6 +4,7 @@ type InquiryConfigRequest struct {
|
||||
GetDoctorInquiryConfigPage // 获取开启问诊配置医生列表-分页
|
||||
PutDoctorInquiryConfig // 修改医生问诊配置
|
||||
AddDoctorInquiryConfig // 新增医生问诊配置
|
||||
GetSystemInquiryConfigPage // 获取系统问诊配置列表-分页
|
||||
}
|
||||
|
||||
// GetDoctorInquiryConfigPage 获取开启问诊配置医生列表-分页
|
||||
@ -45,3 +46,11 @@ type AddDoctorInquiryConfig struct {
|
||||
IsEnable int `json:"is_enable" form:"is_enable" validate:"oneof=0 1" label:"是否启用"` // 0:否 1:是
|
||||
DoctorInquiryTime []*doctorInquiryTime `json:"doctor_inquiry_time" form:"doctor_inquiry_time" label:"医生问诊配置-时间配置"`
|
||||
}
|
||||
|
||||
// GetSystemInquiryConfigPage 获取系统问诊配置列表-分页
|
||||
type GetSystemInquiryConfigPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" 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:会员
|
||||
}
|
||||
|
||||
@ -491,16 +491,16 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
systemGroup := configGroup.Group("/system")
|
||||
{
|
||||
// 获取系统问诊配置列表-分页
|
||||
systemGroup.GET("", api.UserDoctor.GetUserDoctorPage)
|
||||
systemGroup.GET("", api.InquiryConfig.GetSystemInquiryConfigPage)
|
||||
|
||||
// 系统问诊配置详情
|
||||
systemGroup.GET("/list", api.UserDoctor.GetUserDoctorPage)
|
||||
systemGroup.GET("/:system_inquiry_config_id", api.InquiryConfig.GetSystemInquiryConfig)
|
||||
|
||||
// 修改系统问诊配置
|
||||
systemGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||
systemGroup.PUT("/:inquiry_config_id", api.InquiryConfig.PutDoctorInquiryConfig)
|
||||
|
||||
// 修改系统问诊配置
|
||||
systemGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor)
|
||||
// 新增系统问诊配置
|
||||
systemGroup.POST("", api.InquiryConfig.AddDoctorInquiryConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user