Subversion Repositories SmartDukaan

Rev

Rev 22981 | Rev 23047 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
22981 ashik.ali 1
package com.spice.profitmandi.web.controller;
2
 
3
import java.util.Map;
4
 
5
import javax.servlet.http.HttpServletRequest;
6
 
7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.stereotype.Controller;
11
import org.springframework.transaction.annotation.Transactional;
12
import org.springframework.ui.Model;
23026 ashik.ali 13
import org.springframework.web.bind.annotation.RequestBody;
22981 ashik.ali 14
import org.springframework.web.bind.annotation.RequestMapping;
15
import org.springframework.web.bind.annotation.RequestMethod;
16
import org.springframework.web.bind.annotation.RequestParam;
17
 
18
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
19
import com.spice.profitmandi.common.model.ProfitMandiConstants;
23026 ashik.ali 20
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
22981 ashik.ali 21
import com.spice.profitmandi.service.user.RetailerService;
22
 
23
@Controller
24
@Transactional(rollbackFor=Throwable.class)
25
public class RetailerController {
26
 
27
	private static final Logger LOGGER = LoggerFactory.getLogger(RetailerController.class);
28
 
29
	@Autowired
30
	private RetailerService retailerService;
31
 
32
	@RequestMapping(value = "/retailerDetail", method = RequestMethod.GET)
33
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
34
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
35
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
36
		model.addAllAttributes(map);
37
		return "retailer-details";
38
	}
39
 
40
	@RequestMapping(value = "/updateRetailerDocument", method = RequestMethod.PUT)
41
	public String updateRetailerDocument(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, Model model)  throws ProfitMandiBusinessException{
42
		LOGGER.info("Request Received at url {} with documentId {}", request.getRequestURI(), documentId);
43
		Map<String, Object> map = retailerService.updateRetailerDocument(emailIdOrMobileNumber, documentId);
44
		model.addAllAttributes(map);
45
		return "retailer-details";
46
	}
47
 
23026 ashik.ali 48
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
49
	public String updateRetailerDetails(HttpServletRequest request, @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model)  throws ProfitMandiBusinessException{
50
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
51
		Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
52
		model.addAllAttributes(map);
53
		return "retailer-details";
54
	}
55
 
22981 ashik.ali 56
	@RequestMapping(value = "/updateRetailerShopDocument", method = RequestMethod.PUT)
57
	public String updateRetailerShopDocument(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId, @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, Model model)  throws ProfitMandiBusinessException{
58
		LOGGER.info("Request Received at url {} with documentId {}", request.getRequestURI(), documentId);
59
		Map<String, Object> map = retailerService.updateRetailerShopDocument(emailIdOrMobileNumber, shopId, documentId);
60
		model.addAllAttributes(map);
61
		return "retailer-details";
62
	}
23026 ashik.ali 63
 
22981 ashik.ali 64
 
65
	@RequestMapping(value = "/retailerInfo", method = RequestMethod.GET)
66
	public String retailerInfo(HttpServletRequest request)  throws Exception{
67
		return "retailer-info";
68
	}
69
}