people

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: GPL-3.0 Imports: 4 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 {
	PermissionID int    `db:"permission_id" json:"id"`
	Name         string `db:"name" json:"name"`
	Description  string `db:"description" json:"description,omitempty"`
}

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

type PermissionRepo

type PermissionRepo interface {
	ListAllPermissions(ctx context.Context) ([]Permission, error)
	ListPermissionMembersByID(ctx context.Context, permissionID int) ([]User, error)
}

PermissionRepo defines all permission interactions

type Role

type Role struct {
	RoleID      int          `db:"role_id" json:"id"`
	Name        string       `db:"name" json:"name"`
	Description 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 RoleRepo added in v0.8.0

type RoleRepo interface {
	ListAllRoles(ctx context.Context) ([]Role, error)
	ListRoleMembersByID(ctx context.Context, roleID int) ([]User, error)
	ListRolePermissionsByID(ctx context.Context, roleID int) ([]Permission, error)
}

RoleRepo defines all role interaction

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) GetUser added in v0.8.0

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

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

func (*Store) GetUserFull added in v0.8.0

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

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

func (*Store) ListAllPermissions added in v0.8.0

func (m *Store) ListAllPermissions(ctx context.Context) ([]Permission, error)

func (*Store) ListAllRoles added in v0.8.0

func (s *Store) ListAllRoles(ctx context.Context) ([]Role, error)

func (*Store) ListAllUsers added in v0.8.0

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

ListAllUsers 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) ListPermissionMembersByID added in v0.8.0

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

func (*Store) ListRoleMembersByID added in v0.8.0

func (m *Store) ListRoleMembersByID(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.

func (*Store) ListRolePermissionsByID added in v0.8.0

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

type User

type User struct {
	UserID      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      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 *time.Time `db:"updated_at" json:"updatedAt,omitempty"`
	UpdatedBy *int       `db:"updated_by" json:"updatedBy,omitempty"`
	DeletedAt *time.Time `db:"deleted_at" json:"deletedAt,omitempty"`
	DeletedBy *int       `db:"deleted_by" json:"deletedBy,omitempty"`
	Roles     []Role     `json:"roles,omitempty"`
}

UserFull represents a user and all columns

type UserRepo

type UserRepo interface {
	GetUser(ctx context.Context, userID int) (User, error)
	GetUserFull(ctx context.Context, userID int) (UserFull, error)
	ListAllUsers(ctx context.Context) ([]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