Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
21292 ashik.ali 1
package com.spice.profitmandi.web.controller;
2
 
21448 ashik.ali 3
import java.util.Set;
4
 
21292 ashik.ali 5
import javax.servlet.http.HttpServletRequest;
6
 
21463 ashik.ali 7
import org.apache.thrift.TException;
8
import org.apache.thrift.transport.TTransportException;
21292 ashik.ali 9
import org.slf4j.Logger;
10
import org.slf4j.LoggerFactory;
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.http.ResponseEntity;
13
import org.springframework.stereotype.Controller;
21692 amit.gupta 14
import org.springframework.transaction.annotation.Transactional;
21309 ashik.ali 15
import org.springframework.web.bind.annotation.RequestBody;
21292 ashik.ali 16
import org.springframework.web.bind.annotation.RequestMapping;
17
import org.springframework.web.bind.annotation.RequestMethod;
18
import org.springframework.web.bind.annotation.RequestParam;
19
 
20
import com.spice.profitmandi.common.ResponseCodeHolder;
21
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
22
import com.spice.profitmandi.common.model.ProfitMandiConstants;
21463 ashik.ali 23
import com.spice.profitmandi.common.model.UserInfo;
21390 ashik.ali 24
import com.spice.profitmandi.dao.entity.Address;
25
import com.spice.profitmandi.dao.entity.Brand;
26
import com.spice.profitmandi.dao.entity.Document;
21292 ashik.ali 27
import com.spice.profitmandi.dao.entity.Retailer;
21390 ashik.ali 28
import com.spice.profitmandi.dao.entity.RetailerBrand;
29
import com.spice.profitmandi.dao.entity.RetailerRegisteredAddress;
30
import com.spice.profitmandi.dao.entity.Shop;
31
import com.spice.profitmandi.dao.entity.ShopAddress;
21463 ashik.ali 32
import com.spice.profitmandi.dao.entity.User;
21390 ashik.ali 33
import com.spice.profitmandi.dao.repository.AddressRepository;
34
import com.spice.profitmandi.dao.repository.BrandRepository;
35
import com.spice.profitmandi.dao.repository.DocumentRepository;
21426 ashik.ali 36
import com.spice.profitmandi.dao.repository.RetailerAddressRepository;
21390 ashik.ali 37
import com.spice.profitmandi.dao.repository.RetailerBrandRepository;
38
import com.spice.profitmandi.dao.repository.RetailerRegisteredAddressRepository;
21292 ashik.ali 39
import com.spice.profitmandi.dao.repository.RetailerRepository;
21390 ashik.ali 40
import com.spice.profitmandi.dao.repository.ShopAddressRepository;
41
import com.spice.profitmandi.dao.repository.ShopRepository;
21463 ashik.ali 42
import com.spice.profitmandi.dao.repository.UserRepository;
43
import com.spice.profitmandi.thrift.clients.UserClient;
21431 ashik.ali 44
import com.spice.profitmandi.web.req.Category;
21426 ashik.ali 45
import com.spice.profitmandi.web.req.CreateRetailerAddressRequest;
46
import com.spice.profitmandi.web.req.CreateRetailerRequest;
47
import com.spice.profitmandi.web.req.RetailerAddBrandRequest;
21440 ashik.ali 48
import com.spice.profitmandi.web.util.ResponseSender;
21292 ashik.ali 49
 
21463 ashik.ali 50
import in.shop2020.model.v1.user.Sex;
51
import in.shop2020.model.v1.user.UserContextException;
21302 ashik.ali 52
import io.swagger.annotations.ApiImplicitParam;
53
import io.swagger.annotations.ApiImplicitParams;
54
import io.swagger.annotations.ApiOperation;
55
 
