minor change

This commit is contained in:
Daniel Goc
2026-04-10 09:57:07 +02:00
parent 61ccd32c4a
commit c5832c0cf5
2 changed files with 14 additions and 14 deletions

View File

@@ -35,19 +35,19 @@ func (s *ProductService) Find(id_lang, userID uint, p find.Paging, filters *filt
}
func (s *ProductService) AddToFavorites(userID uint, productID uint) error {
count, err := s.productsRepo.ProductInDatabase(productID)
exists, err := s.productsRepo.ProductInDatabase(productID)
if err != nil {
return err
}
if count <= 0 {
if !exists {
return responseErrors.ErrProductNotFound
}
count, err = s.productsRepo.ExistsInFavorites(userID, productID)
exists, err = s.productsRepo.ExistsInFavorites(userID, productID)
if err != nil {
return err
}
if count >= 1 {
if exists {
return responseErrors.ErrAlreadyInFavorites
}
@@ -55,19 +55,19 @@ func (s *ProductService) AddToFavorites(userID uint, productID uint) error {
}
func (s *ProductService) RemoveFromFavorites(userID uint, productID uint) error {
count, err := s.productsRepo.ProductInDatabase(productID)
exists, err := s.productsRepo.ProductInDatabase(productID)
if err != nil {
return err
}
if count <= 0 {
if !exists {
return responseErrors.ErrProductNotFound
}
count, err = s.productsRepo.ExistsInFavorites(userID, productID)
exists, err = s.productsRepo.ExistsInFavorites(userID, productID)
if err != nil {
return err
}
if count <= 0 {
if !exists {
return responseErrors.ErrNotInFavorites
}