新增患者手机号

This commit is contained in:
2023-09-12 09:56:27 +08:00
parent 3fcafc909a
commit a4255c5404
5 changed files with 54 additions and 7 deletions
+1
View File
@@ -50,6 +50,7 @@ type OrderProduct struct {
ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(50);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
Model
}
+40
View File
@@ -0,0 +1,40 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// UserPatient 用户-患者表
type UserPatient struct {
PatientId int64 `gorm:"column:patient_id;type:bigint(19);primary_key;comment:主键id" json:"patient_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
UserName string `gorm:"column:user_name;type:varchar(100);comment:用户名称" json:"user_name"`
OpenId string `gorm:"column:open_id;type:varchar(100);comment:微信open_id" json:"open_id"`
UnionId string `gorm:"column:union_id;type:varchar(100);comment:微信开放平台唯一标识" json:"union_id"`
WxSessionKey string `gorm:"column:wx_session_key;type:varchar(255);comment:微信会话密钥" json:"wx_session_key"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
Model
}
func (m *UserPatient) TableName() string {
return "gdxz_user_patient"
}
func (m *UserPatient) BeforeCreate(tx *gorm.DB) error {
if m.PatientId == 0 {
m.PatientId = 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
}