wireguard-dashboard/model/entity/base.go
coward 1a73a67a4c 🚧
2024-03-05 17:28:18 +08:00

22 lines
365 B
Go

package entity
import (
"github.com/google/uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
type Base struct {
Id string `json:"id" gorm:"primaryKey;type:varchar(36);not null;comment:'主键'"`
CreatedAt datatypes.Time
UpdatedAt datatypes.Time
}
func (b *Base) BeforeCreate(*gorm.DB) (err error) {
if b.Id == "" {
b.Id = uuid.NewString()
}
return
}