41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// UserCaCert 医师/药师ca监管证书表
|
||
type UserCaCert struct {
|
||
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"`
|
||
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"`
|
||
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
||
CertChainP7 string `gorm:"column:cert_chain_p7;type:text;comment:证书链" json:"cert_chain_p7"`
|
||
CertSerialNumber string `gorm:"column:cert_serial_number;type:varchar(100);comment:证书序列号" json:"cert_serial_number"`
|
||
CaPin string `gorm:"column:ca_pin;type:varchar(100);comment:ca认证pin值" json:"ca_pin"`
|
||
IsSignConfig int `gorm:"column:is_sign_config;type:tinyint(1);default:0;comment:是否已添加签章配置(第一次需申请)" json:"is_sign_config"`
|
||
SignConfig string `gorm:"column:sign_config;type:text;comment:签章坐标配置" json:"sign_config"`
|
||
Model
|
||
}
|
||
|
||
func (m *UserCaCert) TableName() string {
|
||
return "gdxz_user_ca_cert"
|
||
}
|
||
|
||
func (m *UserCaCert) BeforeCreate(tx *gorm.DB) error {
|
||
if m.CertId == 0 {
|
||
m.CertId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|