35 lines
982 B
Go
35 lines
982 B
Go
package model
|
|
|
|
import (
|
|
"github.com/bwmarrin/snowflake"
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/config"
|
|
)
|
|
|
|
// 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"`
|
|
Model
|
|
}
|
|
|
|
func (m *DoctorIdenFail) TableName() string {
|
|
return "gdxz_doctor_iden_fail"
|
|
}
|
|
|
|
func (m *DoctorIdenFail) BeforeCreate(tx *gorm.DB) error {
|
|
if m.IdenFailId == 0 {
|
|
// 创建雪花算法实例
|
|
sf, err := snowflake.NewNode(config.C.Snowflake)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// 生成新的雪花算法 ID
|
|
m.IdenFailId = sf.Generate().Int64()
|
|
}
|
|
return nil
|
|
}
|