新增医生详情修改im请求问题
This commit is contained in:
+210
-24
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user