Skip to content

Commit

Permalink
added mail service for accept and revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
majimearun committed Dec 1, 2022
1 parent 55b33d9 commit a785fdf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"java.compile.nullAnalysis.mode": "automatic"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ecommerce.gomart.GomartUser.Admin;

import com.ecommerce.gomart.Email.Email;
import com.ecommerce.gomart.Email.EmailService;
import com.ecommerce.gomart.GomartUser.GomartUser;
import com.ecommerce.gomart.GomartUser.GomartUserRepository;
import com.ecommerce.gomart.GomartUser.Manager.Manager;
Expand Down Expand Up @@ -47,6 +49,9 @@ public void giveManagerAccess(Long adminId, Long userId){
user.setRole(Role.MANAGER);
user.setManager(new Manager(true, ManagerStatus.Approved));
gomartUserRepository.save(user);
EmailService emailService = new EmailService();
Email email = new Email(user.getEmail(), "Manager Access Granted", "You have been granted Manager access to Gomart. Please login to your account to continue using your Manager Account.");
emailService.sendSimpleMail(email);
}
else{
throw new ResponseStatusException(HttpStatus.FORBIDDEN, "User does not have Admin level access or is not logged in");
Expand All @@ -60,6 +65,9 @@ public void removeManagerAccess(Long adminId, Long userId){
user.setRole(Role.CUSTOMER);
user.setManager(new Manager(false, null));
gomartUserRepository.save(user);
EmailService emailService = new EmailService();
Email email = new Email(user.getEmail(), "Manager Access Revoked", "Your Manager access to Gomart has been revoked. Ypu can still use the account as a Customer.");
emailService.sendSimpleMail(email);
}
else{
throw new ResponseStatusException(HttpStatus.FORBIDDEN, "User does not have Admin level access or is not logged in");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ecommerce.gomart.Product;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
Expand All @@ -11,9 +10,6 @@ public interface ProductRepository extends JpaRepository<Product, Long> {

List<Product> findByCategory(Category category);

@Query(value = "SELECT *, LEVENSHTEIN(product_name, :name) FROM gomart_products ORDER BY LEVENSHTEIN(product_name, :name) ASC", nativeQuery = true)
List<Product> findByFuzzyName(String name);

List<Product> findByCategoryAndPriceBetween(Category category, double min, double max);

List<Product> findByNameIgnoreCaseContaining(String name);
Expand Down

0 comments on commit a785fdf

Please sign in to comment.