36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package model
|
||
|
||
import (
|
||
"case-api/global"
|
||
"gorm.io/gorm"
|
||
"time"
|
||
)
|
||
|
||
// ProjectPlatformHospital 关联平台-白名单-医院
|
||
type ProjectPlatformHospital struct {
|
||
WhiteHospitalId int64 `gorm:"column:white_hospital_id;type:bigint(19);primary_key;comment:主键id" json:"white_hospital_id"`
|
||
ProjectPlatformId int64 `gorm:"column:project_platform_id;type:bigint(19);comment:关联id;NOT NULL" json:"project_platform_id"`
|
||
HospitalId int64 `gorm:"column:hospital_id;type:bigint(19);comment:医院id;NOT NULL" json:"hospital_id"`
|
||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:禁用)" json:"status"`
|
||
Model
|
||
BasicHospital []*BasicHospital `gorm:"foreignKey:HospitalId;references:hospital_id" json:"basic_hospital"`
|
||
}
|
||
|
||
func (m *ProjectPlatformHospital) TableName() string {
|
||
return "project_platform_hospital"
|
||
}
|
||
|
||
func (m *ProjectPlatformHospital) BeforeCreate(tx *gorm.DB) error {
|
||
if m.WhiteHospitalId == 0 {
|
||
m.WhiteHospitalId = 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
|
||
}
|