domain

package
v0.0.0-...-193f563 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Model
	Name        string       `yaml:"name" json:"name"`
	Description string       `yaml:"description" json:"description"`
	Role        string       `yaml:"role" json:"role"`
	Users       []User       `gorm:"many2many:user_groups;" yaml:"-" json:"-"`
	Permissions []Permission `yaml:"-" json:"-"`
}

Group .

type Model

type Model struct {
	ID        UUID       `sql:",type:uuid" json:"id"`
	CreatedAt time.Time  `sql:"default:now()" json:"created_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

Model .

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(scope *gorm.Scope) error

BeforeCreate prepare data before create data

type Permission

type Permission struct {
	Model
	DatabaseName string `yaml:"database" json:"database"`
	TableName    string `yaml:"table" json:"table"`
	Select       bool   `yaml:"select" json:"select"`
	Insert       bool   `yaml:"insert" json:"insert"`
	Update       bool   `yaml:"update" json:"update"`
	Delete       bool   `yaml:"delete" json:"delete"`
	UserID       UUID   `yaml:"user_id" json:"user_id"`
	GroupID      UUID   `yaml:"group_id" json:"group_id"`
}

Permission .

func (Permission) AND

func (p Permission) AND(q Permission) Permission

AND .

type UUID

type UUID [16]byte

UUID implement for go-pg convert uuid

func MustGetUUIDFromString

func MustGetUUIDFromString(s string) UUID

MustGetUUIDFromString get uuid from string if failed throw panic, CAUTION: IT ONLY USE FOR TESTING

func NewUUID

func NewUUID() UUID

NewUUID create new UUID with V4

func UUIDFromString

func UUIDFromString(s string) (UUID, error)

UUIDFromString convert string to UUID

func (*UUID) IsZero

func (u *UUID) IsZero() bool

IsZero check uuid is zero

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON implement for json encoding

func (*UUID) Scan

func (u *UUID) Scan(b interface{}) error

Scan .

func (UUID) String

func (u UUID) String() string

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

UnmarshalJSON implement for json decoding

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value .

type User

type User struct {
	Model
	Username       string       `yaml:"username" json:"username"`
	Password       string       `yaml:"-" json:"-"`
	PasswordDigest string       `yaml:"password_digest" json:"password_digest"`
	Role           string       `yaml:"role" json:"role"`
	Email          string       `yaml:"email" json:"email"`
	ConfirmCode    string       `yaml:"confirm_code" json:"confirm_code"`
	Groups         []Group      `gorm:"many2many:user_groups;" yaml:"-" json:"-"`
	Permissions    []Permission `yaml:"-" json:"-"`
}

User .

func (*User) BeforeSave

func (u *User) BeforeSave(scope *gorm.Scope) error

BeforeSave prepare data before create data

type UserGroup

type UserGroup struct {
	GroupID string `yaml:"group_id" json:"group_id"`
	UserID  string `yaml:"user_id" json:"user_id"`
}

UserGroup .

Jump to

Keyboard shortcuts

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