21292 ashik.ali 56
@Controller
21692 amit.gupta 57
@Transactional
21292 ashik.ali 58
public class RetailerController {
59
 
60
	private static final Logger LOGGER=LoggerFactory.getLogger(RetailerController.class);
61
 
62
	@Autowired
21463 ashik.ali 63
	UserRepository userRepository;
64
 
65
	@Autowired
21440 ashik.ali 66
	ResponseSender<?> responseSender;
67
 
68
	@Autowired
21292 ashik.ali 69
	RetailerRepository retailerRepository;
70
 
21390 ashik.ali 71
	@Autowired
72
	BrandRepository brandRepository;
73
 
74
	@Autowired
75
	AddressRepository addressRepository;
76
 
77
	@Autowired
78
	DocumentRepository documentRepository;
79
 
80
	@Autowired
81
	ShopRepository shopRepository;
82
 
83
	@Autowired
84
	RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
85
 
86
	@Autowired
21426 ashik.ali 87
	RetailerAddressRepository retailerAddressRepository;
88
 
89
	@Autowired
21390 ashik.ali 90
	ShopAddressRepository shopAddressRepository;
91
 
92
	@Autowired
93
	RetailerBrandRepository retailerBrandRepository;
94
 
21302 ashik.ali 95
	@ApiImplicitParams({
96
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
97
				required = true, dataType = "string", paramType = "header")
98
	})
21309 ashik.ali 99
 
21302 ashik.ali 100
	@ApiOperation(value = "Create Retailer")
101
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER, method=RequestMethod.POST)
21426 ashik.ali 102
	public ResponseEntity<?> createRetailer(HttpServletRequest request, @RequestBody CreateRetailerRequest createRetailerRequest){
21292 ashik.ali 103
		LOGGER.info("requested url : "+request.getRequestURL().toString());
21440 ashik.ali 104
		try{
21691 amit.gupta 105
			UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
21463 ashik.ali 106
			User user = userRepository.selectById(userInfo.getUserId());
107
			this.createRetailer(user.getEmailId(), createRetailerRequest);
21440 ashik.ali 108
			return responseSender.ok(ResponseCodeHolder.getMessage("RTLR_OK_1000"));
109
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
110
			LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
111
			return responseSender.badRequest(profitMandiBusinessException);
112
		}
113
	}
114
 
21463 ashik.ali 115
	private void createRetailer(String emailId, CreateRetailerRequest createRetailerRequest) 
21440 ashik.ali 116
			throws ProfitMandiBusinessException{
21390 ashik.ali 117
		Retailer retailer = new Retailer();
21426 ashik.ali 118
		retailer.setName(createRetailerRequest.getName());
119
		retailer.setNumber(createRetailerRequest.getNumber());
120
		retailer.setType(createRetailerRequest.getType());
121
		retailer.setMonthlySaleValue(createRetailerRequest.getMonthlySaleValue());
122
		retailer.setSmartphoneSaleValue(createRetailerRequest.getSmartphoneSaleValue());
123
		retailer.setRecharge(createRetailerRequest.getLineOfBusiness().isRecharge());
124
		retailer.setMobile(createRetailerRequest.getLineOfBusiness().isMobile());
125
		retailer.setAccessories(createRetailerRequest.getLineOfBusiness().isAccessories());
21431 ashik.ali 126
		retailer.setOther1(createRetailerRequest.getLineOfBusiness().getOther1());
127
		retailer.setOther2(createRetailerRequest.getLineOfBusiness().getOther2());
21440 ashik.ali 128
		Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
129
		if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
130
			LOGGER.error("documet is already mapped with another retailer");
21448 ashik.ali 131
			throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "DCMNT_1000");
21440 ashik.ali 132
		}
133
		retailer.setDocumentId(retailerDocument.getId());
134
		final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
135
		if(shopRepository.isExistByDocumentId(shopDocument.getId())){
21448 ashik.ali 136
			throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "DCMNT_1000");
21440 ashik.ali 137
		}
21463 ashik.ali 138
		documentRepository.markDocumentAsPersisted(retailerDocument.getId());
21448 ashik.ali 139
		if(retailerRepository.isExistByNumberAndType(retailer.getNumber(), retailer.getType())){
140
			throw new ProfitMandiBusinessException(ProfitMandiConstants.NUMBER + ", " + ProfitMandiConstants.TYPE, retailer.getNumber() + ", " + retailer.getType(), "RTLR_1001");
141
		}
21463 ashik.ali 142
		documentRepository.markDocumentAsPersisted(shopDocument.getId());
143
		retailer.setId(this.createSololicUser(emailId));
21440 ashik.ali 144
		retailerRepository.persist(retailer);
145
		Shop shop = new Shop();
146
		shop.setName(createRetailerRequest.getShop().getName());
147
		shop.setDocumentId(shopDocument.getId());
