新增科普分类管理
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ArticleScienceClass 文章-科普-分类
|
||||
type ArticleScienceClass struct {
|
||||
ClassId int64 `gorm:"column:class_id;type:bigint(19);primary_key;comment:主键id" json:"class_id"`
|
||||
ArticleId int64 `gorm:"column:article_id;type:bigint(19);comment:文章-科普id;NOT NULL" json:"article_id"`
|
||||
BasicClassId int64 `gorm:"column:basic_class_id;type:bigint(19);comment:基础数据-科普-分类id;NOT NULL" json:"basic_class_id"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *ArticleScienceClass) TableName() string {
|
||||
return "gdxz_article_science_class"
|
||||
}
|
||||
|
||||
func (m *ArticleScienceClass) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ClassId == 0 {
|
||||
m.ClassId = 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
|
||||
}
|
||||
Reference in New Issue
Block a user