case-api/api/model/ProjectPlatformHospital.go
2025-03-07 16:57:28 +08:00

36 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}