Documentation ¶
Index ¶
- type UsersService
- func (us *UsersService) CreateUser(newUser *models.User) (models.User, error)
- func (us *UsersService) DeleteUserById(id string) (*models.User, error)
- func (us *UsersService) GetAllUsers(page int, maxUsers int) ([]models.User, error)
- func (us *UsersService) GetTotalUsers() (int, error)
- func (us *UsersService) GetUserByID(id string) (models.User, error)
- func (us *UsersService) LogInUser(email string, password string) (string, error)
- func (us *UsersService) ReplaceUser(newUser *models.User, id string) (models.User, error)
- func (us *UsersService) UpdateUserById(newUser *models.User, id string) (*models.User, error)
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 ¶
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 ¶
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 ¶
ReplaceUser update the user with the id, and return the old user if is any problem it return it.
func (*UsersService) UpdateUserById ¶
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