user

package
v0.0.0-...-861471e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotImplementedErr = fmt.Errorf("this method is not implemented")

Functions

func NewService

func NewService(r *Resources) (*service, error)

Types

type BaseRepository

type BaseRepository struct{}

func (*BaseRepository) DeleteUser

func (repo *BaseRepository) DeleteUser(string) error

func (*BaseRepository) GetAllUsers

func (repo *BaseRepository) GetAllUsers() (users []*User, err error)

func (*BaseRepository) GetUser

func (repo *BaseRepository) GetUser(string) (*User, error)

func (*BaseRepository) GetUserByEmail

func (repo *BaseRepository) GetUserByEmail(string) (*User, error)

func (*BaseRepository) GetUsersByCountry

func (repo *BaseRepository) GetUsersByCountry(cc string) (users []*User, err error)

func (*BaseRepository) PutUser

func (repo *BaseRepository) PutUser(*User) error

type Claims

type Claims struct {
	IsAdmin bool `json:"isAdmin"`
	jwt.RegisteredClaims
}

type MockRepository

type MockRepository struct {
	mock.Mock

	BaseRepository
}

func (*MockRepository) DeleteUser

func (repo *MockRepository) DeleteUser(id string) error

func (*MockRepository) GetAllUsers

func (repo *MockRepository) GetAllUsers() (users []*User, err error)

func (*MockRepository) GetUser

func (repo *MockRepository) GetUser(userId string) (user *User, err error)

func (*MockRepository) GetUserByEmail

func (repo *MockRepository) GetUserByEmail(email string) (user *User, err error)

func (*MockRepository) GetUsersByCountry

func (repo *MockRepository) GetUsersByCountry(cc string) (users []*User, err error)

func (*MockRepository) PutUser

func (repo *MockRepository) PutUser(user *User) error

type MongoRepoParams

type MongoRepoParams struct {
	Host           string
	Database       string
	CollectionName string
}

type MongoRepository

type MongoRepository struct {
	BaseRepository

	Collection *mongo.Collection
}

func NewMongoRepo

func NewMongoRepo(ctx context.Context, params *MongoRepoParams) (*MongoRepository, error)

func (*MongoRepository) DeleteUser

func (repo *MongoRepository) DeleteUser(id string) error

func (*MongoRepository) GetAllUsers

func (repo *MongoRepository) GetAllUsers() ([]*User, error)

func (*MongoRepository) GetUser

func (repo *MongoRepository) GetUser(userId string) (*User, error)

func (*MongoRepository) GetUserByAttr

func (repo *MongoRepository) GetUserByAttr(attr, value string) (*User, error)

func (*MongoRepository) GetUserByEmail

func (repo *MongoRepository) GetUserByEmail(email string) (*User, error)

func (*MongoRepository) GetUsersByCountry

func (repo *MongoRepository) GetUsersByCountry(cc string) ([]*User, error)

func (*MongoRepository) PutUser

func (repo *MongoRepository) PutUser(u *User) error

type Repository

type Repository interface {
	GetUser(string) (*User, error)
	GetUserByEmail(string) (*User, error)
	GetUsersByCountry(cc string) (users []*User, err error)
	DeleteUser(string) error
	PutUser(*User) error
	GetAllUsers() (users []*User, err error)
}

type Resources

type Resources struct {
	Repo        Repository
	UserChannel chan *UserUpdate
}

type User

type User struct {
	ID          string `json:"_id" bson:"_id"`
	FirstName   string `json:"firstName" bson:"firstName"`
	LastName    string `json:"lastName" bson:"lastName"`
	Email       string `json:"email" bson:"email"`
	NickName    string `json:"nickName" bson:"nickName"`
	CountryCode string `json:"countryCode" bson:"countryCode"`
	Saved       string `json:"saved" bson:"saved"`
	Password    []byte `json:"-" bson:"password"`
	IsAdmin     bool   `json:"is_admin"  bson:"isAdmin"`
}

func (*User) Validate

func (u *User) Validate() error

type UserService

type UserService interface {
	GetUser(string) (*User, error)
	GetUserByEmail(string) (*User, error)
	PutUser(u *User) (*User, error)
	DeleteUser(string) error
	GetUsersByCountry(string) ([]*User, error)
	GetAllUsers() ([]*User, error)
}

type UserUpdate

type UserUpdate struct {
	User   *User
	Status string
}

Jump to

Keyboard shortcuts

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