新增医生详情修改im请求问题
This commit is contained in:
parent
54feddd429
commit
a5522bcb63
@ -223,13 +223,13 @@ func (r *UserDoctor) GetUserDoctorPending(c *gin.Context) {
|
|||||||
// PutUserDoctorPending 审核-审核医生
|
// PutUserDoctorPending 审核-审核医生
|
||||||
func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
||||||
userDoctorRequest := requests.UserDoctorRequest{}
|
userDoctorRequest := requests.UserDoctorRequest{}
|
||||||
if err := c.ShouldBindJSON(&userDoctorRequest.PutUserDoctor); err != nil {
|
if err := c.ShouldBind(&userDoctorRequest.PutUserDoctorPending); err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数验证
|
// 参数验证
|
||||||
if err := global.Validate.Struct(userDoctorRequest.PutUserDoctor); err != nil {
|
if err := global.Validate.Struct(userDoctorRequest.PutUserDoctorPending); err != nil {
|
||||||
responses.FailWithMessage(utils.Translate(err), c)
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
|||||||
|
|
||||||
// 业务处理
|
// 业务处理
|
||||||
userDoctorService := service.UserDoctorService{}
|
userDoctorService := service.UserDoctorService{}
|
||||||
_, err = userDoctorService.PutUserDoctor(doctorId, userDoctorRequest.PutUserDoctor)
|
_, err = userDoctorService.PutUserDoctorPending(doctorId, userDoctorRequest.PutUserDoctorPending)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// DoctorIdenFail 医生身份审核失败原因表
|
// DoctorIdenFail 医生身份审核失败原因表
|
||||||
type DoctorIdenFail struct {
|
type DoctorIdenFail struct {
|
||||||
IdenFailId int64 `gorm:"column:iden_fail_id;type:bigint(19);primary_key;comment:主键id" json:"iden_fail_id"`
|
IdenFailId int64 `gorm:"column:iden_fail_id;type:bigint(19);primary_key;comment:主键id" json:"iden_fail_id"`
|
||||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||||
FieldName string `gorm:"column:field_name;type:varchar(50);comment:字段名称" json:"field_name"`
|
FieldName string `gorm:"column:field_name;type:varchar(50);comment:字段名称" json:"field_name"`
|
||||||
FailReason string `gorm:"column:fail_reason;type:varchar(255);comment:失败原因" json:"fail_reason"`
|
FailReason string `gorm:"column:fail_reason;type:varchar(255);comment:失败原因" json:"fail_reason"`
|
||||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at"`
|
Model
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;comment:修改时间" json:"updated_at"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DoctorIdenFail) TableName() string {
|
func (m *DoctorIdenFail) TableName() string {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ type UserDoctorRequest struct {
|
|||||||
PutUserDoctor // 修改医生
|
PutUserDoctor // 修改医生
|
||||||
AddUserDoctor // 新增医生
|
AddUserDoctor // 新增医生
|
||||||
GetUserDoctorPendingPage // 审核-获取医生列表-分页
|
GetUserDoctorPendingPage // 审核-获取医生列表-分页
|
||||||
|
PutUserDoctorPending // 审核-审核医生
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserDoctorPage 获取医生列表-分页
|
// GetUserDoctorPage 获取医生列表-分页
|
||||||
@ -41,7 +42,6 @@ type PutUserDoctor struct {
|
|||||||
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
||||||
LicenseCert []string `json:"license_cert" form:"license_cert" label:"医师执业证"`
|
LicenseCert []string `json:"license_cert" form:"license_cert" label:"医师执业证"`
|
||||||
QualificationCert []string `json:"qualification_cert" form:"qualification_cert" label:"医师资格证"`
|
QualificationCert []string `json:"qualification_cert" form:"qualification_cert" label:"医师资格证"`
|
||||||
QualificationCertNum string `json:"qualification_cert_num" form:"qualification_cert_num" label:"医师资格证号"`
|
|
||||||
WorkCert []string `json:"work_cert" form:"work_cert" label:"医师工作证"`
|
WorkCert []string `json:"work_cert" form:"work_cert" label:"医师工作证"`
|
||||||
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
||||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||||
@ -66,7 +66,6 @@ type AddUserDoctor struct {
|
|||||||
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
||||||
LicenseCert []string `json:"license_cert" form:"license_cert" validate:"required" label:"医师执业证"`
|
LicenseCert []string `json:"license_cert" form:"license_cert" validate:"required" label:"医师执业证"`
|
||||||
QualificationCert []string `json:"qualification_cert" form:"qualification_cert" validate:"required" label:"医师资格证"`
|
QualificationCert []string `json:"qualification_cert" form:"qualification_cert" validate:"required" label:"医师资格证"`
|
||||||
QualificationCertNum string `json:"qualification_cert_num" form:"qualification_cert_num" validate:"required" label:"医师资格证号"`
|
|
||||||
WorkCert []string `json:"work_cert" form:"work_cert" validate:"required" label:"医师工作证"`
|
WorkCert []string `json:"work_cert" form:"work_cert" validate:"required" label:"医师工作证"`
|
||||||
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
||||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||||
@ -87,7 +86,8 @@ type GetUserDoctorPendingPage struct {
|
|||||||
|
|
||||||
// PutUserDoctorPending 审核-审核医生
|
// PutUserDoctorPending 审核-审核医生
|
||||||
type PutUserDoctorPending struct {
|
type PutUserDoctorPending struct {
|
||||||
IdenAuthStatus int `json:"iden_auth_status" form:"iden_auth_status" label:"认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败)
|
IdenAuthStatus int `json:"iden_auth_status" form:"iden_auth_status" validate:"required,oneof=1 3" label:"认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||||
|
QualificationCertNum string `json:"qualification_cert_num" form:"qualification_cert_num" label:"医师资格证号"`
|
||||||
AvatarReason string `json:"avatar_reason" form:"avatar_reason" label:"头像失败原因"`
|
AvatarReason string `json:"avatar_reason" form:"avatar_reason" label:"头像失败原因"`
|
||||||
DepartmentCustomMobileReason string `json:"department_custom_mobile_reason" form:"department_custom_mobile_reason" label:"科室电话失败原因"`
|
DepartmentCustomMobileReason string `json:"department_custom_mobile_reason" form:"department_custom_mobile_reason" label:"科室电话失败原因"`
|
||||||
DepartmentCustomNameReason string `json:"department_custom_name_reason" form:"department_custom_name_reason" label:"科室名称失败原因"`
|
DepartmentCustomNameReason string `json:"department_custom_name_reason" form:"department_custom_name_reason" label:"科室名称失败原因"`
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import (
|
|||||||
"hospital-admin-api/utils"
|
"hospital-admin-api/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserDoctorService struct {
|
type UserDoctorService struct {
|
||||||
@ -251,15 +252,6 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
userDoctorInfoData["qualification_cert"] = qualificationCert
|
userDoctorInfoData["qualification_cert"] = qualificationCert
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理医师资格证号
|
|
||||||
if userDoctorInfo != nil {
|
|
||||||
if userDoctorInfo.QualificationCertNum != putUserDoctorRequest.QualificationCertNum {
|
|
||||||
userDoctorInfoData["qualification_cert_num"] = putUserDoctorRequest.QualificationCertNum
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
userDoctorInfoData["qualification_cert_num"] = putUserDoctorRequest.QualificationCertNum
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理医师工作证
|
// 处理医师工作证
|
||||||
var workCert string
|
var workCert string
|
||||||
if len(putUserDoctorRequest.WorkCert) > 0 {
|
if len(putUserDoctorRequest.WorkCert) > 0 {
|
||||||
@ -421,7 +413,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
res, err := tencentIm.SetProfile(strconv.FormatInt(userDoctor.UserId, 10), profileItem)
|
res, err := tencentIm.SetProfile(strconv.FormatInt(userDoctor.UserId, 10), profileItem)
|
||||||
if err != nil || res != true {
|
if err != nil || res != true {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return false, errors.New("头像设置失败")
|
return false, errors.New(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,20 +737,19 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
|||||||
|
|
||||||
// 新增医生详情表
|
// 新增医生详情表
|
||||||
userDoctorInfo := &model.UserDoctorInfo{
|
userDoctorInfo := &model.UserDoctorInfo{
|
||||||
UserId: user.UserId,
|
UserId: user.UserId,
|
||||||
DoctorId: userDoctor.DoctorId,
|
DoctorId: userDoctor.DoctorId,
|
||||||
CardType: 1,
|
CardType: 1,
|
||||||
CardName: a.CardName,
|
CardName: a.CardName,
|
||||||
CardNameMask: cardNameMask,
|
CardNameMask: cardNameMask,
|
||||||
CardNum: a.CardNum,
|
CardNum: a.CardNum,
|
||||||
CardNumMask: cardNumMask,
|
CardNumMask: cardNumMask,
|
||||||
LicenseCert: licenseCert,
|
LicenseCert: licenseCert,
|
||||||
QualificationCert: qualificationCert,
|
QualificationCert: qualificationCert,
|
||||||
QualificationCertNum: a.QualificationCertNum,
|
WorkCert: workCert,
|
||||||
WorkCert: workCert,
|
IdCardFront: idCardFront,
|
||||||
IdCardFront: idCardFront,
|
IdCardBack: idCardBack,
|
||||||
IdCardBack: idCardBack,
|
SignImage: signImage,
|
||||||
SignImage: signImage,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
userDoctorInfo, err = userDoctorInfoDao.AddUserDoctorInfo(tx, userDoctorInfo)
|
userDoctorInfo, err = userDoctorInfoDao.AddUserDoctorInfo(tx, userDoctorInfo)
|
||||||
@ -964,3 +955,198 @@ func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorR
|
|||||||
|
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutUserDoctorPending 审核-审核医生
|
||||||
|
func (r *UserDoctorService) PutUserDoctorPending(doctorId int64, req requests.PutUserDoctorPending) (bool, error) {
|
||||||
|
// 获取医生数据
|
||||||
|
userDoctorDao := dao.UserDoctorDao{}
|
||||||
|
userDoctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||||
|
if err != nil || userDoctor == nil {
|
||||||
|
return false, errors.New("医生数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生详情数据
|
||||||
|
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||||
|
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByDoctorId(doctorId)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New("医生详情数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||||
|
if err != nil || user == nil {
|
||||||
|
return false, errors.New("医生数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.IdenAuthStatus == 1 {
|
||||||
|
return false, errors.New("已审核成功,无法进行操作")
|
||||||
|
}
|
||||||
|
|
||||||
|
userDoctorData := make(map[string]interface{}) // 医生数据
|
||||||
|
userDoctorInfoData := make(map[string]interface{}) // 医生详情数据
|
||||||
|
|
||||||
|
if req.IdenAuthStatus == 1 && req.QualificationCertNum == "" {
|
||||||
|
return false, errors.New("缺少医师资格证号,无法审核通过")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.IdenAuthStatus == req.IdenAuthStatus {
|
||||||
|
return false, errors.New("请勿重复操作")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始事务
|
||||||
|
tx := global.Db.Begin()
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
doctorIdenFailDao := dao.DoctorIdenFailDao{}
|
||||||
|
|
||||||
|
userDoctorData["iden_auth_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
|
// 审核不通过
|
||||||
|
if req.IdenAuthStatus == 3 {
|
||||||
|
userDoctorData["iden_auth_status"] = 3
|
||||||
|
|
||||||
|
if req.AvatarReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "avatar",
|
||||||
|
FailReason: req.AvatarReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DepartmentCustomMobileReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "department_custom_mobile",
|
||||||
|
FailReason: req.DepartmentCustomMobileReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DepartmentCustomNameReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "department_custom_name",
|
||||||
|
FailReason: req.DepartmentCustomNameReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.BriefIntroductionReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "brief_introduction",
|
||||||
|
FailReason: req.BriefIntroductionReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.BeGoodAtReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "be_good_at_reason",
|
||||||
|
FailReason: req.BeGoodAtReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.LicenseCertReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "license_cert_reason",
|
||||||
|
FailReason: req.LicenseCertReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.QualificationCertReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "qualification_cert_reason",
|
||||||
|
FailReason: req.QualificationCertReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.WorkCertReason != "" {
|
||||||
|
doctorIdenFail := &model.DoctorIdenFail{
|
||||||
|
DoctorId: doctorId,
|
||||||
|
FieldName: "work_cert_reason",
|
||||||
|
FailReason: req.WorkCertReason,
|
||||||
|
}
|
||||||
|
doctorIdenFail, err = doctorIdenFailDao.AddDoctorIdenFail(tx, doctorIdenFail)
|
||||||
|
if err != nil || doctorIdenFail == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核通过
|
||||||
|
if req.IdenAuthStatus == 1 {
|
||||||
|
userDoctorData["iden_auth_status"] = 1
|
||||||
|
userDoctorInfoData["qualification_cert_num"] = req.QualificationCertNum
|
||||||
|
|
||||||
|
// 审核通过删除所有不通过原因数据
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["doctor_id"] = doctorId
|
||||||
|
err := doctorIdenFailDao.DeleteDoctorIdenFail(tx, maps)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改医生数据
|
||||||
|
err = userDoctorDao.EditUserDoctorById(tx, doctorId, userDoctorData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改医生详情数据
|
||||||
|
if len(userDoctorInfoData) != 0 {
|
||||||
|
err = userDoctorInfoDao.EditUserDoctorInfoById(tx, userDoctorInfo.DoctorInfoId, userDoctorInfoData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ func postRequest(url string, requestBody []byte) (map[string]interface{}, error)
|
|||||||
return nil, errors.New("请求im失败")
|
return nil, errors.New("请求im失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
if errorCode, ok := responseMap["ErrorCode"]; ok {
|
if errorCode, ok := responseMap["ErrorCode"].(int); ok {
|
||||||
if errorCode != 0 {
|
if errorCode != 0 {
|
||||||
if errorInfo, ok := responseMap["ErrorInfo"].(string); ok {
|
if errorInfo, ok := responseMap["ErrorInfo"].(string); ok {
|
||||||
return nil, errors.New(errorInfo)
|
return nil, errors.New(errorInfo)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user