Subversion Repositories SmartDukaan

Rev

Rev 23026 | Go to most recent revision | Details | 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;
13
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestMethod;
15
import org.springframework.web.bind.annotation.RequestParam;
16
 
17
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
18
import com.spice.profitmandi.common.model.ProfitMandiConstants;
19
import com.spice.profitmandi.service.user.RetailerService;
20
 
21
@Controller
22
@Transactional(rollbackFor=Throwable.class)
23
public class RetailerController {
24
 
25
	private static final Logger LOGGER = LoggerFactory.getLogger(RetailerController.class);
26
 
27
	@Autowired
28
	private RetailerService retailerService;
29
 
30
	@RequestMapping(value = "/retailerDetail", method = RequestMethod.GET)
31
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
32
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
33
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
34
		model.addAllAttributes(map);
35
		return "retailer-details";
36
	}
37
 
38
	@RequestMapping(value = "/updateRetailerDocument", method = RequestMethod.PUT)
39
	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{
40
		LOGGER.info("Request Received at url {} with documentId {}", request.getRequestURI(), documentId);
41
		Map<String, Object> map = retailerService.updateRetailerDocument(emailIdOrMobileNumber, documentId);
42
		model.addAllAttributes(map);
43
		return "retailer-details";
44
	}
45
 
46
	@RequestMapping(value = "/updateRetailerShopDocument", method = RequestMethod.PUT)
47
	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{
48
		LOGGER.info("Request Received at url {} with documentId {}", request.getRequestURI(), documentId);
49
		Map<String, Object> map = retailerService.updateRetailerShopDocument(emailIdOrMobileNumber, shopId, documentId);
50
		model.addAllAttributes(map);
51
		return "retailer-details";
52
	}
53
 
54
	@RequestMapping(value = "/retailerInfo", method = RequestMethod.GET)
55
	public String retailerInfo(HttpServletRequest request)  throws Exception{
56
		return "retailer-info";
57
	}
58
}