148
		shop.setRetailerId(retailer.getId());
149
		shopRepository.persist(shop);
21448 ashik.ali 150
		this.addBrandWithRetailer(retailer.getId(), createRetailerRequest.getCategories());
21440 ashik.ali 151
		final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
21426 ashik.ali 152
 
21440 ashik.ali 153
		if(!addressRepository.isExist(addressRetailer)){
154
			addressRepository.persist(addressRetailer);
21292 ashik.ali 155
		}
21440 ashik.ali 156
		final RetailerRegisteredAddress retailerRegisteredAddress = new RetailerRegisteredAddress();
157
		retailerRegisteredAddress.setRetailerId(retailer.getId());
158
		retailerRegisteredAddress.setAddressId(addressRetailer.getId());
159
		retailerRegisteredAddressRepository.persist(retailerRegisteredAddress);
21463 ashik.ali 160
		if(!createRetailerRequest.isShopAddressSameAsRetailerAddress() && createRetailerRequest.getAddress() == null){
161
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ADDRESS, "", "");
21440 ashik.ali 162
		}
21463 ashik.ali 163
		if(createRetailerRequest.isShopAddressSameAsRetailerAddress()){
164
			ShopAddress shopAddress = new ShopAddress();
165
			shopAddress.setShopId(shop.getId());
166
			shopAddress.setAddressId(addressRetailer.getId());
167
			shopAddressRepository.persist(shopAddress);
168
		}else{
169
			final Address addressShop = this.createAddress(createRetailerRequest.getShop().getAddress());
170
			if(!addressRepository.isExist(addressShop)){
171
				addressRepository.persist(addressShop);
172
			}
173
			ShopAddress shopAddress = new ShopAddress();
174
			shopAddress.setShopId(shop.getId());
175
			shopAddress.setAddressId(addressShop.getId());
176
			shopAddressRepository.persist(shopAddress);
177
		}
21292 ashik.ali 178
	}
179
 
21463 ashik.ali 180
	private int createSololicUser(String emailId) throws ProfitMandiBusinessException{
181
		in.shop2020.model.v1.user.User user = new in.shop2020.model.v1.user.User();
182
		user.setEmail(emailId);
183
		user.setPassword("");
184
		user.setCommunicationEmail(emailId);
185
		user.setSex(Sex.WONT_SAY);
186
 
187
		try {
188
			UserClient userContextServiceClient = new UserClient();
189
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
190
			user = userClient.createUser(user);
191
			return (int)user.getUserId();
192
		}catch (UserContextException ux){
193
			LOGGER.error("Unable to register user: " + ux.getMessage());
194
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
195
		} catch (TTransportException e) {
196
			LOGGER.error("Unable to register user." + e);
197
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
198
		}catch (TException e) {
199
			LOGGER.error("Unable to register user." + e);
200
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
201
		} 
202
	}
21448 ashik.ali 203
	private void addBrandWithRetailer(int retailerId, Set<Category> categories)
204
		throws ProfitMandiBusinessException{
205
		for(Category category : categories){
206
			for(com.spice.profitmandi.web.req.Brand brandModel : category.getBrands()){
207
				Brand brand = brandRepository.selectByIdAndName(brandModel.getId(), brandModel.getName());
208
				final RetailerBrand retailerBrand = new RetailerBrand();
209
				retailerBrand.setRetailerId(retailerId);
210
				retailerBrand.setBrandId(brand.getId());
211
				retailerBrandRepository.persist(retailerBrand);
212
			}
213
		}
214
	}
21292 ashik.ali 215
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ALL,method=RequestMethod.GET)
21496 ashik.ali 216
	public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize){
21292 ashik.ali 217
		LOGGER.info("requested url : "+request.getRequestURL().toString());
21496 ashik.ali 218
		return responseSender.ok(retailerRepository.selectAll(pageNumber, pageSize));
21292 ashik.ali 219
	}
220
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID, method=RequestMethod.GET)
21431 ashik.ali 221
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
21292 ashik.ali 222
		LOGGER.info("requested url : "+request.getRequestURL().toString());
223
		try {
21440 ashik.ali 224
			return responseSender.ok(retailerRepository.selectById(id));
225
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
226
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
227
			return responseSender.badRequest(profitMandiBusinessException);
21292 ashik.ali 228
		}
