user

package
v0.0.0-...-f15602e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package user is a generated GoMock package.

Package user is a generated GoMock package.

Package user contains user oriented logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RoleStrings

func RoleStrings() []string

RoleStrings returns a slice of all String values of the enum

func SetUser

func SetUser(ctx context.Context, user *User) context.Context

SetUser to context.

Types

type EmailFilter

type EmailFilter struct {
	Eq  []string
	Neq []string
}

EmailFilter represents an email filter.

type Filter

type Filter struct {
	ID    IDFilter
	Email EmailFilter
}

Filter represents user filter.

type ID

type ID int64

ID represents an id for user.

func GetUserID

func GetUserID(ctx context.Context) (ID, bool)

GetUserID from context.

func (ID) ToInt64

func (id ID) ToInt64() int64

ToInt64 convert ID to int64.

type IDFilter

type IDFilter struct {
	Eq  IDs
	Neq IDs
}

IDFilter represents ID filter.

type IDs

type IDs []ID

IDs represents a slice of ID.

func (IDs) ToInt64

func (ids IDs) ToInt64() []int64

ToInt64 convert slice of IDs to slice int64.

type MockRepository

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

MockRepository is a mock of Repository interface.

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance.

func (*MockRepository) Create

func (m *MockRepository) Create(ctx context.Context, props *Props) (*User, error)

Create mocks base method.

func (*MockRepository) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRepository) Exist

func (m *MockRepository) Exist(ctx context.Context, filter *Filter) (bool, error)

Exist mocks base method.

func (*MockRepository) Get

func (m *MockRepository) Get(ctx context.Context, filter *Filter) (*User, error)

Get mocks base method.

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

func (*MockRepositoryMockRecorder) Create

func (mr *MockRepositoryMockRecorder) Create(ctx, props any) *gomock.Call

Create indicates an expected call of Create.

func (*MockRepositoryMockRecorder) Exist

func (mr *MockRepositoryMockRecorder) Exist(ctx, filter any) *gomock.Call

Exist indicates an expected call of Exist.

func (*MockRepositoryMockRecorder) Get

func (mr *MockRepositoryMockRecorder) Get(ctx, filter any) *gomock.Call

Get indicates an expected call of Get.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) Create

func (m *MockService) Create(ctx context.Context, props *Props) (*User, error)

Create mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) Get

func (m *MockService) Get(ctx context.Context, filter *Filter) (*User, error)

Get mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) Create

func (mr *MockServiceMockRecorder) Create(ctx, props any) *gomock.Call

Create indicates an expected call of Create.

func (*MockServiceMockRecorder) Get

func (mr *MockServiceMockRecorder) Get(ctx, filter any) *gomock.Call

Get indicates an expected call of Get.

type Props

type Props struct {
	Email    string
	Name     string
	Phone    string
	Password string
}

Props represents user editable fields.

type QueryCriteria

type QueryCriteria struct {
	Filter Filter
}

QueryCriteria represents a criteria for user query.

type Repository

type Repository interface {
	Get(ctx context.Context, filter *Filter) (*User, error)
	Create(ctx context.Context, props *Props) (*User, error)
	Exist(ctx context.Context, filter *Filter) (bool, error)
}

Repository represents user repository.

type Role

type Role uint8

Role represents an user`s roles.

const (
	RoleUser  Role = iota + 1 // USER
	RoleAdmin                 // ADMIN
)

func RoleString

func RoleString(s string) (Role, error)

RoleString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func RoleValues

func RoleValues() []Role

RoleValues returns all values of the enum

func (Role) IsARole

func (i Role) IsARole() bool

IsARole returns "true" if the value is listed in the enum definition. "false" otherwise

func (*Role) Scan

func (i *Role) Scan(value interface{}) error

func (Role) String

func (i Role) String() string

func (Role) Value

func (i Role) Value() (driver.Value, error)

type Roles

type Roles []Role

Roles represents a slice of Role.

type Service

type Service interface {
	Get(ctx context.Context, filter *Filter) (*User, error)
	Create(ctx context.Context, props *Props) (*User, error)
}

Service represents user use cases.

type UseCase

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

UseCase represents user service.

func NewUseCase

func NewUseCase(repository Repository) *UseCase

NewUseCase create instance of UseCase.

func (UseCase) Create

func (uc UseCase) Create(ctx context.Context, props *Props) (*User, error)

Create user.

func (UseCase) Get

func (uc UseCase) Get(ctx context.Context, filter *Filter) (*User, error)

Get user.

type User

type User struct {
	ID        ID
	Role      Role
	CreatedAt time.Time
	UpdatedAt time.Time
	Props     *Props
}

User represents the user.

func GetUser

func GetUser(ctx context.Context) (*User, bool)

GetUser from context.

Directories

Path Synopsis
Package pg contains implementations for user repositories.
Package pg contains implementations for user repositories.

Jump to

Keyboard shortcuts

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