修改医生详情接口返回数据

This commit is contained in:
wucongxing 2023-10-27 14:47:37 +08:00
parent cb7807801e
commit 5e70c638c6
5 changed files with 83 additions and 19 deletions

View File

@ -6,11 +6,11 @@ import (
"hospital-admin-api/global"
)
type UserCaCert struct {
type UserCaCertDao struct {
}
// GetUserCaCertById 获取监管证书数据-监管证书id
func (r *UserCaCert) GetUserCaCertById(certId int64) (m *model.UserCaCert, err error) {
func (r *UserCaCertDao) GetUserCaCertById(certId int64) (m *model.UserCaCert, err error) {
err = global.Db.First(&m, certId).Error
if err != nil {
return nil, err
@ -19,7 +19,7 @@ func (r *UserCaCert) GetUserCaCertById(certId int64) (m *model.UserCaCert, err e
}
// GetUserCaCertByUserId 获取监管证书数据-监管证书id
func (r *UserCaCert) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, err error) {
func (r *UserCaCertDao) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, err error) {
err = global.Db.Where("user_id = ?", userId).First(&m).Error
if err != nil {
return nil, err
@ -28,7 +28,7 @@ func (r *UserCaCert) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, e
}
// GetUserCaCertListByUserId 获取监管证书数据-监管证书id
func (r *UserCaCert) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaCert, err error) {
func (r *UserCaCertDao) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaCert, err error) {
err = global.Db.Where("user_id = ?", userId).Find(&m).Error
if err != nil {
return nil, err
@ -37,7 +37,7 @@ func (r *UserCaCert) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaC
}
// AddUserCaCert 新增监管证书
func (r *UserCaCert) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model.UserCaCert, error) {
func (r *UserCaCertDao) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model.UserCaCert, error) {
if err := tx.Create(model).Error; err != nil {
return nil, err
}
@ -45,7 +45,7 @@ func (r *UserCaCert) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model
}
// GetUserCaCertList 获取监管证书列表
func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, err error) {
func (r *UserCaCertDao) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, err error) {
err = global.Db.Where(maps).Find(&m).Error
if err != nil {
return nil, err
@ -54,7 +54,7 @@ func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert,
}
// GetUserCaCert 获取监管证书
func (r *UserCaCert) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err error) {
func (r *UserCaCertDao) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err error) {
err = global.Db.Where(maps).First(&m).Error
if err != nil {
return nil, err
@ -63,7 +63,7 @@ func (r *UserCaCert) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err e
}
// DeleteUserCaCertById 删除监管证书-监管证书id
func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
func (r *UserCaCertDao) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
if err := tx.Delete(&model.UserCaCert{}, certId).Error; err != nil {
return err
}
@ -71,7 +71,7 @@ func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
}
// EditUserCaCertById 修改监管证书-监管证书id
func (r *UserCaCert) EditUserCaCertById(tx *gorm.DB, certId int64, data interface{}) error {
func (r *UserCaCertDao) EditUserCaCertById(tx *gorm.DB, certId int64, data interface{}) error {
err := tx.Model(&model.UserCaCert{}).Where("cert_id = ?", certId).Updates(data).Error
if err != nil {
return err

45
api/dto/UserCaCert.go Normal file
View File

@ -0,0 +1,45 @@
package dto
import (
"fmt"
"hospital-admin-api/api/model"
)
type UserCaCertDto struct {
CertId string `json:"cert_id"` // 主键id
UserId *string `json:"user_id"` // 用户id(系统证书时为null)
IsSystem int `json:"is_system"` // 是否系统证书0:否 1:是)
IsLatest int `json:"is_latest"` // 是否最新0:否 1:是)
Type int `json:"type"` // 证书类型1:线下 2:线上)
CertBase64 string `json:"cert_base64"` // 签名值证书
CertChainP7 string `json:"cert_chain_p7"` // 证书链
CertSerialNumber string `json:"cert_serial_number"` // 证书序列号
CaPin string `json:"ca_pin"` // ca认证pin值
IsSignConfig int `json:"is_sign_config"` // 是否已添加签章配置(第一次需申请)
SignConfig string `json:"sign_config"` // 签章坐标配置
CertApplicationTime model.LocalTime `json:"cert_application_time"` // 证书申请时间
CertExpireTime model.LocalTime `json:"cert_expire_time"` // 证书过期时间
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
func GetUserCaCertDto(m *model.UserCaCert) *UserCaCertDto {
userId := fmt.Sprintf("%d", &m.UserId)
return &UserCaCertDto{
CertId: fmt.Sprintf("%d", m.CertId),
UserId: &userId,
IsSystem: m.IsSystem,
IsLatest: m.IsSystem,
Type: m.IsSystem,
CertBase64: m.CertBase64,
CertChainP7: m.CertChainP7,
CertSerialNumber: m.CertSerialNumber,
CaPin: m.CaPin,
IsSignConfig: m.IsSignConfig,
SignConfig: m.SignConfig,
CertApplicationTime: m.CertApplicationTime,
CertExpireTime: m.CertExpireTime,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}

View File

@ -54,6 +54,7 @@ type UserDoctorDto struct {
DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长
DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡
InquiryType string `json:"inquiry_type"` // 服务类型
UserCaCert *UserCaCertDto `json:"user_ca_cert"` // ca监管证书
}
type UserDoctorPendingDto struct {
@ -359,6 +360,14 @@ func (r *UserDoctorDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorD
return r
}
// LoadUserCaCert 加载医生云证书详情
func (r *UserDoctorDto) LoadUserCaCert(m *model.UserCaCert) *UserDoctorDto {
if m != nil {
r.UserCaCert = GetUserCaCertDto(m)
}
return r
}
// LoadUserDoctorInfo 加载医生详情
func (r *UserDoctorPendingDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorPendingDto {
if m != nil {

View File

@ -21,7 +21,7 @@ type UserCaCertService struct {
// GetUserCloudCert 申请云证书-个人
func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -138,7 +138,7 @@ func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, e
// GetHospitalCloudCert 申请云证书-医院
func (r *UserCaCertService) GetHospitalCloudCert(tx *gorm.DB) (bool, error) {
var userId int64 = 5345345461
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -196,7 +196,7 @@ func (r *UserCaCertService) GetHospitalCloudCert(tx *gorm.DB) (bool, error) {
// EditUserCloudCert 修改云证书-个人
func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -320,7 +320,7 @@ func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool,
// RenewUserCloudCert 更新云证书-个人-续约
func (r *UserCaCertService) RenewUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -407,7 +407,7 @@ func (r *UserCaCertService) RenewUserCloudCert(tx *gorm.DB, userId int64) (bool,
func (r *UserCaCertService) RenewHospitalCloudCert(tx *gorm.DB) (bool, error) {
var userId int64 = 5345345461
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -460,7 +460,7 @@ func (r *UserCaCertService) RenewHospitalCloudCert(tx *gorm.DB) (bool, error) {
// RemoveUserCloudCert 注销云证书-个人
func (r *UserCaCertService) RemoveUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
// 检测是否存在云证书
maps := make(map[string]interface{})
@ -529,7 +529,7 @@ func (r *UserCaCertService) RemoveUserCloudCert(tx *gorm.DB, userId int64) (bool
// AddUserSignConfig 添加用户签章配置
func (r *UserCaCertService) AddUserSignConfig(tx *gorm.DB, req requests.AddUserSignConfig) (bool, error) {
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
var entityId string // 唯一标识
var cardNum string // 身份证号/信用代码

View File

@ -38,6 +38,13 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse
doctorBankCardDao := dao.DoctorBankCardDao{}
doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
// 获取医生云证书数据
userCaCertDao := dao.UserCaCertDao{}
maps := make(map[string]interface{})
maps["user_id"] = userDoctor.UserId
maps["type"] = 2
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
// 处理返回值
getUserDoctorResponse = dto.GetUserDoctorDto(userDoctor)
@ -56,6 +63,9 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse
// 加载医生详情
getUserDoctorResponse.LoadUserDoctorInfo(userDoctor.UserDoctorInfo)
// 加载医生云证书详情
getUserDoctorResponse.LoadUserCaCert(userCaCert)
return getUserDoctorResponse, nil
}
@ -91,7 +101,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
doctorBankCard, _ := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
// 获取医生云证书
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
maps := make(map[string]interface{})
maps["user_id"] = userDoctor.UserId
@ -661,7 +671,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
signImage := utils.RemoveOssDomain(req.SignImage)
if signImage != userDoctorInfo.SignImage {
// 检测是否存在云证书
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId)
if err != nil {
tx.Rollback()
@ -1439,7 +1449,7 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
userCaCertService := UserCaCertService{}
// 检测是否存在云证书
userCaCertDao := dao.UserCaCert{}
userCaCertDao := dao.UserCaCertDao{}
maps := make(map[string]interface{})
maps["user_id"] = userDoctor.UserId