33 lines
728 B
Go
33 lines
728 B
Go
package model
|
|
|
|
import (
|
|
"case-api/global"
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
// BasicSensitiveWord 基础数据-敏感词
|
|
type BasicSensitiveWord struct {
|
|
Id int64 `gorm:"column:id;type:bigint(19);primary_key;comment:主键id" json:"id"`
|
|
Word string `gorm:"column:word;type:varchar(50);comment:敏感词" json:"word"`
|
|
Model
|
|
}
|
|
|
|
func (m *BasicSensitiveWord) TableName() string {
|
|
return "basic_sensitive_word"
|
|
}
|
|
|
|
func (m *BasicSensitiveWord) BeforeCreate(tx *gorm.DB) error {
|
|
if m.Id == 0 {
|
|
m.Id = 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
|
|
}
|