新增获取医生列表
This commit is contained in:
parent
d9ca0ab963
commit
5c77f6da99
4
.gitignore
vendored
4
.gitignore
vendored
@ -14,4 +14,6 @@
|
||||
*.log
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
# vendor/
|
||||
.idea/
|
||||
.git/
|
||||
@ -372,3 +372,29 @@ func (r *UserDoctor) PutMulti(c *gin.Context) {
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetUserDoctorList 获取医生列表
|
||||
func (r *UserDoctor) GetUserDoctorList(c *gin.Context) {
|
||||
req := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBind(&req.GetUserDoctorList); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req.GetUserDoctorList); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorListSearch(req.GetUserDoctorList)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := dto.GetUserDoctorListDto(userDoctor)
|
||||
responses.OkWithData(res, c)
|
||||
}
|
||||
|
||||
@ -362,3 +362,34 @@ func (r *UserDoctorDao) GetUserDoctorMultiPageSearch(p requests.GetMultiPage, pa
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorListSearch 获取医生列表
|
||||
func (r *UserDoctorDao) GetUserDoctorListSearch(req requests.GetUserDoctorList) (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")
|
||||
})
|
||||
|
||||
// 用户名称
|
||||
if req.UserName != "" {
|
||||
query = query.Where("user_name LIKE ?", "%"+req.UserName+"%")
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
err = query.Scopes(model.Paginate(1, 10)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ type UserDoctorRequest struct {
|
||||
PutUserDoctorPending // 身份审核-审核医生
|
||||
GetMultiPage // 多点-获取医生列表-分页
|
||||
PutMulti // 多点-审核医生
|
||||
GetUserDoctorList // 获取医生列表
|
||||
}
|
||||
|
||||
// GetUserDoctorPage 获取医生列表-分页
|
||||
@ -126,3 +127,8 @@ type PutMulti struct {
|
||||
MultiPointStatus int `json:"multi_point_status" form:"multi_point_status" validate:"required,oneof=1 3" label:"医生多点执业认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
MultiPointFailReason string `json:"multi_point_fail_reason" form:"multi_point_fail_reason" label:"多点执业认证失败原因"`
|
||||
}
|
||||
|
||||
// GetUserDoctorList 获取医生列表
|
||||
type GetUserDoctorList struct {
|
||||
UserName string `json:"user_name" form:"user_name" label:"医生姓名"`
|
||||
}
|
||||
|
||||
@ -325,6 +325,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取医生列表-分页
|
||||
doctorGroup.GET("", api.UserDoctor.GetUserDoctorPage)
|
||||
|
||||
// 获取医生列表
|
||||
doctorGroup.GET("/list", api.UserDoctor.GetUserDoctorList)
|
||||
|
||||
// 医生详情
|
||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctor)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user