| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.util.Arrays;
|
- |
|
| 4 |
import java.util.List;
|
- |
|
| 5 |
|
- |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
3 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
4 |
|
| 8 |
import org.slf4j.Logger;
|
5 |
import org.slf4j.Logger;
|
| 9 |
import org.slf4j.LoggerFactory;
|
6 |
import org.slf4j.LoggerFactory;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
7 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 11 |
import org.springframework.stereotype.Controller;
|
8 |
import org.springframework.stereotype.Controller;
|
| 12 |
import org.springframework.ui.Model;
|
9 |
import org.springframework.ui.Model;
|
| 13 |
import org.springframework.web.bind.annotation.ModelAttribute;
|
10 |
import org.springframework.web.bind.annotation.ModelAttribute;
|
| 14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
11 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
12 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 16 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 17 |
|
13 |
|
| 18 |
import com.spice.profitmandi.common.model.CustomItem;
|
- |
|
| 19 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
14 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 20 |
import com.spice.profitmandi.dao.repository.OrderRepository;
|
15 |
import com.spice.profitmandi.dao.repository.OrderRepository;
|
| 21 |
import com.spice.profitmandi.web.model.FofoDetails;
|
16 |
import com.spice.profitmandi.web.model.FofoDetails;
|
| - |
|
17 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
| 22 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
18 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 23 |
|
19 |
|
| 24 |
@Controller
|
20 |
@Controller
|
| 25 |
public class OrderController {
|
21 |
public class PurchaseController {
|
| 26 |
|
22 |
|
| 27 |
private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);
|
23 |
private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseController.class);
|
| 28 |
|
24 |
|
| 29 |
@Autowired
|
25 |
@Autowired
|
| 30 |
OrderRepository orderRepository;
|
26 |
OrderRepository orderRepository;
|
| 31 |
|
27 |
|
| 32 |
@Autowired
|
28 |
@Autowired
|
| - |
|
29 |
CookiesFetcher cookiesFetcher;
|
| - |
|
30 |
|
| - |
|
31 |
@Autowired
|
| 33 |
MVCResponseSender mvcResponseSender;
|
32 |
MVCResponseSender mvcResponseSender;
|
| 34 |
|
33 |
|
| 35 |
@RequestMapping(value = "/orders", method = RequestMethod.POST)
|
34 |
@RequestMapping(value = "/purchase", method = RequestMethod.POST)
|
| 36 |
public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request, @RequestParam(name = "airwayBillOrInvoiceNumber") String airwayBillOrInvoiceNumber, @RequestParam(name = ProfitMandiConstants.TYPE) String type, @ModelAttribute Model model) throws Exception{
|
35 |
public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request, Model model) throws Exception, ProfitMandiBusinessException{
|
| 37 |
FofoDetails fofoDetails = null;
|
36 |
FofoDetails fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| 38 |
fofoDetails = (FofoDetails)request.getSession(false).getAttribute(ProfitMandiConstants.FOFO_DETAILS);
|
37 |
String airwayBillOrInvoiceNumber = (String) request.getAttribute("airwayBillOrInvoiceNumber");
|
| 39 |
if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type) || ProfitMandiConstants.INVOICE_NUMBER.equals(type)){
|
- |
|
| 40 |
List<CustomItem> customItems;
|
- |
|
| 41 |
if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type)){
|
- |
|
| 42 |
customItems = orderRepository.selectByAirwayBillNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
|
38 |
model.addAttribute("customItems", orderRepository.selectByAirwayBillOrInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId()));
|
| 43 |
}else{
|
39 |
return "purchase";
|
| 44 |
customItems = orderRepository.selectByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
|
- |
|
| 45 |
}
|
40 |
}
|
| - |
|
41 |
|
| 46 |
model.addAttribute("customItems", customItems);
|
42 |
@RequestMapping(value = "/purchase", method = RequestMethod.GET)
|
| - |
|
43 |
public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request) throws Exception{
|
| 47 |
return "orders";
|
44 |
return "purchase";
|
| 48 |
}else{
|
- |
|
| 49 |
LOGGER.error("Given type is not valid, please choose any one {}", Arrays.asList(ProfitMandiConstants.AIRWAY_BILL_NUMBER, ProfitMandiConstants.INVOICE_NUMBER));
|
- |
|
| 50 |
return mvcResponseSender.createResponseString("RTLR_VE_1021", false, "/error");
|
- |
|
| 51 |
}
|
- |
|
| 52 |
}
|
45 |
}
|
| 53 |
|
46 |
|
| 54 |
}
|
47 |
}
|