Rev 21561 | Rev 21582 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.util.Arrays;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.model.CustomItem;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.dao.repository.OrderRepository;import com.spice.profitmandi.web.model.FofoDetails;import com.spice.profitmandi.web.util.MVCResponseSender;@Controllerpublic class OrderController {private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);@AutowiredOrderRepository orderRepository;@AutowiredMVCResponseSender mvcResponseSender;@RequestMapping(value = "/orders", method = RequestMethod.POST)public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request, @RequestParam(name = "airwayBillOrInvoiceNumber") String airwayBillOrInvoiceNumber, @RequestParam(name = ProfitMandiConstants.TYPE) String type, @ModelAttribute Model model) throws Exception{FofoDetails fofoDetails = null;fofoDetails = (FofoDetails)request.getSession(false).getAttribute(ProfitMandiConstants.FOFO_DETAILS);if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type) || ProfitMandiConstants.INVOICE_NUMBER.equals(type)){List<CustomItem> customItems;if(ProfitMandiConstants.AIRWAY_BILL_NUMBER.equals(type)){customItems = orderRepository.selectByAirwayBillNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());}else{customItems = orderRepository.selectByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());}model.addAttribute("customItems", customItems);return "orders";}else{LOGGER.error("Given type is not valid, please choose any one {}", Arrays.asList(ProfitMandiConstants.AIRWAY_BILL_NUMBER, ProfitMandiConstants.INVOICE_NUMBER));return mvcResponseSender.createResponseString("RTLR_VE_1021", false, "/error");}}}