| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.net.URISyntaxException;
|
4 |
import java.net.URISyntaxException;
|
| - |
|
5 |
import java.util.List;
|
| - |
|
6 |
import java.util.Set;
|
| 5 |
|
7 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
8 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
9 |
|
| 8 |
import org.apache.logging.log4j.Logger;
|
10 |
import org.apache.logging.log4j.Logger;
|
| 9 |
import org.apache.logging.log4j.LogManager;
|
11 |
import org.apache.logging.log4j.LogManager;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
12 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
13 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 11 |
import org.springframework.beans.factory.annotation.Value;
|
14 |
import org.springframework.beans.factory.annotation.Value;
|
| 12 |
import org.springframework.stereotype.Controller;
|
15 |
import org.springframework.stereotype.Controller;
|
| 13 |
import org.springframework.transaction.annotation.Transactional;
|
16 |
import org.springframework.transaction.annotation.Transactional;
|
| 14 |
import org.springframework.ui.Model;
|
17 |
import org.springframework.ui.Model;
|
| 15 |
import org.springframework.web.bind.annotation.RequestMapping;
|
18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 16 |
import org.springframework.web.bind.annotation.RequestMethod;
|
19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 17 |
|
20 |
|
| 18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 19 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
24 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 20 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
25 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
26 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 21 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
27 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22 |
import com.spice.profitmandi.web.model.LoginDetails;
|
28 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 23 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
29 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24 |
|
30 |
|
| 25 |
@Controller
|
31 |
@Controller
|
| Line 34... |
Line 40... |
| 34 |
|
40 |
|
| 35 |
@Autowired
|
41 |
@Autowired
|
| 36 |
private CookiesProcessor cookiesProcessor;
|
42 |
private CookiesProcessor cookiesProcessor;
|
| 37 |
|
43 |
|
| 38 |
@Autowired
|
44 |
@Autowired
|
| - |
|
45 |
@Qualifier("fofoInventoryService")
|
| 39 |
private InventoryService inventoryService;
|
46 |
private InventoryService inventoryService;
|
| - |
|
47 |
|
| - |
|
48 |
@Autowired
|
| - |
|
49 |
private RoleRepository roleRepository;
|
| - |
|
50 |
|
| 40 |
@Autowired
|
51 |
@Autowired
|
| 41 |
private FofoStoreRepository fofoStoreRepository;
|
52 |
private FofoStoreRepository fofoStoreRepository;
|
| 42 |
|
53 |
|
| 43 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
54 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 44 |
|
55 |
|
| Line 50... |
Line 61... |
| 50 |
try {
|
61 |
try {
|
| 51 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
62 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 52 |
} catch (ProfitMandiBusinessException e) {
|
63 |
} catch (ProfitMandiBusinessException e) {
|
| 53 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
64 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 54 |
}
|
65 |
}
|
| - |
|
66 |
|
| - |
|
67 |
|
| 55 |
model.addAttribute("fofoStoreCode", fofoStore != null ? fofoStore.getCode() : null);
|
68 |
model.addAttribute("fofoStoreCode", fofoStore != null ? fofoStore.getCode() : null);
|
| 56 |
model.addAttribute("appContextPath", request.getContextPath());
|
69 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 57 |
model.addAttribute("roleTypes", loginDetails.getRoleTypes());
|
70 |
model.addAttribute("fofoAdmin", this.isAdmin(loginDetails.getRoleIds()));
|
| 58 |
model.addAttribute("webApiHost", webApiHost);
|
71 |
model.addAttribute("webApiHost", webApiHost);
|
| 59 |
model.addAttribute("webApiPort", webApiPort);
|
72 |
model.addAttribute("webApiPort", webApiPort);
|
| 60 |
//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
73 |
//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
| 61 |
//inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
74 |
//inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 62 |
return "dashboard";
|
75 |
return "dashboard";
|
| 63 |
}
|
76 |
}
|
| 64 |
|
77 |
|
| - |
|
78 |
private boolean isAdmin(Set<Integer> roleIds) {
|
| - |
|
79 |
List<Role> roles = roleRepository.selectByIds(roleIds);
|
| - |
|
80 |
for(Role role : roles) {
|
| - |
|
81 |
if(role.getName().equals(RoleType.FOFO_ADMIN.toString())) {
|
| - |
|
82 |
return true;
|
| - |
|
83 |
}
|
| - |
|
84 |
}
|
| - |
|
85 |
return false;
|
| - |
|
86 |
}
|
| - |
|
87 |
|
| 65 |
|
88 |
|
| 66 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
89 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 67 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable{
|
90 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable{
|
| 68 |
model.addAttribute("appContextPath", request.getContextPath());
|
91 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 69 |
return "contact-us";
|
92 |
return "contact-us";
|