Rev 21390 | Rev 21435 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.time.LocalDateTime;import java.util.Set;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpStatus;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.ResponseCodeHolder;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.dao.entity.Address;import com.spice.profitmandi.dao.entity.Brand;import com.spice.profitmandi.dao.entity.Document;import com.spice.profitmandi.dao.entity.Retailer;import com.spice.profitmandi.dao.entity.RetailerBrand;import com.spice.profitmandi.dao.entity.RetailerRegisteredAddress;import com.spice.profitmandi.dao.entity.Shop;import com.spice.profitmandi.dao.entity.ShopAddress;import com.spice.profitmandi.dao.repository.AddressRepository;import com.spice.profitmandi.dao.repository.BrandRepository;import com.spice.profitmandi.dao.repository.DocumentRepository;import com.spice.profitmandi.dao.repository.RetailerAddressRepository;import com.spice.profitmandi.dao.repository.RetailerBrandRepository;import com.spice.profitmandi.dao.repository.RetailerRegisteredAddressRepository;import com.spice.profitmandi.dao.repository.RetailerRepository;import com.spice.profitmandi.dao.repository.ShopAddressRepository;import com.spice.profitmandi.dao.repository.ShopRepository;import com.spice.profitmandi.web.model.ProfitMandiResponse;import com.spice.profitmandi.web.model.Response;import com.spice.profitmandi.web.model.ResponseStatus;import com.spice.profitmandi.web.req.CreateRetailerAddressRequest;import com.spice.profitmandi.web.req.CreateRetailerRequest;import com.spice.profitmandi.web.req.RetailerAddBrandRequest;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;@Controllerpublic class RetailerController {private static final Logger LOGGER=LoggerFactory.getLogger(RetailerController.class);@AutowiredRetailerRepository retailerRepository;@AutowiredBrandRepository brandRepository;@AutowiredAddressRepository addressRepository;@AutowiredDocumentRepository documentRepository;@AutowiredShopRepository shopRepository;@AutowiredRetailerRegisteredAddressRepository retailerRegisteredAddressRepository;@AutowiredRetailerAddressRepository retailerAddressRepository;@AutowiredShopAddressRepository shopAddressRepository;@AutowiredRetailerBrandRepository retailerBrandRepository;@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",required = true, dataType = "string", paramType = "header")})@ApiOperation(value = "Create Retailer")@RequestMapping(value = ProfitMandiConstants.URL_RETAILER, method=RequestMethod.POST)public ResponseEntity<?> createRetailer(HttpServletRequest request, @RequestBody CreateRetailerRequest createRetailerRequest){LOGGER.info("requested url : "+request.getRequestURL().toString());Retailer retailer = new Retailer();retailer.setName(createRetailerRequest.getName());retailer.setNumber(createRetailerRequest.getNumber());retailer.setType(createRetailerRequest.getType());retailer.setMonthlySaleValue(createRetailerRequest.getMonthlySaleValue());retailer.setSmartphoneSaleValue(createRetailerRequest.getSmartphoneSaleValue());retailer.setRecharge(createRetailerRequest.getLineOfBusiness().isRecharge());retailer.setMobile(createRetailerRequest.getLineOfBusiness().isMobile());retailer.setAccessories(createRetailerRequest.getLineOfBusiness().isAccessories());retailer.setOther1(createRetailerRequest.getLineOfBusiness().isOther1());retailer.setOther2(createRetailerRequest.getLineOfBusiness().isOther2());Set<String> brandNames = createRetailerRequest.getBrandNames();try {Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){LOGGER.error("documet is already mapped with another retailer");throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "");}retailer.setDocumentId(retailerDocument.getId());retailerRepository.persist(retailer);final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());if(shopRepository.isExistByDocumentId(shopDocument.getId())){throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "");}Shop shop = new Shop();shop.setName(createRetailerRequest.getShop().getName());shop.setDocumentId(shopDocument.getId());shop.setRetailerId(retailer.getId());try{shopRepository.persist(shop);}catch(ProfitMandiBusinessException profitMandiBusinessException){}for(String brandName : brandNames){Brand brand =new Brand();brand.setName(brandName);if(!brandRepository.isExistByName(brandName)){brandRepository.persist(brand);}final RetailerBrand retailerBrand = new RetailerBrand();retailerBrand.setRetailerId(retailer.getId());retailerBrand.setBrandId(brand.getId());retailerBrandRepository.persist(retailerBrand);}final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());if(!addressRepository.isExist(addressRetailer)){addressRepository.persist(addressRetailer);}final RetailerRegisteredAddress retailerRegisteredAddress = new RetailerRegisteredAddress();retailerRegisteredAddress.setRetailerId(retailer.getId());retailerRegisteredAddress.setAddressId(addressRetailer.getId());try{retailerRegisteredAddressRepository.persist(retailerRegisteredAddress);}catch (ProfitMandiBusinessException profitMandiBusinessException) {}final Address addressShop = this.createAddress(createRetailerRequest.getShop().getAddress());if(!addressRepository.isExist(addressShop)){addressRepository.persist(addressShop);ShopAddress shopAddress = new ShopAddress();shopAddress.setShopId(shop.getId());shopAddress.setAddressId(addressShop.getId());try{shopAddressRepository.persist(shopAddress);}catch(ProfitMandiBusinessException profitMandiBusinessException){}}ShopAddress shopAddress = new ShopAddress();shopAddress.setShopId(shop.getId());shopAddress.setAddressId(addressShop.getId());try{shopAddressRepository.persist(shopAddress);}catch(ProfitMandiBusinessException profitMandiBusinessException){}final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("RTLR_OK_1000"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ALL,method=RequestMethod.GET)public ResponseEntity<?> getAll(HttpServletRequest request){LOGGER.info("requested url : "+request.getRequestURL().toString());final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectAll());return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID, method=RequestMethod.GET)public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectById(id));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_NAME, method=RequestMethod.GET)public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectByName(name));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID,method=RequestMethod.DELETE)public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") long id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {retailerRepository.deleteById(id);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ADD, method=RequestMethod.POST)public ResponseEntity<?> addShop(HttpServletRequest request, @RequestBody com.spice.profitmandi.web.req.Shop createShop, @RequestParam(name = "retailerId") long retailerId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {Document document = documentRepository.selectById(createShop.getDocumentId());if(shopRepository.isExistByDocumentId(createShop.getDocumentId())){LOGGER.error("documet is already mapped with another shop");throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "");}retailerRepository.selectById(retailerId);Shop shop = new Shop();shop.setRetailerId(retailerId);Address address = this.createAddress(createShop.getAddress());addressRepository.persist(address);shop.setAddressId(address.getId());shop.setDocumentId(document.getId());shopRepository.persist(shop);ShopAddress shopAddress = new ShopAddress();shopAddress.setAddressId(address.getId());shopAddress.setShopId(shop.getId());shopAddressRepository.persist(shopAddress);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_REMOVE, method=RequestMethod.DELETE)public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") long shopId, @RequestParam(name = "retailerId") long retailerId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {retailerRepository.removeShop(shopId, retailerId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}private Address createAddress(com.spice.profitmandi.web.req.Address createAddress){Address address = new Address();address.setName(createAddress.getName());address.setLine1(createAddress.getLine1());address.setLine2(createAddress.getLine2());address.setLandmark(createAddress.getLandmark());address.setCity(createAddress.getCity());address.setState(createAddress.getState());address.setPinCode(createAddress.getPinCode());address.setCountry(createAddress.getCountry());address.setPhoneNumber(createAddress.getPhoneNumber());return address;}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ADD, method=RequestMethod.POST)public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CreateRetailerAddressRequest createRetailerAddress){LOGGER.info("requested url : "+request.getRequestURL().toString());try {retailerRepository.addAddress(this.createAddress(createRetailerAddress.getAddress()), createRetailerAddress.getRetailerId());final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_REMOVE, method=RequestMethod.DELETE)public ResponseEntity<?> removeAddress(HttpServletRequest request, @RequestParam(name = "addressId") long addressId, @RequestParam(name = "retailerId") long retailerId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {retailerRepository.removeAddress(addressId, retailerId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ADD, method=RequestMethod.POST)public ResponseEntity<?> addBrand(HttpServletRequest request, @RequestBody RetailerAddBrandRequest retailerAddBrandRequest){LOGGER.info("requested url : "+request.getRequestURL().toString());try {Retailer retailer = retailerRepository.selectById(retailerAddBrandRequest.getRetailerId());for(String brandName : retailerAddBrandRequest.getBrandNames()){Brand brand = null;try{brand = brandRepository.selectByName(brandName);}catch(ProfitMandiBusinessException profitMandiBusinessException){brand = new Brand();brand.setName(brandName);brandRepository.persist(brand);}RetailerBrand retailerBrand = new RetailerBrand();retailerBrand.setBrandId(brand.getId());retailerBrand.setRetailerId(retailer.getId());}//retailerRepository.addAddress(this.createAddress(createRetailerAddress.getAddress()), createRetailerAddress.getRetailerId());final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_REMOVE, method=RequestMethod.DELETE)public ResponseEntity<?> removeBrand(HttpServletRequest request, @RequestParam(name = "brandId") long brandId, @RequestParam(name = "retailerId") long retailerId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {brandRepository.selectById(brandId);retailerRepository.selectById(retailerId);retailerBrandRepository.deleteByRetailerId(retailerId, brandId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_DOCUMENT_DOCUMENT_ID, method=RequestMethod.GET)public ResponseEntity<?> getDocumentById(HttpServletRequest request, @RequestParam(name = "document") long documentId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {retailerRepository.selectByDocumentId(documentId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, documentRepository.selectById(documentId));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ALL, method=RequestMethod.GET)public ResponseEntity<?> getAllShops(HttpServletRequest request, @RequestParam(name = "id") long id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectByRetailerId(id));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ALL, method=RequestMethod.GET)public ResponseEntity<?> getAllAddresses(HttpServletRequest request, @RequestParam(name = "id") long id){LOGGER.info("requested url : "+request.getRequestURL().toString());final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerAddressRepository.selectAddressesByRetailerId(id));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ALL, method=RequestMethod.GET)public ResponseEntity<?> getAllBrads(HttpServletRequest request, @RequestParam(name = "id") long id){LOGGER.info("requested url : "+request.getRequestURL().toString());final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerBrandRepository.selectBrandNamesByRetailerId(id));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}}