people

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Permission

type Permission struct {
	ID          int          `db:"permission_id" json:"id"`
	Name        string       `db:"name" json:"name"`
	Description *null.String `db:"description" json:"description,omitempty"`
}

Permission represents an individual permission. Attempting to implement some RBAC here.

type PermissionRepo

type PermissionRepo interface {
}

PermissionRepo defines all permission interactions

type Role

type Role struct {
	ID          int          `db:"role_id" json:"id"`
	Name        string       `db:"name" json:"name"`
	Description null.String  `db:"description" json:"description"`
	Permissions []Permission `json:"permissions"`
}

Role represents a "group" of permissions where multiple users can have this role and they will inherit these permissions.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store contains our dependency

func NewStore

func NewStore(db *sqlx.DB) *Store

NewStore creates a new store

func (*Store) Get

func (m *Store) Get(ctx context.Context, userID int) (*User, error)

Get returns basic user information to be used for other services.

func (*Store) GetFull

func (m *Store) GetFull(ctx context.Context, userID int) (*UserFull, error)

GetFull will return all user information to be used for profile and management.

func (*Store) ListAll added in v0.7.0

func (m *Store) ListAll(ctx context.Context) (*[]User, error)

ListAll returns all users It doesn't return the full User object Returns user_id, avatar, nickname, first_name, last_name

There will likely be modifications to include the other fields but will need to add a filter at the web handler first or offer a different function.

func (*Store) ListRole added in v0.7.0

func (m *Store) ListRole(ctx context.Context, roleID int) (*[]User, error)

ListRole returns all users who have a certain role It doesn't return the full User object Returns user_id, avatar, nickname, first_name, last_name

There will likely be modifications to include the other fields but will need to add a filter at the web handler first or offer a different function.

type User

type User struct {
	ID          int          `db:"user_id" json:"id"`
	Username    string       `db:"username" json:"username,omitempty"`
	Email       string       `db:"email" json:"email,omitempty"`
	Nickname    string       `db:"nickname" json:"nickname"`
	Avatar      null.String  `db:"avatar" json:"avatar"`
	FirstName   string       `db:"first_name" json:"firstName"`
	LastName    string       `db:"last_name" json:"lastName"`
	Permissions []Permission `json:"permissions,omitempty"`
}

User represents a user object to be used when not all data is required

type UserFull

type UserFull struct {
	User
	LastLogin *time.Time `db:"last_login" json:"lastLogin,omitempty"`
	CreatedAt *time.Time `db:"created_at" json:"createdAt,omitempty"`
	CreatedBy int        `db:"created_by" json:"createdBy,omitempty"`
	UpdatedAt *null.Time `db:"updated_at" json:"updatedAt,omitempty"`
	UpdatedBy *null.Int  `db:"updated_by" json:"updatedBy,omitempty"`
	DeletedAt *null.Time `db:"deleted_at" json:"deletedAt,omitempty"`
	DeletedBy *null.Int  `db:"deleted_by" json:"deletedBy,omitempty"`
	Roles     []Role     `json:"roles,omitempty"`
}

UserFull represents a user and all columns

type UserRepo

type UserRepo interface {
	Get(ctx context.Context, userID int) (*User, error)
	GetFull(ctx context.Context, userID int) (*UserFull, error)
	ListAll(ctx context.Context) (*[]User, error)
	ListRole(ctx context.Context, roleID int) (*[]User, error)
}

UserRepo defines all user interactions

Jump to

Keyboard shortcuts

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