account

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package account present full API functionality of the specific object

Index

Constants

View Source
const RoleAdmin = `admin`

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	ID     []uint64
	UserID []uint64
	Title  []string
	Status []model.ApproveStatus
}

Filter of the objects list

func (*Filter) PrepareQuery

func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB

type ListOrder

type ListOrder struct {
	ID        model.Order
	Title     model.Order
	Status    model.Order
	CreatedAt model.Order
	UpdatedAt model.Order
}

ListOrder of the objects list

func (*ListOrder) PrepareQuery

func (ord *ListOrder) PrepareQuery(query *gorm.DB) *gorm.DB

type MemberFilter

type MemberFilter struct {
	ID        []uint64
	AccountID []uint64
	UserID    []uint64
	NotUserID []uint64
	Status    []model.ApproveStatus
	IsAdmin   null.Bool
}

MemberFilter of the objects list

func (*MemberFilter) PrepareQuery

func (fl *MemberFilter) PrepareQuery(query *gorm.DB) *gorm.DB

type MemberListOrder

type MemberListOrder struct {
	ID        model.Order
	AccountID model.Order
	UserID    model.Order
	Status    model.Order
	IsAdmin   model.Order
	CreatedAt model.Order
	UpdatedAt model.Order
}

MemberListOrder of the objects list

func (*MemberListOrder) PrepareQuery

func (ord *MemberListOrder) PrepareQuery(query *gorm.DB) *gorm.DB

type Repository

type Repository interface {
	Get(ctx context.Context, id uint64) (*model.Account, error)
	GetByTitle(ctx context.Context, title string) (*model.Account, error)
	FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Account, error)
	Count(ctx context.Context, filter *Filter) (int64, error)
	Create(ctx context.Context, account *model.Account) (uint64, error)
	Update(ctx context.Context, id uint64, account *model.Account) error
	Delete(ctx context.Context, id uint64) error

	IsAdmin(ctx context.Context, userID, accountID uint64) bool
	IsMember(ctx context.Context, userID, accountID uint64) bool

	FetchListMembers(ctx context.Context, filter *MemberFilter, order *MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error)
	CountMembers(ctx context.Context, filter *MemberFilter) (int64, error)
	Member(ctx context.Context, userID, accountID uint64) (*model.AccountMember, error)
	MemberByID(ctx context.Context, id uint64) (*model.AccountMember, error)
	LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error
	UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error
	SetMemberRoles(ctx context.Context, account *model.Account, member *model.User, roles ...string) error

	LoadPermissions(ctx context.Context, account *model.Account, user *model.User) error
}

Repository of access to the account

type Usecase

type Usecase interface {
	Get(ctx context.Context, id uint64) (*model.Account, error)
	GetByTitle(ctx context.Context, title string) (*model.Account, error)
	FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Account, error)
	Count(ctx context.Context, filter *Filter) (int64, error)
	Store(ctx context.Context, account *model.Account) (uint64, error)
	Register(ctx context.Context, ownerObj *model.User, accountObj *model.Account, password string) (uint64, error)
	Delete(ctx context.Context, id uint64) error

	FetchListMembers(ctx context.Context, filter *MemberFilter, order *MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error)
	CountMembers(ctx context.Context, filter *MemberFilter) (int64, error)
	LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error
	UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error
	UnlinkAccountMember(ctx context.Context, memberID uint64) error
	InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*model.AccountMember, error)
	SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*model.AccountMember, error)
	SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*model.AccountMember, error)
}

Usecase of the account

Directories

Path Synopsis
delivery
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
Package usecase account implementation
Package usecase account implementation

Jump to

Keyboard shortcuts

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