You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
376 B
23 lines
376 B
4 years ago
|
package db
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
uuid "github.com/satori/go.uuid"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
//Base is
|
||
|
type Base struct {
|
||
|
ID string `sql:"type:uuid;primary_key"`
|
||
|
CreatedAt time.Time
|
||
|
UpdatedAt time.Time
|
||
|
DeletedAt *time.Time `gorm:"index"`
|
||
|
}
|
||
|
|
||
|
//BeforeCreate
|
||
|
func (base *Base) BeforeCreate(tx *gorm.DB) error {
|
||
|
tx.Statement.SetColumn("ID", uuid.NewV4().String())
|
||
|
return nil
|
||
|
}
|