user

package
v0.0.0-...-187a358 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmailAlreadyExists = errors.New("user with such email already exists")
View Source
var ErrNotFound = errors.New("can not find user in store")

Functions

This section is empty.

Types

type MockRepository

type MockRepository struct {
	mock.Mock
}

mockery --name=Repository --filename=repository_mock.go --output=./ --structname=MockRepository --inpackage MockRepository is an autogenerated mock type for the Repository type

func NewMockRepository

func NewMockRepository(t mockConstructorTestingTNewMockRepository) *MockRepository

NewMockRepository creates a new instance of MockRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockRepository) Create

func (_m *MockRepository) Create(user *User) error

Create provides a mock function with given fields: user

func (*MockRepository) Delete

func (_m *MockRepository) Delete(id string) (int, error)

Delete provides a mock function with given fields: id

func (*MockRepository) Get

func (_m *MockRepository) Get(id string) (*User, error)

Get provides a mock function with given fields: id

func (*MockRepository) GetByEmail

func (_m *MockRepository) GetByEmail(email string) (*User, error)

GetByEmail provides a mock function with given fields: email

func (*MockRepository) Update

func (_m *MockRepository) Update(usr *User) error

Update provides a mock function with given fields: usr

type Repository

type Repository interface {
	Create(user *User) error                // Create saves new user to DB, return ErrEmailAlreadyExists when user with email already exists
	GetByEmail(email string) (*User, error) // GetByEmail gets user by email, return ErrNotFound if user not exists
	Get(id string) (*User, error)           // Get gets user by id, return ErrNotFound if user not exists
	Update(usr *User) error                 // Update saves the updated usr entity to store, return ErrEmailAlreadyExists when user with email already exists
	Delete(id string) (int, error)          // Delete removes user from DB
}

Repository User domain repo

type Role

type Role int
const (
	Admin  Role = 1
	Author Role = 2
)

type User

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

func NewUser

func NewUser(name, email, password string, role Role) (*User, error)

func UnmarshalFromDB

func UnmarshalFromDB(
	id string,
	name string,
	email string,
	password string,
	role int,
	defaultLangID string,
) *User

func (*User) ApplyChanges

func (u *User) ApplyChanges(name, email, passwd string, role Role, defaultLangID string) error

func (*User) DefaultLangID

func (u *User) DefaultLangID() string

func (*User) Email

func (u *User) Email() string

func (*User) ID

func (u *User) ID() string

func (*User) Password

func (u *User) Password() string

func (*User) Role

func (u *User) Role() Role

func (*User) ToMap

func (u *User) ToMap() map[string]interface{}

Jump to

Keyboard shortcuts

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