Rev 23796 | Rev 23844 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.io.IOException;import java.net.URISyntaxException;import java.util.List;import java.util.Set;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.Value;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.ui.Model;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.dao.entity.dtr.Role;import com.spice.profitmandi.dao.entity.fofo.FofoStore;import com.spice.profitmandi.dao.enumuration.dtr.RoleType;import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;import com.spice.profitmandi.service.authentication.RoleManager;import com.spice.profitmandi.service.inventory.InventoryService;import com.spice.profitmandi.web.model.LoginDetails;import com.spice.profitmandi.web.util.CookiesProcessor;@Controller@Transactional(rollbackFor = Throwable.class)public class DashboardController {@Value("${web.api.host}")private String webApiHost;@Value("${web.api.port}")private int webApiPort;@Autowiredprivate CookiesProcessor cookiesProcessor;@Autowiredprivate FofoStoreRepository fofoStoreRepository;@Autowiredprivate RoleManager roleManager;private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);@RequestMapping(value = "/dashboard", method = RequestMethod.GET)public String dashboard(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, URISyntaxException, IOException{LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);FofoStore fofoStore = null;try {fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());} catch (ProfitMandiBusinessException e) {LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());}model.addAttribute("fofoStoreCode", fofoStore != null ? fofoStore.getCode() : null);model.addAttribute("appContextPath", request.getContextPath());model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));model.addAttribute("webApiHost", webApiHost);model.addAttribute("webApiPort", webApiPort);//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());//inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());return "dashboard";}@RequestMapping(value = "/contactUs", method = RequestMethod.GET)public String contactUs(HttpServletRequest request, Model model) throws Throwable{model.addAttribute("appContextPath", request.getContextPath());return "contact-us";}/*private List<PaymentOption> getPaymentOptions(int fofoId){List<Integer> paymentOptionIds = fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId);if(paymentOptionIds.isEmpty()){return new ArrayList<>();}return paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds));}*/}