| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.shoppingcart.Cart;
|
3 |
import in.shop2020.model.v1.user.Cart;
|
| 4 |
import in.shop2020.model.v1.shoppingcart.ShoppingCartException;
|
4 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 5 |
import in.shop2020.model.v1.user.Address;
|
5 |
import in.shop2020.model.v1.user.Address;
|
| 6 |
import in.shop2020.model.v1.user.AddressType;
|
6 |
import in.shop2020.model.v1.user.AddressType;
|
| 7 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
7 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 8 |
import in.shop2020.serving.controllers.BaseController;
|
8 |
import in.shop2020.serving.controllers.BaseController;
|
| 9 |
import in.shop2020.serving.pages.PageContentKeys;
|
9 |
import in.shop2020.serving.pages.PageContentKeys;
|
| 10 |
import in.shop2020.serving.pages.PageEnum;
|
10 |
import in.shop2020.serving.pages.PageEnum;
|
| 11 |
import in.shop2020.serving.pages.PageManager;
|
11 |
import in.shop2020.serving.pages.PageManager;
|
| 12 |
import in.shop2020.serving.utils.Utils;
|
12 |
import in.shop2020.serving.utils.Utils;
|
| 13 |
import in.shop2020.thrift.clients.ShoppingCartClient;
|
- |
|
| 14 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
13 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 15 |
|
14 |
|
| 16 |
import java.util.*;
|
15 |
import java.util.*;
|
| 17 |
|
16 |
|
| 18 |
import org.apache.juli.logging.Log;
|
17 |
import org.apache.juli.logging.Log;
|
| Line 38... |
Line 37... |
| 38 |
pageManager = PageManager.getPageManager();
|
37 |
pageManager = PageManager.getPageManager();
|
| 39 |
}
|
38 |
}
|
| 40 |
|
39 |
|
| 41 |
// GET /address
|
40 |
// GET /address
|
| 42 |
public HttpHeaders index() {
|
41 |
public HttpHeaders index() {
|
| 43 |
long userId = 0;
|
42 |
long userId = userinfo.getUserId();
|
| 44 |
boolean isSessionId = true;
|
43 |
boolean isLoggedIn = !userinfo.isLoggedIn();
|
| 45 |
Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
|
44 |
Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
|
| 46 |
|
- |
|
| 47 |
if(userinfo.isLoggedIn()){
|
- |
|
| 48 |
userId = userinfo.getUserId();
|
- |
|
| 49 |
isSessionId = false;
|
- |
|
| 50 |
}else {
|
- |
|
| 51 |
userId = userinfo.getSessionId();
|
- |
|
| 52 |
isSessionId = true;
|
- |
|
| 53 |
}
|
- |
|
| 54 |
|
- |
|
| 55 |
|
45 |
|
| 56 |
params.put(PageContentKeys.CUSTOMER_ID, userId+"");
|
46 |
params.put(PageContentKeys.CUSTOMER_ID, userId+"");
|
| 57 |
params.put(PageContentKeys.IS_SESSION_ID, isSessionId+"");
|
47 |
params.put(PageContentKeys.IS_LOGGED_IN, isLoggedIn+"");
|
| 58 |
params.put(PageContentKeys.CART_ID, userinfo.getCartId()+"");
|
48 |
params.put(PageContentKeys.CART_ID, userinfo.getCartId()+"");
|
| 59 |
params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
|
49 |
params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
|
| 60 |
|
50 |
|
| 61 |
htmlSnippets = pageManager.getPageContents(PageEnum.SHIPPING_ADDRESS_PAGE, params);
|
51 |
htmlSnippets = pageManager.getPageContents(PageEnum.SHIPPING_ADDRESS_PAGE, params);
|
| 62 |
|
52 |
|
| Line 87... |
Line 77... |
| 87 |
address.setPin(this.request.getParameter("pincode"));
|
77 |
address.setPin(this.request.getParameter("pincode"));
|
| 88 |
address.setPhone(this.request.getParameter("mobilenumber"));
|
78 |
address.setPhone(this.request.getParameter("mobilenumber"));
|
| 89 |
address.setCountry(this.request.getParameter("country"));
|
79 |
address.setCountry(this.request.getParameter("country"));
|
| 90 |
address.setEnabled(true);
|
80 |
address.setEnabled(true);
|
| 91 |
if(isDefault.equals("true")){
|
81 |
if(isDefault.equals("true")){
|
| 92 |
userClient.addAddressForUser(address, userinfo.getUserId(), (new Date()).getTime(), true);
|
82 |
userClient.addAddressForUser(userinfo.getUserId(), address, (new Date()).getTime(), true);
|
| 93 |
}else{
|
83 |
}else{
|
| 94 |
userClient.addAddressForUser(address, userinfo.getUserId(), (new Date()).getTime(), false);
|
84 |
userClient.addAddressForUser(userinfo.getUserId(), address, (new Date()).getTime(), false);
|
| 95 |
}
|
85 |
}
|
| 96 |
}
|
86 |
}
|
| 97 |
|
87 |
|
| 98 |
if(action.equals("delete")){
|
88 |
if(action.equals("delete")){
|
| 99 |
Long addressId = Long.parseLong(this.request.getParameter("addressid"));
|
89 |
Long addressId = Long.parseLong(this.request.getParameter("addressid"));
|