minor change
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user