init push
This commit is contained in:
29
internal/domain/auth/role.go
Normal file
29
internal/domain/auth/role.go
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user