229
	}
230
 
231
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_NAME, method=RequestMethod.GET)
232
	public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
233
		LOGGER.info("requested url : "+request.getRequestURL().toString());
234
		try {
21440 ashik.ali 235
			return responseSender.ok(retailerRepository.selectByName(name));
236
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
237
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
238
			return responseSender.badRequest(profitMandiBusinessException);
21292 ashik.ali 239
		}
240
	}
241
 
242
 
243
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID,method=RequestMethod.DELETE)
21431 ashik.ali 244
	public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") int id){
21292 ashik.ali 245
		LOGGER.info("requested url : "+request.getRequestURL().toString());
246
		try {
247
			retailerRepository.deleteById(id);
21440 ashik.ali 248
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
249
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
250
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
251
			return responseSender.badRequest(profitMandiBusinessException);
21292 ashik.ali 252
		}
253
	}
254
 
21426 ashik.ali 255
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ADD, method=RequestMethod.POST)
21431 ashik.ali 256
	public ResponseEntity<?> addShop(HttpServletRequest request, @RequestBody com.spice.profitmandi.web.req.Shop createShop, @RequestParam(name = "retailerId") int retailerId){
21426 ashik.ali 257
		LOGGER.info("requested url : "+request.getRequestURL().toString());
258
		try {
259
			Document document = documentRepository.selectById(createShop.getDocumentId());
260
			if(shopRepository.isExistByDocumentId(createShop.getDocumentId())){
261
				LOGGER.error("documet is already mapped with another shop");
262
				throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "");
263
			}
264
			retailerRepository.selectById(retailerId);
265
			Shop shop = new Shop();
266
			shop.setRetailerId(retailerId);
267
			Address address = this.createAddress(createShop.getAddress());
268
			addressRepository.persist(address);
269
			shop.setAddressId(address.getId());
270
			shop.setDocumentId(document.getId());
271
			shopRepository.persist(shop);
272
			ShopAddress shopAddress = new ShopAddress();
273
			shopAddress.setAddressId(address.getId());
274
			shopAddress.setShopId(shop.getId());
275
			shopAddressRepository.persist(shopAddress);
21440 ashik.ali 276
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
277
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
278
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
279
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 280
		}
281
	}
282
 
283
 
21302 ashik.ali 284
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_REMOVE, method=RequestMethod.DELETE)
21431 ashik.ali 285
	public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") int shopId, @RequestParam(name = "retailerId") int retailerId){
21292 ashik.ali 286
		LOGGER.info("requested url : "+request.getRequestURL().toString());
287
		try {
288
			retailerRepository.removeShop(shopId, retailerId);
21440 ashik.ali 289
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
290
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
291
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
292
			return responseSender.badRequest(profitMandiBusinessException);
21292 ashik.ali 293
		}
294
	}
295
 
21426 ashik.ali 296
	private Address createAddress(com.spice.profitmandi.web.req.Address createAddress){
297
		Address address = new Address();
298
		address.setName(createAddress.getName());
299
		address.setLine1(createAddress.getLine1());
300
		address.setLine2(createAddress.getLine2());
301
		address.setLandmark(createAddress.getLandmark());
302
		address.setCity(createAddress.getCity());
303
		address.setState(createAddress.getState());
304
		address.setPinCode(createAddress.getPinCode());
305
		address.setCountry(createAddress.getCountry());
306
		address.setPhoneNumber(createAddress.getPhoneNumber());
307
		return address;
308
	}
21440 ashik.ali 309
 
21426 ashik.ali 310
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ADD, method=RequestMethod.POST)
311
	public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CreateRetailerAddressRequest createRetailerAddress){
312
		LOGGER.info("requested url : "+request.getRequestURL().toString());
313
		try {
314
			retailerRepository.addAddress(this.createAddress(createRetailerAddress.getAddress()), createRetailerAddress.getRetailerId());
21440 ashik.ali 315
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
316
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
317
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
318
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 319
		}
320
	}
21292 ashik.ali 321
 
21426 ashik.ali 322
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_REMOVE, method=RequestMethod.DELETE)
21431 ashik.ali 323
	public ResponseEntity<?> removeAddress(HttpServletRequest request, @RequestParam(name = "addressId") int addressId, @RequestParam(name = "retailerId") int retailerId){
21426 ashik.ali 324
		LOGGER.info("requested url : "+request.getRequestURL().toString());
325
		try {
326
			retailerRepository.removeAddress(addressId, retailerId);
21440 ashik.ali 327
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
328
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
329
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
330
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 331
		}
332
	}
