新增审核多点,修改医生多点处理
This commit is contained in:
parent
c9efce7bb6
commit
0bc6cf35d6
@ -316,7 +316,7 @@ func (r *UserDoctor) GetMulti(c *gin.Context) {
|
|||||||
|
|
||||||
// 业务处理
|
// 业务处理
|
||||||
userDoctorService := service.UserDoctorService{}
|
userDoctorService := service.UserDoctorService{}
|
||||||
g, err := userDoctorService.GetUserDoctorPending(doctorId)
|
g, err := userDoctorService.GetMulti(doctorId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
@ -324,3 +324,41 @@ func (r *UserDoctor) GetMulti(c *gin.Context) {
|
|||||||
|
|
||||||
responses.OkWithData(g, c)
|
responses.OkWithData(g, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutMulti 多点-审核医生
|
||||||
|
func (r *UserDoctor) PutMulti(c *gin.Context) {
|
||||||
|
userDoctorRequest := requests.UserDoctorRequest{}
|
||||||
|
if err := c.ShouldBind(&userDoctorRequest.PutMulti); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(userDoctorRequest.PutMulti); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
id := c.Param("doctor_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
doctorId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务处理
|
||||||
|
userDoctorService := service.UserDoctorService{}
|
||||||
|
_, err = userDoctorService.PutMulti(doctorId, userDoctorRequest.PutMulti)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.Ok(c)
|
||||||
|
}
|
||||||
|
|||||||
53
api/dao/hospitalDepartment.go
Normal file
53
api/dao/hospitalDepartment.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HospitalDepartment struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHospitalDepartmentById 获取科室数据-科室id
|
||||||
|
func (r *HospitalDepartment) GetHospitalDepartmentById(departmentId int64) (m *model.HospitalDepartment, err error) {
|
||||||
|
err = global.Db.First(&m, departmentId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddHospitalDepartment 新增科室
|
||||||
|
func (r *HospitalDepartment) AddHospitalDepartment(tx *gorm.DB, model *model.HospitalDepartment) (*model.HospitalDepartment, error) {
|
||||||
|
if err := tx.Create(model).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHospitalDepartmentList 获取科室列表
|
||||||
|
func (r *HospitalDepartment) GetHospitalDepartmentList(maps interface{}) (m []*model.HospitalDepartment, err error) {
|
||||||
|
err = global.Db.Where(maps).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteHospitalDepartmentById 删除科室-科室id
|
||||||
|
func (r *HospitalDepartment) DeleteHospitalDepartmentById(tx *gorm.DB, departmentId int64) error {
|
||||||
|
if err := tx.Delete(&model.HospitalDepartment{}, departmentId).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditHospitalDepartmentById 修改科室-科室id
|
||||||
|
func (r *HospitalDepartment) EditHospitalDepartmentById(tx *gorm.DB, departmentId int64, data interface{}) error {
|
||||||
|
err := tx.Model(&model.HospitalDepartment{}).Where("department_id = ?", departmentId).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
34
api/model/hospitalDepartment.go
Normal file
34
api/model/hospitalDepartment.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/bwmarrin/snowflake"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HospitalDepartment 医院科室表-标准
|
||||||
|
type HospitalDepartment struct {
|
||||||
|
DepartmentId int64 `gorm:"column:department_id;type:bigint(19);primary_key;comment:主键id" json:"department_id"`
|
||||||
|
DepartmentName string `gorm:"column:department_name;type:varchar(255);comment:科室名称" json:"department_name"`
|
||||||
|
DepartmentCode string `gorm:"column:department_code;type:varchar(100);comment:科室代码" json:"department_code"`
|
||||||
|
DepartmentType int `gorm:"column:department_type;type:tinyint(1);default:0;comment:科室类型(0:未知 1:肝脏病)" json:"department_type"`
|
||||||
|
Model
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HospitalDepartment) TableName() string {
|
||||||
|
return "gdxz_hospital_department"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HospitalDepartment) BeforeCreate(tx *gorm.DB) error {
|
||||||
|
if m.DepartmentId == 0 {
|
||||||
|
// 创建雪花算法实例
|
||||||
|
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成新的雪花算法 ID
|
||||||
|
m.DepartmentId = sf.Generate().Int64()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
// UserCaCert 医师/药师ca监管证书表
|
// UserCaCert 医师/药师ca监管证书表
|
||||||
type UserCaCert struct {
|
type UserCaCert struct {
|
||||||
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
||||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(系统证书时为null)" json:"user_id"`
|
UserId *int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(系统证书时为null)" json:"user_id"`
|
||||||
IsSystem int `gorm:"column:is_system;type:tinyint(1);default:0;comment:是否系统证书(0:否 1:是)" json:"is_system"`
|
IsSystem int `gorm:"column:is_system;type:tinyint(1);default:0;comment:是否系统证书(0:否 1:是)" json:"is_system"`
|
||||||
Type int `gorm:"column:type;type:tinyint(1);comment:证书类型(1:线下 2:线上)" json:"type"`
|
Type int `gorm:"column:type;type:tinyint(1);comment:证书类型(1:线下 2:线上)" json:"type"`
|
||||||
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
||||||
|
|||||||
@ -7,6 +7,7 @@ type UserDoctorRequest struct {
|
|||||||
GetUserDoctorPendingPage // 身份审核-获取医生列表-分页
|
GetUserDoctorPendingPage // 身份审核-获取医生列表-分页
|
||||||
PutUserDoctorPending // 身份审核-审核医生
|
PutUserDoctorPending // 身份审核-审核医生
|
||||||
GetMultiPage // 多点-获取医生列表-分页
|
GetMultiPage // 多点-获取医生列表-分页
|
||||||
|
PutMulti // 多点-审核医生
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserDoctorPage 获取医生列表-分页
|
// GetUserDoctorPage 获取医生列表-分页
|
||||||
@ -108,3 +109,9 @@ type GetMultiPage struct {
|
|||||||
HospitalName string `json:"hospital_name" form:"hospital_name" label:"医院名称"`
|
HospitalName string `json:"hospital_name" form:"hospital_name" label:"医院名称"`
|
||||||
MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"医生多点执业认证状态"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"医生多点执业认证状态"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutMulti 多点-审核医生
|
||||||
|
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:"多点执业认证失败原因"`
|
||||||
|
}
|
||||||
|
|||||||
@ -178,28 +178,27 @@ type IdenAuthFailReason struct {
|
|||||||
|
|
||||||
// GetMulti 多点-医生详情
|
// GetMulti 多点-医生详情
|
||||||
type GetMulti struct {
|
type GetMulti struct {
|
||||||
DoctorID string `json:"doctor_id"` // 主键id
|
DoctorID string `json:"doctor_id"` // 主键id
|
||||||
UserID string `json:"user_id"` // 用户id
|
UserID string `json:"user_id"` // 用户id
|
||||||
UserName string `json:"user_name"` // 用户名称
|
UserName string `json:"user_name"` // 用户名称
|
||||||
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
||||||
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||||
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
||||||
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
||||||
Avatar string `json:"avatar"` // 头像
|
Avatar string `json:"avatar"` // 头像
|
||||||
DoctorTitle int `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
DoctorTitle int `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||||
DepartmentCustomID string `json:"department_custom_id"` // 科室id-自定义
|
DepartmentCustomID string `json:"department_custom_id"` // 科室id-自定义
|
||||||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||||||
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
||||||
HospitalID string `json:"hospital_id"` // 所属医院id
|
HospitalID string `json:"hospital_id"` // 所属医院id
|
||||||
BeGoodAt string `json:"be_good_at"` // 擅长
|
BeGoodAt string `json:"be_good_at"` // 擅长
|
||||||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
User *userResponse.User `json:"user"` // 用户
|
User *userResponse.User `json:"user"` // 用户
|
||||||
Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院
|
Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院
|
||||||
UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情
|
UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情
|
||||||
DoctorExpertise []*doctorExpertiseResponse.DoctorExpertise `json:"doctor_expertise"` // 医生专长
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserDoctorPageResponse 获取用户列表-分页
|
// GetUserDoctorPageResponse 获取用户列表-分页
|
||||||
|
|||||||
@ -351,7 +351,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
doctorMultiGroup.GET("/:doctor_id", api.UserDoctor.GetMulti)
|
doctorMultiGroup.GET("/:doctor_id", api.UserDoctor.GetMulti)
|
||||||
|
|
||||||
// 多点-审核医生
|
// 多点-审核医生
|
||||||
doctorMultiGroup.PUT("/:doctor_id", api.UserDoctor.GetMultiPage)
|
doctorMultiGroup.PUT("/:doctor_id", api.UserDoctor.PutMulti)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
// 获取用户数据
|
// 获取用户数据
|
||||||
userDao := dao.UserDao{}
|
userDao := dao.UserDao{}
|
||||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
user, err := userDao.GetUserById(userDoctor.UserId)
|
||||||
if err != nil {
|
if err != nil && user == nil {
|
||||||
return false, errors.New("医生数据错误")
|
return false, errors.New("医生数据错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,6 +177,27 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改科室数据,重新认定为未审核
|
||||||
|
if userDoctor.DepartmentCustomId != departmentCustomId {
|
||||||
|
// 检测是否存在正在审核中的处方
|
||||||
|
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||||
|
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["doctor_id"] = doctorId
|
||||||
|
maps["prescription_status"] = 1
|
||||||
|
orderPrescription, err := orderPrescriptionDao.GetList(maps)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New("修改失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(orderPrescription) > 0 {
|
||||||
|
return false, errors.New("存在审核中的处方,请勿修改科室数据")
|
||||||
|
}
|
||||||
|
|
||||||
|
userDoctorData["multi_point_status"] = 2
|
||||||
|
userDoctorData["multi_point_fail_reason"] = ""
|
||||||
|
}
|
||||||
|
|
||||||
// 处理科室电话
|
// 处理科室电话
|
||||||
if userDoctor.DepartmentCustomMobile != putUserDoctorRequest.DepartmentCustomMobile {
|
if userDoctor.DepartmentCustomMobile != putUserDoctorRequest.DepartmentCustomMobile {
|
||||||
userDoctorData["department_custom_id"] = putUserDoctorRequest.DepartmentCustomMobile
|
userDoctorData["department_custom_id"] = putUserDoctorRequest.DepartmentCustomMobile
|
||||||
@ -310,62 +331,14 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
return false, errors.New("未上传新的签名图片")
|
return false, errors.New("未上传新的签名图片")
|
||||||
}
|
}
|
||||||
if putUserDoctorRequest.SignImage != "" {
|
if putUserDoctorRequest.SignImage != "" {
|
||||||
signImage := strings.Replace(putUserDoctorRequest.SignImage, "https://img.applets.igandanyiyuan.com", "", 1)
|
signImage := utils.RemoveOssDomain(putUserDoctorRequest.SignImage)
|
||||||
if signImage != userDoctorInfo.SignImage {
|
if signImage != userDoctorInfo.SignImage {
|
||||||
if userDoctor.MultiPointStatus == 2 {
|
if userDoctor.MultiPointStatus == 2 {
|
||||||
return false, errors.New("多点执业审核中,请操作后进行修改")
|
return false, errors.New("多点执业审核中,请操作后进行修改")
|
||||||
}
|
}
|
||||||
|
|
||||||
userDoctorInfoData["sign_image"] = signImage
|
userDoctorInfoData["sign_image"] = signImage
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理专长
|
|
||||||
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
|
||||||
// 检测专长是否存在
|
|
||||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
|
||||||
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
|
||||||
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.New("专长错误")
|
|
||||||
}
|
|
||||||
|
|
||||||
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
|
||||||
if err != nil || diseaseClassExpertise == nil {
|
|
||||||
return false, errors.New("专长数据错误")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理多点问题
|
|
||||||
fieldsToCheck := []string{"id_card_front", "id_card_back", "sign_image"}
|
|
||||||
|
|
||||||
exists := false
|
|
||||||
for _, field := range fieldsToCheck {
|
|
||||||
if _, ok := userDoctorInfoData[field]; ok {
|
|
||||||
exists = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
idCardFront := userDoctorInfo.IdCardFront
|
|
||||||
idCardBack := userDoctorInfo.IdCardBack
|
|
||||||
signImage := userDoctorInfo.SignImage
|
|
||||||
|
|
||||||
if _, ok := userDoctorInfoData["id_card_front"]; ok {
|
|
||||||
idCardFront = userDoctorInfoData["id_card_front"].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := userDoctorInfoData["id_card_back"]; ok {
|
|
||||||
idCardBack = userDoctorInfoData["id_card_back"].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := userDoctorInfoData["sign_image"]; ok {
|
|
||||||
signImage = userDoctorInfoData["sign_image"].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if idCardFront != "" && idCardBack != "" && signImage != "" {
|
|
||||||
// 检测是否存在正在审核中的处方
|
// 检测是否存在正在审核中的处方
|
||||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||||
|
|
||||||
@ -387,6 +360,23 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理专长
|
||||||
|
if len(putUserDoctorRequest.DoctorExpertise) > 0 {
|
||||||
|
// 检测专长是否存在
|
||||||
|
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||||
|
for _, v := range putUserDoctorRequest.DoctorExpertise {
|
||||||
|
expertiseId, err := strconv.ParseInt(v, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New("专长错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
diseaseClassExpertise, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseById(expertiseId)
|
||||||
|
if err != nil || diseaseClassExpertise == nil {
|
||||||
|
return false, errors.New("专长数据错误")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 开始事务
|
// 开始事务
|
||||||
tx := global.Db.Begin()
|
tx := global.Db.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -482,108 +472,47 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, putUserDoctorRequest r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断科室是否修改,同步修改ca平台
|
// 处理签名图片-如果更改,查看是否已添加签章配置,会进行删除
|
||||||
if userDoctor.DepartmentCustomId != departmentCustomId {
|
if putUserDoctorRequest.SignImage != "" {
|
||||||
// 获取科室数据
|
signImage := utils.RemoveOssDomain(putUserDoctorRequest.SignImage)
|
||||||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustom{}
|
if signImage != userDoctorInfo.SignImage {
|
||||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(departmentCustomId)
|
// 检测是否存在云证书
|
||||||
if err != nil || hospitalDepartmentCustom == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New("科室错误")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取云证书数据
|
|
||||||
userCaCertDao := dao.UserCaCert{}
|
|
||||||
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
|
||||||
if err != nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New("修改失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
if userCaCerts != nil && len(userCaCerts) > 0 {
|
|
||||||
// 修改云证书
|
|
||||||
editCloudCertRequestData := &ca.EditCloudCertRequestData{
|
|
||||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
EntityType: "Personal",
|
|
||||||
PersonalPhone: user.Mobile,
|
|
||||||
PersonalName: userDoctorInfo.CardName,
|
|
||||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
|
||||||
OrgName: "",
|
|
||||||
OrgNumber: "",
|
|
||||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
OrgDept: hospitalDepartmentCustom.DepartmentName, // // 卫生证书:医院部门
|
|
||||||
Province: "四川省",
|
|
||||||
Locality: "成都市",
|
|
||||||
AuthType: "实人认证",
|
|
||||||
// AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
|
||||||
AuthTime: "1688694270",
|
|
||||||
AuthResult: "认证通过",
|
|
||||||
AuthNoticeType: "数字证书变更告知",
|
|
||||||
}
|
|
||||||
|
|
||||||
editCloudCertResponse, err := ca.EditCloudCert(editCloudCertRequestData)
|
|
||||||
if err != nil || editCloudCertResponse == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改ca监管证书表
|
|
||||||
userCaCertDao := dao.UserCaCert{}
|
userCaCertDao := dao.UserCaCert{}
|
||||||
data := make(map[string]interface{})
|
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||||
data["cert_base64"] = editCloudCertResponse.CertBase64
|
|
||||||
data["cert_chain_p7"] = editCloudCertResponse.CertP7
|
|
||||||
data["cert_serial_number"] = editCloudCertResponse.CertP7
|
|
||||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCerts[0].CertId, data)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return false, errors.New("删除失败")
|
return false, errors.New("修改失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userCaCerts != nil && len(userCaCerts) > 0 {
|
||||||
|
userCaCert := userCaCerts[0]
|
||||||
|
// 检测是否已经添加签章配置
|
||||||
|
if userCaCert.IsSignConfig == 1 {
|
||||||
|
// 修改签章配置为未添加
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
data["is_sign_config"] = 0
|
||||||
|
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除签章配置
|
||||||
|
deleteUserSignConfigRequestData := &ca.DeleteUserSignConfigRequestData{
|
||||||
|
UserId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
ConfigKey: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := ca.DeleteUserSignConfig(deleteUserSignConfigRequestData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断签名图片是否修改,同步修改ca平台
|
|
||||||
// 1、新用户,未存在证书
|
|
||||||
// if putUserDoctorRequest.SignImage != "" {
|
|
||||||
// signImage := strings.Replace(putUserDoctorRequest.SignImage, "https://img.applets.igandanyiyuan.com", "", 1)
|
|
||||||
// if signImage != userDoctorInfo.SignImage {
|
|
||||||
// // 检测是否存在云证书
|
|
||||||
// userCaCertDao := dao.UserCaCert{}
|
|
||||||
// userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
|
||||||
// if err != nil {
|
|
||||||
// tx.Rollback()
|
|
||||||
// return false, errors.New("修改失败")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if userCaCerts != nil && len(userCaCerts) > 0 {
|
|
||||||
// userCaCert := userCaCerts[0]
|
|
||||||
// // 检测是否已经添加签章配置
|
|
||||||
// if userCaCert.IsSignConfig == 1 {
|
|
||||||
// // 修改签章配置为未添加
|
|
||||||
// data := make(map[string]interface{})
|
|
||||||
// data["is_sign_config"] = 0
|
|
||||||
// err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
|
||||||
// if err != nil {
|
|
||||||
// tx.Rollback()
|
|
||||||
// return false, errors.New(err.Error())
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 删除签章配置
|
|
||||||
// deleteUserSignConfigRequestData := &ca.DeleteUserSignConfigRequestData{
|
|
||||||
// UserId: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
// ConfigKey: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// _, err := ca.DeleteUserSignConfig(deleteUserSignConfigRequestData)
|
|
||||||
// if err != nil {
|
|
||||||
// tx.Rollback()
|
|
||||||
// return false, errors.New(err.Error())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -723,7 +652,7 @@ func (r *UserDoctorService) AddUserDoctor(userId string, a requests.AddUserDocto
|
|||||||
|
|
||||||
// 多点执业状态
|
// 多点执业状态
|
||||||
var multiPointStatus int
|
var multiPointStatus int
|
||||||
if a.IdCardFront != "" && a.IdCardBack != "" && a.SignImage != "" {
|
if a.IdCardFront != "" && a.IdCardBack != "" && a.SignImage != "" && departmentCustomId != 0 {
|
||||||
multiPointStatus = 2
|
multiPointStatus = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,14 +1186,6 @@ func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetM
|
|||||||
return nil, errors.New("用户数据错误")
|
return nil, errors.New("用户数据错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
userDoctorService := UserDoctorService{}
|
|
||||||
|
|
||||||
// 获取医生专长
|
|
||||||
doctorExpertise, err := userDoctorService.GetUserDoctorExpertiseByDoctorId(doctorId)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||||
if userDoctor.UserDoctorInfo != nil {
|
if userDoctor.UserDoctorInfo != nil {
|
||||||
@ -1305,8 +1226,181 @@ func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetM
|
|||||||
User: user,
|
User: user,
|
||||||
Hospital: hospital,
|
Hospital: hospital,
|
||||||
UserDoctorInfo: userDoctorInfo,
|
UserDoctorInfo: userDoctorInfo,
|
||||||
DoctorExpertise: doctorExpertise, // 专长
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutMulti 多点-审核医生
|
||||||
|
func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (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.MultiPointStatus == 1 {
|
||||||
|
return false, errors.New("已审核成功,无法进行操作")
|
||||||
|
}
|
||||||
|
|
||||||
|
userDoctorData := make(map[string]interface{}) // 医生数据
|
||||||
|
|
||||||
|
if userDoctor.IdenAuthStatus == req.MultiPointStatus {
|
||||||
|
return false, errors.New("请勿重复操作")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始事务
|
||||||
|
tx := global.Db.Begin()
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 检测是否存在云证书
|
||||||
|
userCaCertDao := dao.UserCaCert{}
|
||||||
|
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("修改失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取自定义科室数据
|
||||||
|
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustom{}
|
||||||
|
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(userDoctor.DepartmentCustomId)
|
||||||
|
if err != nil || hospitalDepartmentCustom == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取标准科室数据
|
||||||
|
hospitalDepartmentDao := dao.HospitalDepartment{}
|
||||||
|
hospitalDepartment, err := hospitalDepartmentDao.GetHospitalDepartmentById(hospitalDepartmentCustom.DepartmentId)
|
||||||
|
if err != nil || hospitalDepartment == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userCaCerts == nil && len(userCaCerts) == 0 {
|
||||||
|
// 申请云证书
|
||||||
|
cloudCertRequestData := &ca.AddCloudCertRequest{
|
||||||
|
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
EntityType: "Personal",
|
||||||
|
PersonalPhone: user.Mobile,
|
||||||
|
PersonalName: userDoctorInfo.CardName,
|
||||||
|
PersonalIdNumber: userDoctorInfo.CardNum,
|
||||||
|
OrgName: "",
|
||||||
|
OrgNumber: "",
|
||||||
|
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||||
|
Province: "四川省",
|
||||||
|
Locality: "成都市",
|
||||||
|
AuthType: "实人认证",
|
||||||
|
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
|
AuthResult: "认证通过",
|
||||||
|
AuthNoticeType: "数字证书申请告知",
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudCertResponse, err := ca.AddCloudCert(cloudCertRequestData)
|
||||||
|
if err != nil || cloudCertResponse == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增ca监管证书表
|
||||||
|
userCaCert := &model.UserCaCert{
|
||||||
|
UserId: &userDoctor.UserId,
|
||||||
|
IsSystem: 0,
|
||||||
|
Type: 1,
|
||||||
|
CertBase64: cloudCertResponse.CertBase64,
|
||||||
|
CertChainP7: cloudCertResponse.CertP7,
|
||||||
|
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
||||||
|
CaPin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
IsSignConfig: 0,
|
||||||
|
SignConfig: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
||||||
|
if err != nil || userCaCert == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 修改云证书
|
||||||
|
cloudCertRequestData := &ca.EditCloudCertRequestData{
|
||||||
|
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
EntityType: "Personal",
|
||||||
|
PersonalPhone: user.Mobile,
|
||||||
|
PersonalName: userDoctorInfo.CardName,
|
||||||
|
PersonalIdNumber: userDoctorInfo.CardNum,
|
||||||
|
OrgName: "",
|
||||||
|
OrgNumber: "",
|
||||||
|
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
||||||
|
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||||
|
Province: "四川省",
|
||||||
|
Locality: "成都市",
|
||||||
|
AuthType: "实人认证",
|
||||||
|
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
|
AuthResult: "认证通过",
|
||||||
|
AuthNoticeType: "数字证书变更告知",
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudCertResponse, err := ca.EditCloudCert(cloudCertRequestData)
|
||||||
|
if err != nil || cloudCertResponse == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改ca监管证书表
|
||||||
|
userCaCertDao := dao.UserCaCert{}
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
data["cert_base64"] = cloudCertResponse.CertBase64
|
||||||
|
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
||||||
|
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
||||||
|
err = userCaCertDao.EditUserCaCertById(tx, userCaCerts[0].CertId, data)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userDoctorData["multi_point_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
|
// 审核不通过
|
||||||
|
if req.MultiPointStatus == 3 {
|
||||||
|
userDoctorData["multi_point_status"] = 3
|
||||||
|
userDoctorData["multi_point_fail_reason"] = req.MultiPointFailReason
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核通过
|
||||||
|
if req.MultiPointStatus == 1 {
|
||||||
|
userDoctorData["multi_point_status"] = 1
|
||||||
|
userDoctorData["multi_point_fail_reason"] = ""
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改医生数据
|
||||||
|
err = userDoctorDao.EditUserDoctorById(tx, doctorId, userDoctorData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -25,8 +25,8 @@ type EditCloudCertRequestData struct {
|
|||||||
AuthNoticeType string `json:"authNoticeType"` // 委托鉴证告知类型[数字证书申请告知]
|
AuthNoticeType string `json:"authNoticeType"` // 委托鉴证告知类型[数字证书申请告知]
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCloudCertRequestData 新增云证书请求数据
|
// AddCloudCertRequest 新增云证书请求数据
|
||||||
type AddCloudCertRequestData struct {
|
type AddCloudCertRequest struct {
|
||||||
EntityId string `json:"entityId"` // 用户唯一标识,由业务系统定义
|
EntityId string `json:"entityId"` // 用户唯一标识,由业务系统定义
|
||||||
EntityType string `json:"entityType"` // 用户类型,可选值[Personal/Organizational]
|
EntityType string `json:"entityType"` // 用户类型,可选值[Personal/Organizational]
|
||||||
PersonalPhone string `json:"personalPhone"` // 联系人电话
|
PersonalPhone string `json:"personalPhone"` // 联系人电话
|
||||||
@ -153,9 +153,9 @@ func EditCloudCert(d *EditCloudCertRequestData) (*EditCloudCertResponse, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddCloudCert 新增云证书
|
// AddCloudCert 新增云证书
|
||||||
func AddCloudCert(d *AddCloudCertRequestData) (*AddCloudCertResponse, error) {
|
func AddCloudCert(d *AddCloudCertRequest) (*AddCloudCertResponse, error) {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
return nil, errors.New("修改云证书失败")
|
return nil, errors.New("获取云证书失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取签名
|
// 获取签名
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user