34 lines
917 B
Go
34 lines
917 B
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/global"
|
|
"time"
|
|
)
|
|
|
|
// ArticleScienceSource 文章-科普-来源
|
|
type ArticleScienceSource struct {
|
|
SourceId int64 `gorm:"column:source_id;type:bigint(19);primary_key;comment:主键id" json:"source_id"`
|
|
SourceName string `gorm:"column:source_name;type:varchar(200);comment:来源名称" json:"source_name"`
|
|
SourceImage string `gorm:"column:source_image;type:varchar(200);comment:来源图片" json:"source_image"`
|
|
Model
|
|
}
|
|
|
|
func (m *ArticleScienceSource) TableName() string {
|
|
return "gdxz_article_science_source"
|
|
}
|
|
|
|
func (m *ArticleScienceSource) BeforeCreate(tx *gorm.DB) error {
|
|
if m.SourceId == 0 {
|
|
m.SourceId = 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
|
|
}
|