新增医生详情修改im请求问题
This commit is contained in:
parent
54feddd429
commit
a5522bcb63
@ -223,13 +223,13 @@ func (r *UserDoctor) GetUserDoctorPending(c *gin.Context) {
|
||||
// PutUserDoctorPending 审核-审核医生
|
||||
func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
||||
userDoctorRequest := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBindJSON(&userDoctorRequest.PutUserDoctor); err != nil {
|
||||
if err := c.ShouldBind(&userDoctorRequest.PutUserDoctorPending); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
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)
|
||||
return
|
||||
}
|
||||
@ -249,7 +249,7 @@ func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
||||
|
||||
// 业务处理
|
||||
userDoctorService := service.UserDoctorService{}
|
||||
_, err = userDoctorService.PutUserDoctor(doctorId, userDoctorRequest.PutUserDoctor)
|
||||
_, err = userDoctorService.PutUserDoctorPending(doctorId, userDoctorRequest.PutUserDoctorPending)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// DoctorIdenFail 医生身份审核失败原因表
|
||||
type DoctorIdenFail struct {
|
||||
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"`
|
||||
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"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;comment:修改时间" json:"updated_at"`
|
||||
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"`
|
||||
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"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorIdenFail) TableName() string {
|
||||
|
||||
@ -5,6 +5,7 @@ type UserDoctorRequest struct {
|
||||
PutUserDoctor // 修改医生
|
||||
AddUserDoctor // 新增医生
|
||||
GetUserDoctorPendingPage // 审核-获取医生列表-分页
|
||||
PutUserDoctorPending // 审核-审核医生
|
||||
}
|
||||
|
||||
// GetUserDoctorPage 获取医生列表-分页
|
||||
@ -41,7 +42,6 @@ type PutUserDoctor struct {
|
||||
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
||||
LicenseCert []string `json:"license_cert" form:"license_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:"医师工作证"`
|
||||
IdCardFront string `json:"id_card_front" form:"id_card_front" 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:"医生简介"`
|
||||
LicenseCert []string `json:"license_cert" form:"license_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:"医师工作证"`
|
||||
IdCardFront string `json:"id_card_front" form:"id_card_front" label:"身份证正面图片"`
|
||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||
@ -87,7 +86,8 @@ type GetUserDoctorPendingPage struct {
|
||||
|
||||
// PutUserDoctorPending 审核-审核医生
|
||||
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:"头像失败原因"`
|
||||
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:"科室名称失败原因"`
|
||||
|
||||
@ -18,6 +18,7 @@ import (
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserDoctorService struct {
|
||||
@ -251,15 +252,6 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
||||
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
|
||||
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)
|
||||
if err != nil || res != true {
|
||||
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{
|
||||
UserId: user.UserId,
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
CardType: 1,
|
||||
CardName: a.CardName,
|
||||
CardNameMask: cardNameMask,
|
||||
CardNum: a.CardNum,
|
||||
CardNumMask: cardNumMask,
|
||||
LicenseCert: licenseCert,
|
||||
QualificationCert: qualificationCert,
|
||||
QualificationCertNum: a.QualificationCertNum,
|
||||
WorkCert: workCert,
|
||||
IdCardFront: idCardFront,
|
||||
IdCardBack: idCardBack,
|
||||
SignImage: signImage,
|
||||
UserId: user.UserId,
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
CardType: 1,
|
||||
CardName: a.CardName,
|
||||
CardNameMask: cardNameMask,
|
||||
CardNum: a.CardNum,
|
||||
CardNumMask: cardNumMask,
|
||||
LicenseCert: licenseCert,
|
||||
QualificationCert: qualificationCert,
|
||||
WorkCert: workCert,
|
||||
IdCardFront: idCardFront,
|
||||
IdCardBack: idCardBack,
|
||||
SignImage: signImage,
|
||||
}
|
||||
|
||||
userDoctorInfo, err = userDoctorInfoDao.AddUserDoctorInfo(tx, userDoctorInfo)
|
||||
@ -964,3 +955,198 @@ func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorR
|
||||
|
||||
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失败")
|
||||
}
|
||||
|
||||
if errorCode, ok := responseMap["ErrorCode"]; ok {
|
||||
if errorCode, ok := responseMap["ErrorCode"].(int); ok {
|
||||
if errorCode != 0 {
|
||||
if errorInfo, ok := responseMap["ErrorInfo"].(string); ok {
|
||||
return nil, errors.New(errorInfo)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user