30 lines
730 B
Go
30 lines
730 B
Go
package auth
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"wucher/internal/shared/pkg/uuidv7"
|
|
)
|
|
|
|
type Role struct {
|
|
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
|
Code string `gorm:"type:varchar(64);uniqueIndex;column:code"`
|
|
Name string `gorm:"type:varchar(64);uniqueIndex;not null;column:name"`
|
|
Description string `gorm:"type:varchar(255);column:description"`
|
|
CreatedAt time.Time
|
|
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
|
|
UpdatedAt time.Time
|
|
UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"`
|
|
}
|
|
|
|
func (Role) TableName() string { return "roles" }
|
|
|
|
func (r *Role) BeforeCreate(tx *gorm.DB) error {
|
|
if len(r.ID) == 0 {
|
|
r.ID = uuidv7.MustBytes()
|
|
}
|
|
return nil
|
|
}
|