Subversion Repositories SmartDukaan

Rev

Rev 22860 | Rev 23366 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.fofo.FofoStore;
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
import com.spice.profitmandi.web.model.LoginDetails;
import com.spice.profitmandi.web.util.CookiesProcessor;

@Controller
@Transactional(rollbackFor = Throwable.class)
public class DashboardController {

        @Autowired
        private CookiesProcessor cookiesProcessor;
        
        @Autowired
        private FofoStoreRepository fofoStoreRepository;
        
        private static final Logger LOGGER = LoggerFactory.getLogger(DashboardController.class);
        
        @RequestMapping(value = "/dashboard", method = RequestMethod.GET)
        public String dashboard(HttpServletRequest request, Model model) throws ProfitMandiBusinessException{
                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("roleTypes", loginDetails.getRoleTypes());
                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";
        }
        
}