Subversion Repositories SmartDukaan

Rev

Rev 23494 | Rev 23568 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23494 Rev 23499
Line 32... Line 32...
32
import com.spice.profitmandi.dao.entity.dtr.Shop;
32
import com.spice.profitmandi.dao.entity.dtr.Shop;
33
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
33
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
34
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
34
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
35
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
35
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
36
import com.spice.profitmandi.service.user.RetailerService;
36
import com.spice.profitmandi.service.user.RetailerService;
37
import com.spice.profitmandi.web.model.LoginDetails;
-
 
38
import com.spice.profitmandi.web.util.CookiesProcessor;
-
 
39
 
37
 
40
@Controller
38
@Controller
41
@Transactional(rollbackFor=Throwable.class)
39
@Transactional(rollbackFor=Throwable.class)
42
public class RetailerController {
40
public class RetailerController {
43
 
41
 
Line 54... Line 52...
54
	
52
	
55
	@Autowired
53
	@Autowired
56
	private DocumentRepository documentRepository;
54
	private DocumentRepository documentRepository;
57
	
55
	
58
	@Autowired
56
	@Autowired
59
	private CookiesProcessor cookiesProcessor;
-
 
60
	
-
 
61
	@Autowired
-
 
62
	private ResponseSender<?> responseSender;
57
	private ResponseSender<?> responseSender;
63
	
58
	
64
	@RequestMapping(value = "/retailerDetail", method = RequestMethod.GET)
59
	@RequestMapping(value = "/retailerDetail", method = RequestMethod.GET)
65
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
60
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber, Model model)  throws ProfitMandiBusinessException{
66
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
61
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(), emailIdOrMobileNumber);
Line 87... Line 82...
87
	public ResponseEntity<?> getAllDistrict(@RequestParam(name = "stateName") String stateName){
82
	public ResponseEntity<?> getAllDistrict(@RequestParam(name = "stateName") String stateName){
88
		return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
83
		return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
89
	}
84
	}
90
	
85
	
91
	@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
86
	@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
92
	public ResponseEntity<?> retailerDocumentById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId) throws ProfitMandiBusinessException{
87
	public ResponseEntity<?> retailerDocumentById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException{
93
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
94
		Document document = documentRepository.selectById(documentId);
88
		Document document = documentRepository.selectById(documentId);
95
		Retailer retailer = retailerRepository.selectById(loginDetails.getFofoId());
89
		Retailer retailer = retailerRepository.selectById(retailerId);
96
		
90
		
97
		if(retailer.getDocumentId() == null) {
91
		if(retailer.getDocumentId() == null) {
98
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
92
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
99
		}
93
		}
100
		if(retailer.getDocumentId() != documentId) {
94
		if(retailer.getDocumentId() != documentId) {
Line 102... Line 96...
102
		}
96
		}
103
		return responseSender.ok(document);
97
		return responseSender.ok(document);
104
	}
98
	}
105
	
99
	
106
	@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
100
	@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
107
	public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, Model model) throws ProfitMandiBusinessException{
101
	public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model) throws ProfitMandiBusinessException{
108
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
109
		
102
		
110
		Retailer retailer = retailerRepository.selectById(loginDetails.getFofoId());
103
		Retailer retailer = retailerRepository.selectById(retailerId);
111
		
104
		
112
		if(retailer.getDocumentId() == null) {
105
		if(retailer.getDocumentId() == null) {
113
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
106
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
114
		}
107
		}
115
		
108
		
Line 142... Line 135...
142
		
135
		
143
		//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
136
		//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
144
	}
137
	}
145
	
138
	
146
	@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
139
	@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
147
	public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId) throws ProfitMandiBusinessException{
140
	public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId, @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException{
148
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
149
		Shop shop = shopRepository.selectById(shopId);
141
		Shop shop = shopRepository.selectById(shopId);
150
		
142
		
151
		if(shop.getRetailerId() != loginDetails.getFofoId()) {
143
		if(shop.getRetailerId() != retailerId) {
152
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
144
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
153
		}
145
		}
154
		
146
		
155
		if(shop.getDocumentId() == null) {
147
		if(shop.getDocumentId() == null) {
156
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
148
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
Line 159... Line 151...
159
		Document document = documentRepository.selectById(shop.getDocumentId());
151
		Document document = documentRepository.selectById(shop.getDocumentId());
160
		return responseSender.ok(document);
152
		return responseSender.ok(document);
161
	}
153
	}
162
	
154
	
163
	@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
155
	@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
164
	public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId, Model model) throws ProfitMandiBusinessException{
156
	public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId, @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model) throws ProfitMandiBusinessException{
165
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
166
		
157
		
167
		Shop shop = shopRepository.selectById(shopId);
158
		Shop shop = shopRepository.selectById(shopId);
168
		
159
		
169
		if(shop.getRetailerId() != loginDetails.getFofoId()) {
160
		if(shop.getRetailerId() != retailerId) {
170
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
161
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
171
		}
162
		}
172
		
163
		
173
		if(shop.getDocumentId() == null) {
164
		if(shop.getDocumentId() == null) {
174
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
165
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");