新增修改医生
This commit is contained in:
parent
966039e4b6
commit
a38fe237dd
@ -25,5 +25,6 @@ type userDoctorManage struct {
|
||||
|
||||
// Basic 基础数据
|
||||
type basic struct {
|
||||
Department // 科室
|
||||
Department // 科室管理
|
||||
Hospital // 医院管理
|
||||
}
|
||||
|
||||
42
api/controller/hospital.go
Normal file
42
api/controller/hospital.go
Normal file
@ -0,0 +1,42 @@
|
||||
// Package controller 科室管理
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/responses/hospitalResponse"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type Hospital struct{}
|
||||
|
||||
// GetHospitalLimit 获取医院列表-限制条数
|
||||
func (b *Hospital) GetHospitalLimit(c *gin.Context) {
|
||||
hospitalRequest := requests.HospitalRequest{}
|
||||
if err := c.ShouldBind(&hospitalRequest.GetHospitalLimit); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(hospitalRequest.GetHospitalLimit); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(hospitalRequest.GetHospitalLimit)
|
||||
hospitalDao := dao.Hospital{}
|
||||
hospitals, err := hospitalDao.GetHospitalLimitByMaps(hospitalRequest.GetHospitalLimit)
|
||||
if err != nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getHospitalLimitResponse := hospitalResponse.GetHospitalLimitResponse(hospitals)
|
||||
responses.OkWithData(getHospitalLimitResponse, c)
|
||||
}
|
||||
@ -84,16 +84,16 @@ func (r *UserDoctor) GetPostUserDoctor(c *gin.Context) {
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
|
||||
// PutPostUserDoctor 修改医生
|
||||
func (r *UserDoctor) PutPostUserDoctor(c *gin.Context) {
|
||||
// PutUserDoctor 修改医生
|
||||
func (r *UserDoctor) PutUserDoctor(c *gin.Context) {
|
||||
userDoctorRequest := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBindJSON(&userDoctorRequest.PutPostUserDoctor); err != nil {
|
||||
if err := c.ShouldBindJSON(&userDoctorRequest.PutUserDoctor); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(userDoctorRequest.PutPostUserDoctor); err != nil {
|
||||
if err := global.Validate.Struct(userDoctorRequest.PutUserDoctor); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
@ -113,7 +113,7 @@ func (r *UserDoctor) PutPostUserDoctor(c *gin.Context) {
|
||||
|
||||
// 业务处理
|
||||
userDoctorService := service.UserDoctorService{}
|
||||
_, err = userDoctorService.PutPostUserDoctor(doctorId, userDoctorRequest.PutPostUserDoctor)
|
||||
_, err = userDoctorService.PutUserDoctor(doctorId, userDoctorRequest.PutUserDoctor)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("修改失败", c)
|
||||
return
|
||||
|
||||
@ -3,6 +3,7 @@ package dao
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
@ -51,3 +52,45 @@ func (r *Hospital) EditHospitalById(tx *gorm.DB, hospitalId int64, data interfac
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetHospitalLimitByMaps 获取医院列表-限制条数
|
||||
func (r *Hospital) GetHospitalLimitByMaps(hospitalRequest requests.GetHospitalLimit) (m []*model.Hospital, err error) {
|
||||
result := global.Db
|
||||
if hospitalRequest.HospitalName != "" {
|
||||
result = result.Where("hospital_name like ?", "%"+hospitalRequest.HospitalName+"%")
|
||||
}
|
||||
|
||||
if hospitalRequest.HospitalLevelName != "" {
|
||||
result = result.Where("hospital_level_name like ?", "%"+hospitalRequest.HospitalLevelName+"%")
|
||||
}
|
||||
|
||||
if hospitalRequest.ProvinceId != 0 {
|
||||
result = result.Where("province_id = ?", hospitalRequest.ProvinceId)
|
||||
}
|
||||
|
||||
if hospitalRequest.Province != "" {
|
||||
result = result.Where("province like ?", "%"+hospitalRequest.Province+"%")
|
||||
}
|
||||
|
||||
if hospitalRequest.CityId != 0 {
|
||||
result = result.Where("city_id = ?", hospitalRequest.CityId)
|
||||
}
|
||||
|
||||
if hospitalRequest.City != "" {
|
||||
result = result.Where("city like ?", "%"+hospitalRequest.City+"%")
|
||||
}
|
||||
|
||||
if hospitalRequest.CountyId != 0 {
|
||||
result = result.Where("county_id = ?", hospitalRequest.CountyId)
|
||||
}
|
||||
|
||||
if hospitalRequest.County != "" {
|
||||
result = result.Where("county like ?", "%"+hospitalRequest.County+"%")
|
||||
}
|
||||
|
||||
err = result.Limit(10).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
17
api/requests/hospital.go
Normal file
17
api/requests/hospital.go
Normal file
@ -0,0 +1,17 @@
|
||||
package requests
|
||||
|
||||
type HospitalRequest struct {
|
||||
GetHospitalLimit // 获取医院列表-限制条数
|
||||
}
|
||||
|
||||
// GetHospitalLimit 获取医院列表-限制条数
|
||||
type GetHospitalLimit struct {
|
||||
HospitalName string `json:"hospital_name" form:"hospital_name" label:"医院名称"`
|
||||
HospitalLevelName string `json:"hospital_level_name" form:"hospital_level_name" label:"医院等级名称"`
|
||||
ProvinceId int `json:"province_id" form:"province_id" label:"省份id"`
|
||||
Province string `json:"province" form:"province" label:"省份"`
|
||||
CityId int `json:"city_id" form:"city_id" label:"城市id"`
|
||||
City string `json:"city" form:"city" label:"城市"`
|
||||
CountyId int `json:"county_id" form:"county_id" label:"区县id"`
|
||||
County string `json:"county" form:"county" label:"区县"`
|
||||
}
|
||||
@ -2,7 +2,7 @@ package requests
|
||||
|
||||
type UserDoctorRequest struct {
|
||||
GetUserDoctorPage // 获取医生列表-分页
|
||||
PutPostUserDoctor // 修改医生
|
||||
PutUserDoctor // 修改医生
|
||||
}
|
||||
|
||||
// GetUserDoctorPage 获取医生列表-分页
|
||||
@ -23,11 +23,11 @@ type GetUserDoctorPage struct {
|
||||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation" form:"is_enterprise_deep_cooperation" label:"是否企业深度合作"` // (0:否 1:是)
|
||||
}
|
||||
|
||||
// PutPostUserDoctor 修改医生
|
||||
type PutPostUserDoctor struct {
|
||||
// PutUserDoctor 修改医生
|
||||
type PutUserDoctor struct {
|
||||
IsRecommend int `json:"is_recommend" form:"is_recommend" label:"是否首页推荐"` // (0:否 1:是)
|
||||
Avatar string `json:"avatar" form:"avatar" validate:"required" label:"头像"`
|
||||
DoctorTitle int `json:"doctor_title" form:"doctor_title" validate:"required oneof=1 2 3 4 5 6" label:"医生职称"` // (1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
DoctorTitle int `json:"doctor_title" form:"doctor_title" validate:"required,oneof=1 2 3 4 5 6" label:"医生职称"` // (1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
DepartmentCustomId string `json:"department_custom_id" form:"department_custom_id" validate:"required" label:"科室"`
|
||||
DepartmentCustomName string `json:"department_custom_name" form:"department_custom_name" validate:"required" label:"科室名称"` // (如未自己输入,填入标准科室名称)
|
||||
DepartmentCustomMobile string `json:"department_custom_mobile" form:"department_custom_mobile" label:"科室电话"`
|
||||
|
||||
@ -49,3 +49,40 @@ func HospitalResponse(hospital *model.Hospital) *Hospital {
|
||||
UpdatedAt: hospital.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetHospitalLimitResponse 自定义列表
|
||||
func GetHospitalLimitResponse(hospitals []*model.Hospital) []Hospital {
|
||||
// 处理返回值
|
||||
getHospitalLimitResponses := make([]Hospital, len(hospitals))
|
||||
|
||||
if len(hospitals) > 0 {
|
||||
for i, v := range hospitals {
|
||||
// 将原始结构体转换为新结构体
|
||||
getHospitalLimitResponse := Hospital{
|
||||
HospitalID: strconv.FormatInt(v.HospitalID, 10),
|
||||
HospitalName: v.HospitalName,
|
||||
HospitalStatus: v.HospitalStatus,
|
||||
HospitalLevelName: v.HospitalLevelName,
|
||||
PostCode: v.PostCode,
|
||||
Telephone: v.HospitalName,
|
||||
ProvinceID: v.ProvinceId,
|
||||
Province: v.Province,
|
||||
CityID: v.CityId,
|
||||
City: v.City,
|
||||
CountyID: v.CountyId,
|
||||
County: v.County,
|
||||
Address: v.Address,
|
||||
Latitude: v.Lat,
|
||||
Longitude: v.HospitalName,
|
||||
Description: v.Desc,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
getHospitalLimitResponses[i] = getHospitalLimitResponse
|
||||
}
|
||||
}
|
||||
|
||||
return getHospitalLimitResponses
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
doctorGroup.GET("/:doctor_id", api.UserDoctor.GetPostUserDoctor)
|
||||
|
||||
// 修改医生
|
||||
doctorGroup.PUT("/:doctor_id", api.UserDoctor.PutPostUserDoctor)
|
||||
doctorGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctor)
|
||||
|
||||
// // 新增医生
|
||||
// doctorGroup.POST("", api.Post.AddPost)
|
||||
@ -259,4 +259,11 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
customGroup.GET("/list", api.Department.GetDepartmentCustomList)
|
||||
}
|
||||
}
|
||||
|
||||
// 医院管理-基础数据
|
||||
hospitalGroup := adminGroup.Group("/hospital")
|
||||
{
|
||||
// 获取医院列表-限制条数
|
||||
hospitalGroup.GET("/list", api.Hospital.GetHospitalLimit)
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ import (
|
||||
type UserDoctorService struct {
|
||||
}
|
||||
|
||||
// PutPostUserDoctor 修改医生
|
||||
func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest requests.PutPostUserDoctor) (bool, error) {
|
||||
// PutUserDoctor 修改医生
|
||||
func (r *UserDoctorService) PutUserDoctor(doctorId int64, userDoctorRequest requests.PutUserDoctor) (bool, error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||
@ -30,10 +30,10 @@ func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest
|
||||
}
|
||||
|
||||
// 医生数据
|
||||
var userDoctorData map[string]interface{}
|
||||
userDoctorData := make(map[string]interface{})
|
||||
|
||||
// 医生详情数据
|
||||
var userDoctorInfoData map[string]interface{}
|
||||
userDoctorInfoData := make(map[string]interface{})
|
||||
|
||||
// 处理头像
|
||||
userDoctorRequest.Avatar = strings.Replace(userDoctorRequest.Avatar, config.C.Oss.OssCustomDomainName, "", 1)
|
||||
@ -167,6 +167,10 @@ func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest
|
||||
}
|
||||
|
||||
// 处理身份证正面图片
|
||||
if userDoctorInfo.IdCardFront != "" && userDoctorRequest.IdCardFront == "" {
|
||||
return false, errors.New("未上传新的身份证图片")
|
||||
}
|
||||
|
||||
if userDoctorRequest.IdCardFront != "" {
|
||||
idCardFront := strings.Replace(userDoctorRequest.IdCardFront, "https://img.applets.igandanyiyuan.com", "", 1)
|
||||
if idCardFront != userDoctorInfo.IdCardFront {
|
||||
@ -175,6 +179,9 @@ func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest
|
||||
}
|
||||
|
||||
// 身份证背面图片
|
||||
if userDoctorInfo.IdCardBack != "" && userDoctorRequest.IdCardBack == "" {
|
||||
return false, errors.New("未上传新的身份证图片")
|
||||
}
|
||||
if userDoctorRequest.IdCardBack != "" {
|
||||
idCardBack := strings.Replace(userDoctorRequest.IdCardBack, "https://img.applets.igandanyiyuan.com", "", 1)
|
||||
if idCardBack != userDoctorInfo.IdCardBack {
|
||||
@ -183,6 +190,9 @@ func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest
|
||||
}
|
||||
|
||||
// 签名图片
|
||||
if userDoctorInfo.SignImage != "" && userDoctorRequest.SignImage == "" {
|
||||
return false, errors.New("未上传新的签名图片")
|
||||
}
|
||||
if userDoctorRequest.SignImage != "" {
|
||||
signImage := strings.Replace(userDoctorRequest.SignImage, "https://img.applets.igandanyiyuan.com", "", 1)
|
||||
if signImage != userDoctorInfo.SignImage {
|
||||
@ -227,6 +237,10 @@ func (r *UserDoctorService) PutPostUserDoctor(doctorId int64, userDoctorRequest
|
||||
}
|
||||
}
|
||||
|
||||
// 判断头像是否修改,同步修改im
|
||||
// 判断科室是否修改,同步修改ca平台
|
||||
// 判断签名图片是否修改,同步修改ca平台
|
||||
|
||||
// _, ok := userDoctorData["department_custom_id"]
|
||||
// if ok {
|
||||
// // 变更科室
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user