| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.Map;
|
- |
|
| 5 |
import java.util.Set;
|
4 |
import java.util.Set;
|
| 6 |
|
5 |
|
| 7 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 8 |
|
7 |
|
| 9 |
import org.slf4j.Logger;
|
8 |
import org.slf4j.Logger;
|
| Line 26... |
Line 25... |
| 26 |
import com.spice.profitmandi.dao.entity.Retailer;
|
25 |
import com.spice.profitmandi.dao.entity.Retailer;
|
| 27 |
import com.spice.profitmandi.dao.entity.RetailerBrand;
|
26 |
import com.spice.profitmandi.dao.entity.RetailerBrand;
|
| 28 |
import com.spice.profitmandi.dao.entity.RetailerRegisteredAddress;
|
27 |
import com.spice.profitmandi.dao.entity.RetailerRegisteredAddress;
|
| 29 |
import com.spice.profitmandi.dao.entity.Shop;
|
28 |
import com.spice.profitmandi.dao.entity.Shop;
|
| 30 |
import com.spice.profitmandi.dao.entity.ShopAddress;
|
29 |
import com.spice.profitmandi.dao.entity.ShopAddress;
|
| 31 |
import com.spice.profitmandi.dao.enumuration.RetailerType;
|
- |
|
| 32 |
import com.spice.profitmandi.dao.enumuration.SaleValue;
|
- |
|
| 33 |
import com.spice.profitmandi.dao.repository.AddressRepository;
|
30 |
import com.spice.profitmandi.dao.repository.AddressRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.BrandRepository;
|
31 |
import com.spice.profitmandi.dao.repository.BrandRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.DocumentRepository;
|
32 |
import com.spice.profitmandi.dao.repository.DocumentRepository;
|
| - |
|
33 |
import com.spice.profitmandi.dao.repository.RetailerAddressRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.RetailerBrandRepository;
|
34 |
import com.spice.profitmandi.dao.repository.RetailerBrandRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.RetailerRegisteredAddressRepository;
|
35 |
import com.spice.profitmandi.dao.repository.RetailerRegisteredAddressRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
36 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.ShopAddressRepository;
|
37 |
import com.spice.profitmandi.dao.repository.ShopAddressRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.ShopRepository;
|
38 |
import com.spice.profitmandi.dao.repository.ShopRepository;
|
| 41 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
39 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 42 |
import com.spice.profitmandi.web.model.Response;
|
40 |
import com.spice.profitmandi.web.model.Response;
|
| 43 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
41 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| - |
|
42 |
import com.spice.profitmandi.web.req.CreateRetailerAddressRequest;
|
| 44 |
import com.spice.profitmandi.web.req.CreateRetailerRequestModel;
|
43 |
import com.spice.profitmandi.web.req.CreateRetailerRequest;
|
| - |
|
44 |
import com.spice.profitmandi.web.req.RetailerAddBrandRequest;
|
| 45 |
|
45 |
|
| 46 |
import io.swagger.annotations.ApiImplicitParam;
|
46 |
import io.swagger.annotations.ApiImplicitParam;
|
| 47 |
import io.swagger.annotations.ApiImplicitParams;
|
47 |
import io.swagger.annotations.ApiImplicitParams;
|
| 48 |
import io.swagger.annotations.ApiOperation;
|
48 |
import io.swagger.annotations.ApiOperation;
|
| 49 |
|
49 |
|
| Line 69... |
Line 69... |
| 69 |
|
69 |
|
| 70 |
@Autowired
|
70 |
@Autowired
|
| 71 |
RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
71 |
RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
| 72 |
|
72 |
|
| 73 |
@Autowired
|
73 |
@Autowired
|
| - |
|
74 |
RetailerAddressRepository retailerAddressRepository;
|
| - |
|
75 |
|
| - |
|
76 |
@Autowired
|
| 74 |
ShopAddressRepository shopAddressRepository;
|
77 |
ShopAddressRepository shopAddressRepository;
|
| 75 |
|
78 |
|
| 76 |
@Autowired
|
79 |
@Autowired
|
| 77 |
RetailerBrandRepository retailerBrandRepository;
|
80 |
RetailerBrandRepository retailerBrandRepository;
|
| 78 |
|
81 |
|
| 79 |
@SuppressWarnings("unchecked")
|
- |
|
| 80 |
@ApiImplicitParams({
|
82 |
@ApiImplicitParams({
|
| 81 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
83 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 82 |
required = true, dataType = "string", paramType = "header")
|
84 |
required = true, dataType = "string", paramType = "header")
|
| 83 |
})
|
85 |
})
|
| 84 |
|
86 |
|
| 85 |
@ApiOperation(value = "Create Retailer")
|
87 |
@ApiOperation(value = "Create Retailer")
|
| 86 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER, method=RequestMethod.POST)
|
88 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER, method=RequestMethod.POST)
|
| 87 |
public ResponseEntity<?> createRetailer(HttpServletRequest request, @RequestBody CreateRetailerRequestModel createRetailerRequestModel){
|
89 |
public ResponseEntity<?> createRetailer(HttpServletRequest request, @RequestBody CreateRetailerRequest createRetailerRequest){
|
| 88 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
90 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 89 |
final Map<String, Object> createRetailerMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.CREATE_RETAILER_MAP);
|
- |
|
| 90 |
request.removeAttribute(ProfitMandiConstants.CREATE_RETAILER_MAP);
|
- |
|
| 91 |
Retailer retailer = new Retailer();
|
91 |
Retailer retailer = new Retailer();
|
| 92 |
retailer.setName(createRetailerMap.get(ProfitMandiConstants.NAME).toString());
|
92 |
retailer.setName(createRetailerRequest.getName());
|
| 93 |
retailer.setNumber(createRetailerMap.get(ProfitMandiConstants.NUMBER).toString());
|
93 |
retailer.setNumber(createRetailerRequest.getNumber());
|
| 94 |
retailer.setType((RetailerType)createRetailerMap.get(ProfitMandiConstants.TYPE));
|
94 |
retailer.setType(createRetailerRequest.getType());
|
| 95 |
retailer.setMonthlySaleValue((SaleValue)createRetailerMap.get(ProfitMandiConstants.MONTLY_SALE_VALUE));
|
95 |
retailer.setMonthlySaleValue(createRetailerRequest.getMonthlySaleValue());
|
| 96 |
retailer.setSmartphoneSaleValue((SaleValue)createRetailerMap.get(ProfitMandiConstants.SMARTPHONE_SALE_VALUE));
|
96 |
retailer.setSmartphoneSaleValue(createRetailerRequest.getSmartphoneSaleValue());
|
| 97 |
retailer.setRecharge((boolean)createRetailerMap.get(ProfitMandiConstants.RECHARGE));
|
97 |
retailer.setRecharge(createRetailerRequest.getLineOfBusiness().isRecharge());
|
| 98 |
retailer.setMobile((boolean)createRetailerMap.get(ProfitMandiConstants.MOBILE));
|
98 |
retailer.setMobile(createRetailerRequest.getLineOfBusiness().isMobile());
|
| 99 |
retailer.setAccessories((boolean)createRetailerMap.get(ProfitMandiConstants.ACCESSORITES));
|
99 |
retailer.setAccessories(createRetailerRequest.getLineOfBusiness().isAccessories());
|
| 100 |
retailer.setOther1((boolean)createRetailerMap.get(ProfitMandiConstants.OTHER1));
|
100 |
retailer.setOther1(createRetailerRequest.getLineOfBusiness().isOther1());
|
| 101 |
retailer.setOther2((boolean)createRetailerMap.get(ProfitMandiConstants.OTHER2));
|
101 |
retailer.setOther2(createRetailerRequest.getLineOfBusiness().isOther2());
|
| 102 |
Set<String> brandNames = (Set<String>) createRetailerMap.get(ProfitMandiConstants.BRAND_NAMES);
|
102 |
Set<String> brandNames = createRetailerRequest.getBrandNames();
|
| 103 |
|
103 |
|
| 104 |
try {
|
104 |
try {
|
| 105 |
|
105 |
|
| 106 |
Document retailerDocument = documentRepository.selectById((int)createRetailerMap.get(ProfitMandiConstants.DOCUMENT_ID));
|
106 |
Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
|
| 107 |
if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
|
107 |
if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
|
| 108 |
LOGGER.error("documet is already mapped with another retailer");
|
108 |
LOGGER.error("documet is already mapped with another retailer");
|
| 109 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "");
|
109 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "");
|
| 110 |
}
|
110 |
}
|
| 111 |
retailer.setDocumentId(retailerDocument.getId());
|
111 |
retailer.setDocumentId(retailerDocument.getId());
|
| 112 |
retailerRepository.persist(retailer);
|
112 |
retailerRepository.persist(retailer);
|
| 113 |
Map<String, Object> createShopMap = (Map<String, Object>)createRetailerMap.get(ProfitMandiConstants.SHOP);
|
- |
|
| 114 |
final Document shopDocument = documentRepository.selectById((int)createShopMap.get(ProfitMandiConstants.DOCUMENT_ID));
|
113 |
final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
|
| 115 |
if(shopRepository.isExistByDocumentId(shopDocument.getId())){
|
114 |
if(shopRepository.isExistByDocumentId(shopDocument.getId())){
|
| 116 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "");
|
115 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "");
|
| 117 |
}
|
116 |
}
|
| 118 |
Shop shop = new Shop();
|
117 |
Shop shop = new Shop();
|
| 119 |
shop.setName(createShopMap.get(ProfitMandiConstants.NAME).toString());
|
118 |
shop.setName(createRetailerRequest.getShop().getName());
|
| 120 |
shop.setDocumentId(shopDocument.getId());
|
119 |
shop.setDocumentId(shopDocument.getId());
|
| 121 |
shop.setRetailerId(retailer.getId());
|
120 |
shop.setRetailerId(retailer.getId());
|
| 122 |
try{
|
121 |
try{
|
| 123 |
shopRepository.persist(shop);
|
122 |
shopRepository.persist(shop);
|
| 124 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
123 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| Line 133... |
Line 132... |
| 133 |
final RetailerBrand retailerBrand = new RetailerBrand();
|
132 |
final RetailerBrand retailerBrand = new RetailerBrand();
|
| 134 |
retailerBrand.setRetailerId(retailer.getId());
|
133 |
retailerBrand.setRetailerId(retailer.getId());
|
| 135 |
retailerBrand.setBrandId(brand.getId());
|
134 |
retailerBrand.setBrandId(brand.getId());
|
| 136 |
retailerBrandRepository.persist(retailerBrand);
|
135 |
retailerBrandRepository.persist(retailerBrand);
|
| 137 |
}
|
136 |
}
|
| 138 |
final Address addressRetailer = (Address)createRetailerMap.get(ProfitMandiConstants.ADDRESS);
|
137 |
final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
|
| - |
|
138 |
|
| 139 |
if(!addressRepository.isExist(addressRetailer)){
|
139 |
if(!addressRepository.isExist(addressRetailer)){
|
| 140 |
addressRepository.persist(addressRetailer);
|
140 |
addressRepository.persist(addressRetailer);
|
| 141 |
}
|
141 |
}
|
| 142 |
final RetailerRegisteredAddress retailerRegisteredAddress = new RetailerRegisteredAddress();
|
142 |
final RetailerRegisteredAddress retailerRegisteredAddress = new RetailerRegisteredAddress();
|
| 143 |
retailerRegisteredAddress.setRetailerId(retailer.getId());
|
143 |
retailerRegisteredAddress.setRetailerId(retailer.getId());
|
| Line 146... |
Line 146... |
| 146 |
retailerRegisteredAddressRepository.persist(retailerRegisteredAddress);
|
146 |
retailerRegisteredAddressRepository.persist(retailerRegisteredAddress);
|
| 147 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
147 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 148 |
|
148 |
|
| 149 |
}
|
149 |
}
|
| 150 |
|
150 |
|
| 151 |
final Address addressShop = (Address)createShopMap.get(ProfitMandiConstants.ADDRESS);
|
151 |
final Address addressShop = this.createAddress(createRetailerRequest.getShop().getAddress());
|
| 152 |
if(!addressRepository.isExist(addressShop)){
|
152 |
if(!addressRepository.isExist(addressShop)){
|
| 153 |
addressRepository.persist(addressShop);
|
153 |
addressRepository.persist(addressShop);
|
| 154 |
ShopAddress shopAddress = new ShopAddress();
|
154 |
ShopAddress shopAddress = new ShopAddress();
|
| 155 |
shopAddress.setShopId(shop.getId());
|
155 |
shopAddress.setShopId(shop.getId());
|
| 156 |
shopAddress.setAddressId(addressShop.getId());
|
156 |
shopAddress.setAddressId(addressShop.getId());
|
| Line 173... |
Line 173... |
| 173 |
}catch (ProfitMandiBusinessException pmbe) {
|
173 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 174 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
174 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 175 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
175 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 176 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
176 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 177 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
177 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 178 |
}catch (Exception e) {
|
- |
|
| 179 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 180 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 181 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 182 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 183 |
}
|
178 |
}
|
| 184 |
}
|
179 |
}
|
| 185 |
|
180 |
|
| 186 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ALL,method=RequestMethod.GET)
|
181 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ALL,method=RequestMethod.GET)
|
| 187 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
182 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
| 188 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
183 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 189 |
try {
|
- |
|
| 190 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectAll());
|
184 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectAll());
|
| 191 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
185 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 192 |
}catch (Exception e) {
|
- |
|
| 193 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 194 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 195 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 196 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 197 |
}
|
- |
|
| 198 |
}
|
186 |
}
|
| 199 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID, method=RequestMethod.GET)
|
187 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID, method=RequestMethod.GET)
|
| 200 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
188 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 201 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
189 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 202 |
try {
|
190 |
try {
|
| 203 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectById(id));
|
191 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerRepository.selectById(id));
|
| 204 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
192 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 205 |
}catch (ProfitMandiBusinessException pmbe) {
|
193 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 206 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
194 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 207 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
195 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 208 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
196 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 209 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
197 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 210 |
}catch (Exception e) {
|
- |
|
| 211 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 212 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 213 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 214 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 215 |
}
|
198 |
}
|
| 216 |
}
|
199 |
}
|
| 217 |
|
200 |
|
| 218 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_NAME, method=RequestMethod.GET)
|
201 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_NAME, method=RequestMethod.GET)
|
| 219 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
202 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
| Line 224... |
Line 207... |
| 224 |
}catch (ProfitMandiBusinessException pmbe) {
|
207 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 225 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
208 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 226 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
209 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 227 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
210 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 228 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
211 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 229 |
}catch (Exception e) {
|
- |
|
| 230 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 231 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 232 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 233 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 234 |
}
|
212 |
}
|
| 235 |
}
|
213 |
}
|
| 236 |
|
214 |
|
| 237 |
|
215 |
|
| 238 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID,method=RequestMethod.DELETE)
|
216 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ID,method=RequestMethod.DELETE)
|
| 239 |
public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
217 |
public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 240 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
218 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 241 |
try {
|
219 |
try {
|
| 242 |
retailerRepository.deleteById(id);
|
220 |
retailerRepository.deleteById(id);
|
| 243 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
221 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| 244 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
222 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 245 |
}catch (ProfitMandiBusinessException pmbe) {
|
223 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 246 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
224 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 247 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
225 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 248 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
226 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 249 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
227 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 250 |
}catch (Exception e) {
|
- |
|
| 251 |
LOGGER.error("Internal Server error : ",e);
|
- |
|
| 252 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 253 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 254 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 255 |
}
|
228 |
}
|
| 256 |
}
|
229 |
}
|
| 257 |
|
230 |
|
| - |
|
231 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ADD, method=RequestMethod.POST)
|
| - |
|
232 |
public ResponseEntity<?> addShop(HttpServletRequest request, @RequestBody com.spice.profitmandi.web.req.Shop createShop, @RequestParam(name = "retailerId") long retailerId){
|
| - |
|
233 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
234 |
try {
|
| - |
|
235 |
Document document = documentRepository.selectById(createShop.getDocumentId());
|
| - |
|
236 |
if(shopRepository.isExistByDocumentId(createShop.getDocumentId())){
|
| - |
|
237 |
LOGGER.error("documet is already mapped with another shop");
|
| - |
|
238 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "");
|
| - |
|
239 |
}
|
| - |
|
240 |
retailerRepository.selectById(retailerId);
|
| - |
|
241 |
Shop shop = new Shop();
|
| - |
|
242 |
shop.setRetailerId(retailerId);
|
| - |
|
243 |
Address address = this.createAddress(createShop.getAddress());
|
| - |
|
244 |
addressRepository.persist(address);
|
| - |
|
245 |
shop.setAddressId(address.getId());
|
| - |
|
246 |
shop.setDocumentId(document.getId());
|
| - |
|
247 |
shopRepository.persist(shop);
|
| - |
|
248 |
ShopAddress shopAddress = new ShopAddress();
|
| - |
|
249 |
shopAddress.setAddressId(address.getId());
|
| - |
|
250 |
shopAddress.setShopId(shop.getId());
|
| - |
|
251 |
shopAddressRepository.persist(shopAddress);
|
| - |
|
252 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| - |
|
253 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
254 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
255 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
256 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
257 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
258 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
259 |
}
|
| - |
|
260 |
}
|
| - |
|
261 |
|
| - |
|
262 |
|
| 258 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_REMOVE, method=RequestMethod.DELETE)
|
263 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_REMOVE, method=RequestMethod.DELETE)
|
| 259 |
public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") int shopId, @RequestParam(name = "retailerId") int retailerId){
|
264 |
public ResponseEntity<?> removeShop(HttpServletRequest request, @RequestParam(name = "shopId") long shopId, @RequestParam(name = "retailerId") long retailerId){
|
| 260 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
265 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 261 |
try {
|
266 |
try {
|
| 262 |
retailerRepository.removeShop(shopId, retailerId);
|
267 |
retailerRepository.removeShop(shopId, retailerId);
|
| 263 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
268 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| 264 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
269 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 265 |
}catch (ProfitMandiBusinessException pmbe) {
|
270 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 266 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
271 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 267 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
272 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 268 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
273 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 269 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
274 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 270 |
}catch (Exception e) {
|
- |
|
| 271 |
LOGGER.error("Internal Server error : ",e);
|
- |
|
| 272 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 273 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 274 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 275 |
}
|
275 |
}
|
| 276 |
}
|
276 |
}
|
| 277 |
|
277 |
|
| - |
|
278 |
private Address createAddress(com.spice.profitmandi.web.req.Address createAddress){
|
| - |
|
279 |
Address address = new Address();
|
| - |
|
280 |
address.setName(createAddress.getName());
|
| - |
|
281 |
address.setLine1(createAddress.getLine1());
|
| - |
|
282 |
address.setLine2(createAddress.getLine2());
|
| - |
|
283 |
address.setLandmark(createAddress.getLandmark());
|
| - |
|
284 |
address.setCity(createAddress.getCity());
|
| - |
|
285 |
address.setState(createAddress.getState());
|
| - |
|
286 |
address.setPinCode(createAddress.getPinCode());
|
| - |
|
287 |
address.setCountry(createAddress.getCountry());
|
| - |
|
288 |
address.setPhoneNumber(createAddress.getPhoneNumber());
|
| - |
|
289 |
return address;
|
| - |
|
290 |
}
|
| - |
|
291 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ADD, method=RequestMethod.POST)
|
| - |
|
292 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CreateRetailerAddressRequest createRetailerAddress){
|
| - |
|
293 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
294 |
try {
|
| - |
|
295 |
retailerRepository.addAddress(this.createAddress(createRetailerAddress.getAddress()), createRetailerAddress.getRetailerId());
|
| - |
|
296 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| - |
|
297 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
298 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
299 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
300 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
301 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
302 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
303 |
}
|
| - |
|
304 |
}
|
| - |
|
305 |
|
| - |
|
306 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_REMOVE, method=RequestMethod.DELETE)
|
| - |
|
307 |
public ResponseEntity<?> removeAddress(HttpServletRequest request, @RequestParam(name = "addressId") long addressId, @RequestParam(name = "retailerId") long retailerId){
|
| - |
|
308 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
309 |
try {
|
| - |
|
310 |
retailerRepository.removeAddress(addressId, retailerId);
|
| - |
|
311 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| - |
|
312 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
313 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
314 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
315 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
316 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
317 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
318 |
}
|
| - |
|
319 |
}
|
| - |
|
320 |
|
| - |
|
321 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ADD, method=RequestMethod.POST)
|
| - |
|
322 |
public ResponseEntity<?> addBrand(HttpServletRequest request, @RequestBody RetailerAddBrandRequest retailerAddBrandRequest){
|
| - |
|
323 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
324 |
try {
|
| - |
|
325 |
Retailer retailer = retailerRepository.selectById(retailerAddBrandRequest.getRetailerId());
|
| - |
|
326 |
for(String brandName : retailerAddBrandRequest.getBrandNames()){
|
| - |
|
327 |
Brand brand = null;
|
| - |
|
328 |
try{
|
| - |
|
329 |
brand = brandRepository.selectByName(brandName);
|
| - |
|
330 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
331 |
brand = new Brand();
|
| - |
|
332 |
brand.setName(brandName);
|
| - |
|
333 |
brandRepository.persist(brand);
|
| - |
|
334 |
}
|
| - |
|
335 |
RetailerBrand retailerBrand = new RetailerBrand();
|
| - |
|
336 |
retailerBrand.setBrandId(brand.getId());
|
| - |
|
337 |
retailerBrand.setRetailerId(retailer.getId());
|
| - |
|
338 |
}
|
| - |
|
339 |
//retailerRepository.addAddress(this.createAddress(createRetailerAddress.getAddress()), createRetailerAddress.getRetailerId());
|
| - |
|
340 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| - |
|
341 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
342 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
343 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
344 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
345 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
346 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
347 |
}
|
| - |
|
348 |
}
|
| - |
|
349 |
|
| - |
|
350 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_REMOVE, method=RequestMethod.DELETE)
|
| - |
|
351 |
public ResponseEntity<?> removeBrand(HttpServletRequest request, @RequestParam(name = "brandId") long brandId, @RequestParam(name = "retailerId") long retailerId){
|
| - |
|
352 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
353 |
try {
|
| - |
|
354 |
brandRepository.selectById(brandId);
|
| - |
|
355 |
retailerRepository.selectById(retailerId);
|
| - |
|
356 |
retailerBrandRepository.deleteByRetailerId(retailerId, brandId);
|
| - |
|
357 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
|
| - |
|
358 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
359 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
360 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
361 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
362 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
363 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
364 |
}
|
| - |
|
365 |
}
|
| - |
|
366 |
|
| - |
|
367 |
|
| - |
|
368 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_DOCUMENT_DOCUMENT_ID, method=RequestMethod.GET)
|
| - |
|
369 |
public ResponseEntity<?> getDocumentById(HttpServletRequest request, @RequestParam(name = "document") long documentId){
|
| - |
|
370 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
371 |
try {
|
| - |
|
372 |
retailerRepository.selectByDocumentId(documentId);
|
| - |
|
373 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, documentRepository.selectById(documentId));
|
| - |
|
374 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
375 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
376 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
377 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
378 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
379 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
380 |
}
|
| - |
|
381 |
}
|
| - |
|
382 |
|
| - |
|
383 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_SHOP_ALL, method=RequestMethod.GET)
|
| - |
|
384 |
public ResponseEntity<?> getAllShops(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| - |
|
385 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
386 |
try {
|
| - |
|
387 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectByRetailerId(id));
|
| - |
|
388 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
389 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
390 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
391 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
392 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
393 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
394 |
}
|
| - |
|
395 |
}
|
| 278 |
|
396 |
|
| - |
|
397 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ALL, method=RequestMethod.GET)
|
| - |
|
398 |
public ResponseEntity<?> getAllAddresses(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| - |
|
399 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
400 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerAddressRepository.selectAddressesByRetailerId(id));
|
| - |
|
401 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
402 |
}
|
| - |
|
403 |
|
| - |
|
404 |
|
| - |
|
405 |
@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ALL, method=RequestMethod.GET)
|
| - |
|
406 |
public ResponseEntity<?> getAllBrads(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| - |
|
407 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
408 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, retailerBrandRepository.selectBrandNamesByRetailerId(id));
|
| - |
|
409 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
410 |
}
|
| - |
|
411 |
|
| 279 |
}
|
412 |
}
|