Documentation
¶
Index ¶
- type LinkRepository
- func (lr *LinkRepository) Create(id, content, ownerID string) (link models.Link, err error)
- func (lr *LinkRepository) Delete(id string) error
- func (lr *LinkRepository) DeleteByUser(requesterID, id string) error
- func (lr *LinkRepository) Get(id string) (models.Link, error)
- func (lr *LinkRepository) GetByUser(requesterID, id string) (models.Link, error)
- func (lr *LinkRepository) GetContentAndIncreaseHitCount(id string) (string, error)
- func (lr *LinkRepository) IncreaseHitCount(id string) error
- func (lr *LinkRepository) List(ownerID string, limit, offset uint) ([]models.Link, error)
- func (lr *LinkRepository) ListByUser(requesterID, ownerID string, limit, offset uint) ([]models.Link, error)
- func (lr *LinkRepository) UpdateContent(id, content string) error
- func (lr *LinkRepository) UpdateContentByUser(requesterID, id, content string) error
- type SessionRepository
- func (sr *SessionRepository) Create(userID string, expireDate int64) (models.Session, error)
- func (sr *SessionRepository) Delete(id string) error
- func (sr *SessionRepository) DeleteByUser(userID, id string) error
- func (sr *SessionRepository) GenerateToken(sessionID string) (string, error)
- func (sr *SessionRepository) List(userID string, limit, offset uint) ([]models.Session, error)
- func (sr *SessionRepository) ValidateAndRenew(sessionToken string) (string, error)
- func (sr *SessionRepository) ValidateToken(sessionToken string) (string, error)
- type UserRepository
- func (ur *UserRepository) CheckLoginCredentials(name string, password []byte) (bool, error)
- func (ur *UserRepository) Create(name string, password []byte, isAdmin bool) (user models.User, err error)
- func (ur *UserRepository) CreateByUser(requesterID string, name string, password []byte, isAdmin bool) (user models.User, err error)
- func (ur *UserRepository) Delete(id string) error
- func (ur *UserRepository) DeleteByUser(requesterID, id string) (err error)
- func (ur *UserRepository) Get(id string) (models.User, error)
- func (ur *UserRepository) GetByUser(requesterID, id string) (user models.User, err error)
- func (ur *UserRepository) List(limit, offset uint) ([]models.User, error)
- func (ur *UserRepository) ListByUser(requesterID string, limit, offset uint) (users []models.User, err error)
- func (ur *UserRepository) Update(payload user_repository.UpdatePayload) (err error)
- func (ur *UserRepository) UpdateByUser(requesterID string, user user_repository.UpdatePayload) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LinkRepository ¶
LinkRepository implements ILinkRepository
func (*LinkRepository) Create ¶
func (lr *LinkRepository) Create(id, content, ownerID string) (link models.Link, err error)
Create creates a link and save it to the storage This methods will permorn validations over the provided data If the id is left blank, a random one would be assigned The data validations in this method can produce an ErrInvalidID or an ErrInvalidContent
func (*LinkRepository) Delete ¶
func (lr *LinkRepository) Delete(id string) error
Delete deletes a link from the storage If the link does not exists in the storage an NotFoundError would be returned
func (*LinkRepository) DeleteByUser ¶
func (lr *LinkRepository) DeleteByUser(requesterID, id string) error
DeleteByUser deletes a link from the storage If the link does not exists in the storage an NotFoundError would be returned The requester must own the link or be an admin to perform this action
func (*LinkRepository) Get ¶
func (lr *LinkRepository) Get(id string) (models.Link, error)
Get returns the link with specified ID from the storage If the link does not exists in the storage an NotFoundError would be returned
func (*LinkRepository) GetByUser ¶
func (lr *LinkRepository) GetByUser(requesterID, id string) (models.Link, error)
GetByUser returns the link with specified ID from the storage If the link does not exists in the storage an NotFoundError would be returned The requester must own the link or be an admin to perform this action
func (*LinkRepository) GetContentAndIncreaseHitCount ¶
func (lr *LinkRepository) GetContentAndIncreaseHitCount(id string) (string, error)
GetContentAndIncreaseHitCount return the link content and increases the hits number of a link in the storage If the link does not exists in the storage an NotFoundError would be returned
func (*LinkRepository) IncreaseHitCount ¶
func (lr *LinkRepository) IncreaseHitCount(id string) error
IncreaseHitCount increases the hits number of a link in the storage If the link does not exists in the storage an NotFoundError would be returned
func (*LinkRepository) List ¶
List lits the users If the limit is set to 0, no limit will be established, the same applies to the offset if the ownerID is not empty the search would be limited to the owned by the specified user
func (*LinkRepository) ListByUser ¶
func (lr *LinkRepository) ListByUser(requesterID, ownerID string, limit, offset uint) ([]models.Link, error)
ListByUser lits the users If the limit is set to 0, no limit will be established, the same applies to the offset if the ownerID is not empty the search would be limited to the owned owned by the specified user The requester must be the owner of the links or an admin to perform this action
func (*LinkRepository) UpdateContent ¶
func (lr *LinkRepository) UpdateContent(id, content string) error
UpdateContent replaces the content of an existing link If the link doesn't exists in the Link an error would be returned This methods will permorn validations over the provided data The data validations in this method can produce an ErrInvalidContent
func (*LinkRepository) UpdateContentByUser ¶
func (lr *LinkRepository) UpdateContentByUser(requesterID, id, content string) error
UpdateContentByUser replaces the content of an existing link If the link doesn't exists in the Link an error would be returned This methods will permorn validations over the provided data The data validations in this method can produce an ErrInvalidContent The requester must own the link or be an admin to perform this action
type SessionRepository ¶
func (*SessionRepository) Delete ¶
func (sr *SessionRepository) Delete(id string) error
func (*SessionRepository) DeleteByUser ¶
func (sr *SessionRepository) DeleteByUser(userID, id string) error
func (*SessionRepository) GenerateToken ¶
func (sr *SessionRepository) GenerateToken(sessionID string) (string, error)
func (*SessionRepository) ValidateAndRenew ¶
func (sr *SessionRepository) ValidateAndRenew(sessionToken string) (string, error)
func (*SessionRepository) ValidateToken ¶
func (sr *SessionRepository) ValidateToken(sessionToken string) (string, error)
type UserRepository ¶
UserRepository implements IUserRepository
func (*UserRepository) CheckLoginCredentials ¶
func (ur *UserRepository) CheckLoginCredentials(name string, password []byte) (bool, error)
CheckLoginCredentials checks if the provided credentials are valid to perform a login
func (*UserRepository) Create ¶
func (ur *UserRepository) Create(name string, password []byte, isAdmin bool) (user models.User, err error)
Create creates an user and save it to the storage This methods will permorn validations over the provided data
func (*UserRepository) CreateByUser ¶
func (ur *UserRepository) CreateByUser(requesterID string, name string, password []byte, isAdmin bool) (user models.User, err error)
CreateByUser creates an user and save it to the storage This methods will permorn validations over the provided data The data validations in this method can produce an ErrInvalidName or an ErrInvalidPassword The requester must be an admin to perform this action
func (*UserRepository) Delete ¶
func (ur *UserRepository) Delete(id string) error
Delete deletes an user from the storage If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned
func (*UserRepository) DeleteByUser ¶
func (ur *UserRepository) DeleteByUser(requesterID, id string) (err error)
DeleteByUser deletes an user from the storage If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned The requester must only delete himself or be an admin to perform this action
func (*UserRepository) Get ¶
func (ur *UserRepository) Get(id string) (models.User, error)
Get returns an user from the storage If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned
func (*UserRepository) GetByUser ¶
func (ur *UserRepository) GetByUser(requesterID, id string) (user models.User, err error)
GetByUser returns an user from the storage If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned The requester must only request information about himself or be an admin to perform this action
func (*UserRepository) List ¶
func (ur *UserRepository) List(limit, offset uint) ([]models.User, error)
List lits the users If the limit is set to 0, no limit will be established, the same applies to the offset
func (*UserRepository) ListByUser ¶
func (ur *UserRepository) ListByUser(requesterID string, limit, offset uint) (users []models.User, err error)
ListByUser lits the users If limit is set to 0, no limit will be established The requester must be an admin to perform this action
func (*UserRepository) Update ¶
func (ur *UserRepository) Update(payload user_repository.UpdatePayload) (err error)
Update replaces the values of the user in the storage with the values of the user provided by parameter If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned This methods will permorn validations over the provided data
func (*UserRepository) UpdateByUser ¶
func (ur *UserRepository) UpdateByUser(requesterID string, user user_repository.UpdatePayload) (err error)
UpdateByUser replaces the values of the user in the storage with the values of the user provided by parameter This methods will permorn validations over the provided data The data validations in this method can produce an ErrInvalidName or an ErrInvalidPassword If the user does not exists in the storage an error pkg/interfaces/storage.NotFoundError would be returned The requestor can only modify information about himself or otherwise be an admin to perform this action. The isAdmin property can only be changed by other admins.