| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23568 |
govind |
3 |
import java.io.IOException;
|
|
|
4 |
import java.net.URISyntaxException;
|
| 23784 |
ashik.ali |
5 |
import java.util.List;
|
|
|
6 |
import java.util.Set;
|
| 23568 |
govind |
7 |
|
| 22086 |
amit.gupta |
8 |
import javax.servlet.http.HttpServletRequest;
|
|
|
9 |
|
| 23786 |
amit.gupta |
10 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
11 |
import org.apache.logging.log4j.Logger;
|
| 22481 |
ashik.ali |
12 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
13 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
14 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
15 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
16 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
17 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
18 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
19 |
|
| 22481 |
ashik.ali |
20 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 23784 |
ashik.ali |
21 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 22654 |
ashik.ali |
22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 23784 |
ashik.ali |
23 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 22481 |
ashik.ali |
24 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 23798 |
amit.gupta |
25 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23568 |
govind |
26 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22481 |
ashik.ali |
27 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
28 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
|
|
29 |
|
| 21615 |
kshitij.so |
30 |
@Controller
|
| 22481 |
ashik.ali |
31 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
32 |
public class DashboardController {
|
| 23379 |
ashik.ali |
33 |
|
|
|
34 |
@Value("${web.api.host}")
|
|
|
35 |
private String webApiHost;
|
|
|
36 |
|
|
|
37 |
@Value("${web.api.port}")
|
|
|
38 |
private int webApiPort;
|
| 21615 |
kshitij.so |
39 |
|
| 22481 |
ashik.ali |
40 |
@Autowired
|
| 22927 |
ashik.ali |
41 |
private CookiesProcessor cookiesProcessor;
|
| 23786 |
amit.gupta |
42 |
|
| 22481 |
ashik.ali |
43 |
@Autowired
|
| 23786 |
amit.gupta |
44 |
private FofoStoreRepository fofoStoreRepository;
|
| 23784 |
ashik.ali |
45 |
|
| 23568 |
govind |
46 |
@Autowired
|
| 23786 |
amit.gupta |
47 |
private RoleManager roleManager;
|
| 23784 |
ashik.ali |
48 |
|
| 23568 |
govind |
49 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 21615 |
kshitij.so |
50 |
|
|
|
51 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 23568 |
govind |
52 |
public String dashboard(HttpServletRequest request, Model model) throws ProfitMandiBusinessException, URISyntaxException, IOException{
|
| 22927 |
ashik.ali |
53 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 22481 |
ashik.ali |
54 |
|
|
|
55 |
FofoStore fofoStore = null;
|
|
|
56 |
try {
|
| 22927 |
ashik.ali |
57 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
58 |
} catch (ProfitMandiBusinessException e) {
|
| 22927 |
ashik.ali |
59 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
60 |
}
|
|
|
61 |
model.addAttribute("fofoStoreCode", fofoStore != null ? fofoStore.getCode() : null);
|
| 22086 |
amit.gupta |
62 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 23796 |
amit.gupta |
63 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23379 |
ashik.ali |
64 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
65 |
model.addAttribute("webApiPort", webApiPort);
|
| 23568 |
govind |
66 |
//LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
67 |
//inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
68 |
return "dashboard";
|
|
|
69 |
}
|
|
|
70 |
|
| 22860 |
ashik.ali |
71 |
|
| 22354 |
ashik.ali |
72 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 22927 |
ashik.ali |
73 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable{
|
| 22354 |
ashik.ali |
74 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
75 |
return "contact-us";
|
|
|
76 |
}
|
|
|
77 |
|
| 23366 |
ashik.ali |
78 |
/*private List<PaymentOption> getPaymentOptions(int fofoId){
|
|
|
79 |
List<Integer> paymentOptionIds = fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId);
|
|
|
80 |
if(paymentOptionIds.isEmpty()){
|
|
|
81 |
return new ArrayList<>();
|
|
|
82 |
}
|
|
|
83 |
return paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds));
|
|
|
84 |
}*/
|
|
|
85 |
|
|
|
86 |
|
| 21615 |
kshitij.so |
87 |
}
|