Subversion Repositories SmartDukaan

Rev

Rev 23798 | Rev 23844 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23798 Rev 23838
Line 8... Line 8...
8
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletRequest;
9
 
9
 
10
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.Logger;
11
import org.apache.logging.log4j.Logger;
12
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.beans.factory.annotation.Autowired;
-
 
13
import org.springframework.beans.factory.annotation.Qualifier;
13
import org.springframework.beans.factory.annotation.Value;
14
import org.springframework.beans.factory.annotation.Value;
14
import org.springframework.stereotype.Controller;
15
import org.springframework.stereotype.Controller;
15
import org.springframework.transaction.annotation.Transactional;
16
import org.springframework.transaction.annotation.Transactional;
16
import org.springframework.ui.Model;
17
import org.springframework.ui.Model;
17
import org.springframework.web.bind.annotation.RequestMapping;
18
import org.springframework.web.bind.annotation.RequestMapping;
Line 20... Line 21...
20
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
21
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
21
import com.spice.profitmandi.dao.entity.dtr.Role;
22
import com.spice.profitmandi.dao.entity.dtr.Role;
22
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
23
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
23
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
24
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
24
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
25
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
25
import com.spice.profitmandi.service.authentication.RoleManager;
-
 
26
import com.spice.profitmandi.service.inventory.InventoryService;
26
import com.spice.profitmandi.service.inventory.InventoryService;
27
import com.spice.profitmandi.web.model.LoginDetails;
27
import com.spice.profitmandi.web.model.LoginDetails;
28
import com.spice.profitmandi.web.util.CookiesProcessor;
28
import com.spice.profitmandi.web.util.CookiesProcessor;
-
 
29
import com.spice.profitmandi.web.util.RoleManager;
29
 
30
 
30
@Controller
31
@Controller
31
@Transactional(rollbackFor = Throwable.class)
32
@Transactional(rollbackFor = Throwable.class)
32
public class DashboardController {
33
public class DashboardController {
33
	
34
	
Line 37... Line 38...
37
	@Value("${web.api.port}")
38
	@Value("${web.api.port}")
38
	private int webApiPort;
39
	private int webApiPort;
39
 
40
 
40
	@Autowired
41
	@Autowired
41
	private CookiesProcessor cookiesProcessor;
42
	private CookiesProcessor cookiesProcessor;
42
 
-
 
43
	@Autowired
-
 
44
	private FofoStoreRepository fofoStoreRepository;
-
 
45
	
43
	
46
	@Autowired
44
	@Autowired
47
	private RoleManager roleManager;
45
	private RoleManager roleManager;
48
	
46
	
-
 
47
	@Autowired
-
 
48
	private FofoStoreRepository fofoStoreRepository;
-
 
49
	
49
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
50
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
50
	
51
	
51
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
52
	@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
52
	public String dashboard(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, URISyntaxException, IOException{
53
	public String dashboard(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, URISyntaxException, IOException{
53
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
54
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
Line 56... Line 57...
56
		try {
57
		try {
57
			fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
58
			fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
58
		} catch (ProfitMandiBusinessException e) {
59
		} catch (ProfitMandiBusinessException e) {
59
			LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
60
			LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
60
		}
61
		}
61
		model.addAttribute("fofoStoreCode", fofoStore != null ? fofoStore.getCode() : null);
62
		model.addAttribute("fofoStore", fofoStore);
62
		model.addAttribute("appContextPath", request.getContextPath());
63
		model.addAttribute("appContextPath", request.getContextPath());
63
		model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
64
		model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
64
		model.addAttribute("webApiHost", webApiHost);
65
		model.addAttribute("webApiHost", webApiHost);
65
		model.addAttribute("webApiPort", webApiPort);
66
		model.addAttribute("webApiPort", webApiPort);
66
		//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
67
		//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());