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