333
 
334
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ADD, method=RequestMethod.POST)
335
	public ResponseEntity<?> addBrand(HttpServletRequest request, @RequestBody RetailerAddBrandRequest retailerAddBrandRequest){
336
		LOGGER.info("requested url : "+request.getRequestURL().toString());
337
		try {
21448 ashik.ali 338
			retailerRepository.selectById(retailerAddBrandRequest.getRetailerId());
339
			this.addBrandWithRetailer(retailerAddBrandRequest.getRetailerId(), retailerAddBrandRequest.getCategories());
21440 ashik.ali 340
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
341
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
342
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
343
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 344
		}
345
	}
346
 
347
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_REMOVE, method=RequestMethod.DELETE)
21431 ashik.ali 348
	public ResponseEntity<?> removeBrand(HttpServletRequest request, @RequestParam(name = "brandId") int brandId, @RequestParam(name = "retailerId") int retailerId){
21426 ashik.ali 349
		LOGGER.info("requested url : "+request.getRequestURL().toString());
350
		try {
351
			brandRepository.selectById(brandId);
352
			retailerRepository.selectById(retailerId);
21448 ashik.ali 353
			retailerBrandRepository.deleteByRetailerAndBrandId(retailerId, brandId);
21440 ashik.ali 354
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
355
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
356
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
357
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 358
		}
359
	}
360
 
361
 
21448 ashik.ali 362
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_DOCUMENT, method=RequestMethod.GET)
363
	public ResponseEntity<?> getDocumentById(HttpServletRequest request, @RequestParam(name = "retailerId") int retailerId){
21426 ashik.ali 364
		LOGGER.info("requested url : "+request.getRequestURL().toString());
365
		try {
21448 ashik.ali 366
			return responseSender.ok(retailerRepository.selectDocumentById(retailerId));
21440 ashik.ali 367
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
368
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
369
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 370
		}
371
	}
372
 
21448 ashik.ali 373
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_REGISTERED_ADDRESS, method=RequestMethod.GET)
374
	public ResponseEntity<?> getRegisteredAddressById(HttpServletRequest request, @RequestParam(name = "retailerId") int retailerId){
375
		LOGGER.info("requested url : "+request.getRequestURL().toString());
376
		try {
377
			return responseSender.ok(retailerRegisteredAddressRepository.selectByRetailerId(retailerId));
378
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
379
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
380
			return responseSender.badRequest(profitMandiBusinessException);
381
		}
382
	}
383
 
21426 ashik.ali 384
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ALL, method=RequestMethod.GET)
21431 ashik.ali 385
	public ResponseEntity<?> getAllShops(HttpServletRequest request, @RequestParam(name = "id") int id){
21426 ashik.ali 386
		LOGGER.info("requested url : "+request.getRequestURL().toString());
387
		try {
21440 ashik.ali 388
			return responseSender.ok(shopRepository.selectByRetailerId(id));
389
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
390
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
391
			return responseSender.badRequest(profitMandiBusinessException);
21426 ashik.ali 392
		}
393
	}
394
 
395
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ALL, method=RequestMethod.GET)
21431 ashik.ali 396
	public ResponseEntity<?> getAllAddresses(HttpServletRequest request, @RequestParam(name = "id") int id){
21426 ashik.ali 397
		LOGGER.info("requested url : "+request.getRequestURL().toString());
21440 ashik.ali 398
		return responseSender.ok(retailerAddressRepository.selectAddressesByRetailerId(id));
21426 ashik.ali 399
	}
400
 
401
 
402
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ALL, method=RequestMethod.GET)
21431 ashik.ali 403
	public ResponseEntity<?> getAllBrads(HttpServletRequest request, @RequestParam(name = "id") int id){
21426 ashik.ali 404
		LOGGER.info("requested url : "+request.getRequestURL().toString());
21440 ashik.ali 405
		return responseSender.ok(retailerBrandRepository.selectBrandNamesByRetailerId(id));
21426 ashik.ali 406
	}
407
 
21292 ashik.ali 408
}