Rev 29812 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import javax.servlet.http.HttpServletRequest;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;import org.springframework.http.MediaType;import org.springframework.http.ResponseEntity;import org.springframework.mail.javamail.JavaMailSender;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.services.mandii.MandiiService;import com.spice.profitmandi.common.web.util.ResponseSender;import com.spice.profitmandi.dao.entity.fofo.FofoStore;import com.spice.profitmandi.dao.enumuration.fofo.Gateway;import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;import com.spice.profitmandi.dao.repository.dtr.UserRepository;import com.spice.profitmandi.dao.repository.transaction.PaymentRepository;import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;import com.spice.profitmandi.service.wallet.WalletService;@Controller@Transactional(rollbackFor = Throwable.class)public class GatewayController {private static final Logger log = LogManager.getLogger(GatewayController.class);@AutowiredUserWalletRepository userWalletRepository;@AutowiredPaymentRepository paymentRepository;@AutowiredAddWalletRequestRepository addWalletRequestRepository;@AutowiredWalletService walletService;@AutowiredFofoStoreRepository fofoStoreRepository;@AutowiredJavaMailSender mailSender;@Autowired@Qualifier("userRepository")private UserRepository userRepository;@Autowiredprivate UserAccountRepository userAccountRepository;@Autowiredprivate MandiiService mandiiService;@AutowiredResponseSender<?> responseSender;@RequestMapping(value = "payment/gateway/status/{gateway}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)public ResponseEntity<?> getLoanStatus(HttpServletRequest request,@PathVariable Gateway gateway) throws ProfitMandiBusinessException {int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);FofoStore fs = fofoStoreRepository.selectByRetailerId(retailerId);if(gateway != null && gateway.equals(Gateway.MANDII)) {try {return responseSender.ok(mandiiService.getStatus(fs.getPan()));} catch (Exception e) {throw new ProfitMandiBusinessException("Loan Provider", gateway, "Cant fetch details for provider");}} else {throw new ProfitMandiBusinessException("Provider", "Empty", "Provider cant be empty");}}}