entity

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrationBack

func MigrationBack(db *gorm.DB) error

func Migrations

func Migrations(db *gorm.DB) error

Types

type Model

type Model struct {
	ID        string `gorm:"type:varchar(256);primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*Model) Generate

func (m *Model) Generate()

type Organization

type Organization struct {
	Model
	Name        string     `gorm:"type:varchar(256);UNIQUE"`
	Description string     `gorm:"type:varchar(256)"`
	Users       []User     `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	UserRoles   []UserRole `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func (Organization) ConvertModel

func (org Organization) ConvertModel() (*model.Organization, error)

type Permission

type Permission struct {
	Model
	Name        string `gorm:"type:varchar(256);UNIQUE"`
	Description string `gorm:"type:varchar(256)"`
}

func (Permission) ConvertModel

func (p Permission) ConvertModel() (*model.Permission, error)

type Resource

type Resource struct {
	Method       string      `gorm:"type:varchar(256);primaryKey"`
	URI          string      `gorm:"type:varchar(256);primaryKey"`
	PermissionID string      `gorm:"type:varchar(256);primaryKey"`
	Permission   *Permission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type Role

type Role struct {
	Model
	Name            string           `gorm:"type:varchar(256);UNIQUE"`
	Description     string           `gorm:"type:varchar(256)"`
	RolePermissions []RolePermission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	UserRoles       []UserRole       `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Role) ConvertModel

func (r Role) ConvertModel() (*model.Role, error)

type RolePermission

type RolePermission struct {
	RoleID       string      `gorm:"type:varchar(256);primaryKey"`
	PermissionID string      `gorm:"type:varchar(256);primaryKey"`
	Permission   *Permission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type User

type User struct {
	Key            string       `gorm:"type:varchar(256);primaryKey"`
	OrganizationID string       `gorm:"type:varchar(256);primaryKey"`
	Organization   Organization `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	UserRoles      []UserRole   `gorm:"foreignKey:UserKey,OrganizationID;references:Key,OrganizationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func (User) ConvertModel

func (u User) ConvertModel() (*model.User, error)

type UserRole

type UserRole struct {
	UserKey        string `gorm:"type:varchar(256);primaryKey"`
	OrganizationID string `gorm:"type:varchar(256);primaryKey"`
	RoleID         string `gorm:"type:varchar(256);primaryKey"`
	Organization   Organization
	Role           Role
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL