init push
This commit is contained in:
32
internal/domain/auth/permission.go
Normal file
32
internal/domain/auth/permission.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
type Permission struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
Name string `gorm:"type:varchar(64);uniqueIndex;not null;column:name"`
|
||||
Key string `gorm:"type:varchar(64);uniqueIndex;not null;column:key"`
|
||||
Description string `gorm:"type:varchar(255);column:description"`
|
||||
Module string `gorm:"type:varchar(64);index;column:module"`
|
||||
RequiresPIN bool `gorm:"not null;default:false;column:requires_pin"`
|
||||
|
||||
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 (Permission) TableName() string { return "permissions" }
|
||||
|
||||
func (p *Permission) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(p.ID) == 0 {
|
||||
p.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user