Subversion Repositories SmartDukaan

Rev

Rev 21561 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21561 Rev 21574
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.util.HashSet;
3
import java.util.Arrays;
4
import java.util.Set;
4
import java.util.List;
5
 
5
 
-
 
6
import javax.servlet.http.HttpServletRequest;
-
 
7
 
-
 
8
import org.slf4j.Logger;
-
 
9
import org.slf4j.LoggerFactory;
-
 
10
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.stereotype.Controller;
11
import org.springframework.stereotype.Controller;
7
import org.springframework.ui.ModelMap;
12
import org.springframework.ui.Model;
8
import org.springframework.web.bind.annotation.ModelAttribute;
13
import org.springframework.web.bind.annotation.ModelAttribute;
9
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestMapping;
10
import org.springframework.web.bind.annotation.RequestMethod;
15
import org.springframework.web.bind.annotation.RequestMethod;
-
 
16
import org.springframework.web.bind.annotation.RequestParam;
11
 
17
 
-
 
18
import com.spice.profitmandi.common.model.CustomItem;
-
 
19
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
20
import com.spice.profitmandi.dao.repository.OrderRepository;
12
import com.spice.profitmandi.web.model.Car;
21
import com.spice.profitmandi.web.model.FofoDetails;
-
 
22
import com.spice.profitmandi.web.util.MVCResponseSender;
13
 
23
 
14
@Controller
24
@Controller
15
public class CarController {
25
public class OrderController {
16
 
26
 
17
	@RequestMapping(value = "/cars", method = RequestMethod.GET)
27
	private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);
18
	public String init(@ModelAttribute("model") ModelMap model) {
-
 
19
		Set<Car> cars = new HashSet<>();
-
 
20
		cars.add(new Car("Honda", "Civic"));
-
 
21
		cars.add(new Car("Toyota", "Camry"));
-
 
22
		cars.add(new Car("Nisaan", "Altima"));
-
 
23
	    model.addAttribute("cars", cars);
-
 
24
	    return "cars";
-
 
25
	}
28
	
-
 
29
	@Autowired
-
 
30
	OrderRepository orderRepository;
26
	
31
	
-
 
32
	@Autowired
-
 
33
	MVCResponseSender mvcResponseSender;
-
 
34
	
27
	@RequestMapping(value = "/index", method = RequestMethod.GET)
35
	@RequestMapping(value = "/orders", method = RequestMethod.POST)
28
	public String indexPage(){
36
	public String orderByAirwayBillOrInvoiceNumber(HttpServletRequest request, @RequestParam(name = "airwayBillOrInvoiceNumber") String airwayBillOrInvoiceNumber, @RequestParam(name = ProfitMandiConstants.TYPE) String type, @ModelAttribute Model model)  throws Exception{
-
 
37
		FofoDetails fofoDetails = null;
-
 
38
		fofoDetails = (FofoDetails)request.getSession(false).getAttribute(ProfitMandiConstants.FOFO_DETAILS);
-
 
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());
-
 
43
			}else{
-
 
44
				customItems = orderRepository.selectByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
-
 
45
			}
-
 
46
			model.addAttribute("customItems", customItems);
29
		return "index";
47
			return "orders";
-
 
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
		}
30
	}
52
	}
-
 
53
	
31
}
54
}