usermysql

package
v0.0.0-...-a6f937e Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(db *gorm.DB) domain.UserRepository

Types

type Permission

type Permission struct {
	ID   int64  `gorm:"column:id;primaryKey"`
	Name string `gorm:"column:name;unique"`
}

func (Permission) TableName

func (Permission) TableName() string

type Role

type Role struct {
	ID          int64        `gorm:"column:id;primaryKey"`
	Name        string       `gorm:"column:name;unique"`
	Permissions []Permission `gorm:"many2many:role_permissions"`
}

func (*Role) PermissionNames

func (i *Role) PermissionNames() (res []string)

func (Role) TableName

func (Role) TableName() string

type RolePermission

type RolePermission struct {
	RoleID       int64 `gorm:"column:role_id;uniqueIndex:idx_id"`
	PermissionID int64 `gorm:"column:permission_id;uniqueIndex:idx_id"`
}

func (RolePermission) TableName

func (RolePermission) TableName() string

type User

type User struct {
	ID       int64  `gorm:"column:id;primaryKey"`
	Name     string `gorm:"column:name"`
	Email    string `gorm:"column:email;unique"`
	Password string `gorm:"column:password"`
	Roles    []Role `gorm:"many2many:user_roles"`
}

func MakeUser

func MakeUser(i *domain.User) *User

func (*User) RoleNames

func (i *User) RoleNames() (res []string)

func (User) TableName

func (User) TableName() string

func (*User) ToEntity

func (i *User) ToEntity() *domain.User

type UserRole

type UserRole struct {
	UserID int64 `gorm:"column:user_id;uniqueIndex:idx_id"`
	RoleID int64 `gorm:"column:role_id;uniqueIndex:idx_id"`
}

func (UserRole) TableName

func (UserRole) TableName() string

Jump to

Keyboard shortcuts

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