| Line 16... |
Line 16... |
| 16 |
import org.springframework.beans.factory.annotation.Autowired;
|
16 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 17 |
import org.springframework.http.HttpStatus;
|
17 |
import org.springframework.http.HttpStatus;
|
| 18 |
import org.springframework.http.MediaType;
|
18 |
import org.springframework.http.MediaType;
|
| 19 |
import org.springframework.http.ResponseEntity;
|
19 |
import org.springframework.http.ResponseEntity;
|
| 20 |
import org.springframework.stereotype.Controller;
|
20 |
import org.springframework.stereotype.Controller;
|
| - |
|
21 |
import org.springframework.web.bind.annotation.PathVariable;
|
| 21 |
import org.springframework.web.bind.annotation.RequestBody;
|
22 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 22 |
import org.springframework.web.bind.annotation.RequestMapping;
|
23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMethod;
|
24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
25 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 24 |
|
26 |
|
| 25 |
import com.google.gson.Gson;
|
27 |
import com.google.gson.Gson;
|
| 26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 27 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
29 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 28 |
import com.spice.profitmandi.common.services.ContentPojoPopulator;
|
30 |
import com.spice.profitmandi.common.services.ContentPojoPopulator;
|
| Line 41... |
Line 43... |
| 41 |
import com.spice.profitmandi.web.res.CartResponse;
|
43 |
import com.spice.profitmandi.web.res.CartResponse;
|
| 42 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
44 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
| 43 |
|
45 |
|
| 44 |
import in.shop2020.logistics.DeliveryType;
|
46 |
import in.shop2020.logistics.DeliveryType;
|
| 45 |
import in.shop2020.model.v1.user.ItemQuantity;
|
47 |
import in.shop2020.model.v1.user.ItemQuantity;
|
| - |
|
48 |
import in.shop2020.model.v1.user.UserContextService;
|
| 46 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
49 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 47 |
import io.swagger.annotations.ApiImplicitParam;
|
50 |
import io.swagger.annotations.ApiImplicitParam;
|
| 48 |
import io.swagger.annotations.ApiImplicitParams;
|
51 |
import io.swagger.annotations.ApiImplicitParams;
|
| 49 |
import io.swagger.annotations.ApiOperation;
|
52 |
import io.swagger.annotations.ApiOperation;
|
| 50 |
|
53 |
|
| Line 213... |
Line 216... |
| 213 |
cartObj.put("estimateString", LogisticsService.getDeliveryDateString(maxEstimate,DeliveryType.COD));
|
216 |
cartObj.put("estimateString", LogisticsService.getDeliveryDateString(maxEstimate,DeliveryType.COD));
|
| 214 |
} catch (NumberFormatException | JSONException | TException e) {
|
217 |
} catch (NumberFormatException | JSONException | TException e) {
|
| 215 |
// TODO Auto-generated catch block
|
218 |
// TODO Auto-generated catch block
|
| 216 |
e.printStackTrace();
|
219 |
e.printStackTrace();
|
| 217 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while getting delivery estimates");
|
220 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while getting delivery estimates");
|
| 218 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
221 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() ,
|
| - |
|
222 |
HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
| 219 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
223 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 220 |
}
|
224 |
}
|
| 221 |
|
225 |
|
| 222 |
}
|
226 |
}
|
| 223 |
cartObj.put("maxEstimate", maxEstimate);
|
227 |
cartObj.put("maxEstimate", maxEstimate);
|
| 224 |
CartResponse cartResponse = new Gson().fromJson(cartObj.toString(), CartResponse.class);
|
228 |
CartResponse cartResponse = new Gson().fromJson(cartObj.toString(), CartResponse.class);
|
| 225 |
vc = new ValidateCartResponse(cartResponse, "Success","Items added to cart successfully");
|
229 |
vc = new ValidateCartResponse(cartResponse, "Success","Items added to cart successfully");
|
| 226 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, vc);
|
230 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, vc);
|
| 227 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
231 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 228 |
}
|
232 |
}
|
| - |
|
233 |
|
| - |
|
234 |
@RequestMapping(value = ProfitMandiConstants.URL_CART, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
235 |
@ApiImplicitParams({
|
| - |
|
236 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
237 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
238 |
})
|
| - |
|
239 |
|
| - |
|
240 |
@ApiOperation(value = "Change address")
|
| - |
|
241 |
public ResponseEntity<?> changeAddress(HttpServletRequest request,@PathVariable(value="cartId") long cartId, @RequestParam(value="addressId") long addressId){
|
| - |
|
242 |
ProfitMandiResponse<?> profitMandiResponse;
|
| - |
|
243 |
try {
|
| - |
|
244 |
UserContextService.Client userClient = new UserClient().getClient();
|
| - |
|
245 |
userClient.addAddressToCart(cartId, addressId);
|
| - |
|
246 |
profitMandiResponse = new ProfitMandiResponse<>(request.getRequestURL().toString(), "Address changed successfully");
|
| - |
|
247 |
} catch(Exception e) {
|
| - |
|
248 |
profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, "Could not changed the address");
|
| - |
|
249 |
logger.error("Unable to change address", e);
|
| - |
|
250 |
}
|
| - |
|
251 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
252 |
}
|
| 229 |
}
|
253 |
}
|
| 230 |
|
254 |
|