add role based permissions
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Module struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Code string `gorm:"uniqueIndex;not null" json:"code"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
Permissions []Permission `gorm:"foreignKey:ModuleID" json:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
func (Module) TableName() string { return "modules" }
|
||||
@@ -18,11 +18,14 @@ type Role struct {
|
||||
func (Role) TableName() string { return "roles" }
|
||||
|
||||
type Permission struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
Code string `gorm:"uniqueIndex;not null" json:"code"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
ModuleID *uuid.UUID `gorm:"type:uuid" json:"module_id"`
|
||||
Module *Module `gorm:"foreignKey:ModuleID" json:"module,omitempty"`
|
||||
Action string `json:"action"`
|
||||
Code string `gorm:"uniqueIndex;not null" json:"code"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Permission) TableName() string { return "permissions" }
|
||||
|
||||
Reference in New Issue
Block a user