新增科普分类管理
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// BasicArticleClass 基础数据-科普-分类
|
||||
type BasicArticleClass struct {
|
||||
BasicClassId int64 `gorm:"column:basic_class_id;type:bigint(19);primary_key;comment:主键id" json:"basic_class_id"`
|
||||
BasicClassName string `gorm:"column:basic_class_name;type:varchar(255);comment:分类名称" json:"basic_class_name"`
|
||||
BasicClassSort uint `gorm:"column:basic_class_sort;type:int(5);default:1;comment:排序(越大排序越靠前)" json:"basic_class_sort"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *BasicArticleClass) TableName() string {
|
||||
return "gdxz_basic_article_class"
|
||||
}
|
||||
|
||||
func (m *BasicArticleClass) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.BasicClassId == 0 {
|
||||
m.BasicClassId = 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