models

package
v0.0.0-...-e029def Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormalUser uint64 = 0 // Suggest books, suggest authors
	AdminUser  uint64 = 1 // Admin
)
View Source
const (
	ValidateBooks        uint64 = 0
	ValidateAuthors      uint64 = 1
	ElevateUsers         uint64 = 2
	DemoteUsers          uint64 = 3
	ValidateSingleAuthor uint64 = 4
	ValidateSingleBook   uint64 = 5
)

Variables

View Source
var (
	InvalidUserGroup = errors.New("user group was invalid")
)

Functions

func GetUserGroup

func GetUserGroup(value uint64) string

func IsTargeted

func IsTargeted(permissionType uint64) bool

func IsValidPermissionType

func IsValidPermissionType(value uint64) bool

func IsValidUserGroup

func IsValidUserGroup(value uint64) bool

func PermissionContains

func PermissionContains(l, r Permission) bool

Types

type Author

type Author struct {
	Id          uint64
	SuggestedBy *uint64
	SuggestedAt time.Time
	ValidatedBy sql.NullInt64
	ValidatedAt *time.Time
	FirstName   string
	LastName    string
	ImageId     sql.NullInt64
}

type Book

type Book struct {
	Id          uint64
	SuggestedBy *uint64
	SuggestedAt time.Time
	ValidatedBy sql.NullInt64
	ValidatedAt *time.Time
	Title       string
	Description string
	ImageId     sql.NullInt64
}

type Permission

type Permission struct {
	Type uint64
	Ref  uint64
}

func BroadPermission

func BroadPermission(permissionType uint64) *Permission

func BuildPermission

func BuildPermission(permissionType string, reference uint64) (*Permission, error)

func TargetedPermission

func TargetedPermission(permissionType uint64, id uint64) *Permission

func (*Permission) IsTargeted

func (perm *Permission) IsTargeted() bool

type User

type User struct {
	Id        uint64
	CreatedAt time.Time
	Username  string
	Email     string
	UserGroup uint64
}

func (*User) NilId

func (user *User) NilId() *uint64

type WrittenBy

type WrittenBy struct {
	AuthorId uint64
	BookId   uint64
}

Jump to

Keyboard shortcuts

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