add membership

This commit is contained in:
Fran Jurmanović
2025-06-26 00:51:54 +02:00
parent 69733e4940
commit 74df36cd0d
24 changed files with 863 additions and 83 deletions

20
local/model/role.go Normal file
View File

@@ -0,0 +1,20 @@
package model
import (
"github.com/google/uuid"
"gorm.io/gorm"
)
// Role represents a user role in the system.
type Role struct {
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;"`
Name string `json:"name" gorm:"unique_index;not null"`
Permissions []Permission `json:"permissions" gorm:"many2many:role_permissions;"`
}
// BeforeCreate is a GORM hook that runs before creating new credentials
func (s *Role) BeforeCreate(tx *gorm.DB) error {
s.ID = uuid.New()
return nil
}