Back to godoc.org

Package logic

v0.0.0-...-181be6d
Latest Go to latest

The latest major version is .

Published: May 15, 2020 | License: OSL-3.0 | Module: git.dragon-labs.de/base/usermodule

Index

Variables

var (
	ErrEmailAlreadyExists    = errors.New("email already exists")
	ErrUsernameAlreadyExists = errors.New("username already exists")
	ErrUserNotFound          = errors.New("user not found")
)

type UserRepository

type UserRepository interface {
	UserService
	InitRepository() error
}

type UserSerializer

type UserSerializer interface {
	EncodeUser(user *models.User) ([]byte, error)
	DecodeUser(data []byte) (*models.User, error)
	EncodeUsers(user []*models.User) ([]byte, error)
	DecodeUsers(data []byte) ([]*models.User, error)
	EncodeAuthentication(authData *models.Authentication) ([]byte, error)
	EncodeGroups([]*models.Group) ([]byte, error)
	EncodeGroup(*models.Group) ([]byte, error)
	DecodeGroup(data []byte) (*models.Group, error)
	Encode(obj interface{}) ([]byte, error)
	Decode(data []byte) (map[string]interface{}, error)
}

UserSerializer is the base interface for encode and decode the user struct into and from a specific type

type UserService

type UserService interface {
	RegisterUser(*models.User) (*models.User, error)
	LoginUser(*models.User) (*models.Authentication, error)
	ExistEmail(email string) (bool, error)
	ExistUsername(username string) (bool, error)
	GetUserByID(id uint) (*models.User, error)
	GetUserByUsername(username string) (*models.User, error)
	GetUserByEmail(email string) (*models.User, error)
	ListAllUsers() ([]*models.User, error)
	ActivateUser(*models.User) (bool, error)
	DeleteUser(*models.User) error
	UpdateUser(*models.User) (*models.User, error)

	GetGroupByID(id int) (*models.Group, error)

	ListGroups() ([]*models.Group, error)
	ListDefaultGroups() ([]*models.Group, error)
	CreateGroup(*models.Group) (*models.Group, error)
	UpdateGroup(*models.Group) (*models.Group, error)
	DeleteGroup(*models.Group) error

	AddGroupToUser(user *models.User, group *models.Group) (bool, error)
	RemGroupFromUser(user *models.User, group *models.Group) (bool, error)
}

UserService is an interface with all functions to manage the user

func NewUserService

func NewUserService(userRepo UserRepository, jwtConfig *config.JWTConfig) UserService

NewUserService creates a new service object with an given repository for actions

Package Files

  • logic.go
  • repository.go
  • serializer.go
  • service.go
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier