services

package
v0.0.0-...-4b14bc7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UsersService

type UsersService struct {
	Repository dataccess.IUserRepository
}

func NewUsersService

func NewUsersService(repository dataccess.IUserRepository) *UsersService

NewUsersService return a instance of UsersService it needs de repository to use

func (*UsersService) CreateUser

func (us *UsersService) CreateUser(newUser *models.User) (models.User, error)

CreateUser create the newUser validating the information of the structure if it is validate, create the users on the repository return error if is any error in the process

func (*UsersService) DeleteUserById

func (us *UsersService) DeleteUserById(id string) (*models.User, error)

DeleteUserById update de statate of the user isAvtive to false it woul return the user info and if its any error it will be returned

func (*UsersService) GetAllUsers

func (us *UsersService) GetAllUsers(page int, maxUsers int) ([]models.User, error)

GetAllUsers obtains as maxUsers active users of the database and a part of the segmen users. iF its any error it will be returned

func (*UsersService) GetTotalUsers

func (us *UsersService) GetTotalUsers() (int, error)

GetTotalUsers obtains the total of active user in the respository just return a number, and if its any error it also return it

func (*UsersService) GetUserByID

func (us *UsersService) GetUserByID(id string) (models.User, error)

GetUserByID obtains a users searching by ID if it doesnt exist return an error, but if it exist return de struct of the user

func (*UsersService) LogInUser

func (us *UsersService) LogInUser(email string, password string) (string, error)

LoginUser verify if the email and password match, if it doesnt, it return an error but if its correct, it return a Json Web Token with name and email information

func (*UsersService) ReplaceUser

func (us *UsersService) ReplaceUser(newUser *models.User, id string) (models.User, error)

ReplaceUser update the user with the id, and return the old user if is any problem it return it.

func (*UsersService) UpdateUserById

func (us *UsersService) UpdateUserById(newUser *models.User, id string) (*models.User, error)

UpdateUserById update some values fo the info of some user it also verify the information and if its correct, it will updated reeturn the old user, if its any error it will be returned

Jump to

Keyboard shortcuts

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