Subversion Repositories SmartDukaan

Rev

Rev 1175 | Rev 1625 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1175 Rev 1623
Line 2... Line 2...
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
6
import in.shop2020.model.v1.user.User;
6
import in.shop2020.model.v1.user.User;
-
 
7
import in.shop2020.model.v1.user.Widget;
-
 
8
import in.shop2020.model.v1.user.WidgetItem;
7
import in.shop2020.serving.utils.DesEncrypter;
9
import in.shop2020.serving.utils.DesEncrypter;
8
import in.shop2020.serving.utils.UserMessage;
10
import in.shop2020.serving.utils.UserMessage;
9
import in.shop2020.thrift.clients.UserContextServiceClient;
11
import in.shop2020.thrift.clients.UserContextServiceClient;
10
 
12
 
11
import java.io.IOException;
13
import java.io.IOException;
12
import java.util.Date;
14
import java.util.Date;
-
 
15
import java.util.List;
13
 
16
 
14
import org.apache.log4j.Logger;
17
import org.apache.log4j.Logger;
15
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Result;
16
import org.apache.struts2.convention.annotation.Results;
19
import org.apache.struts2.convention.annotation.Results;
17
 
20
 
Line 87... Line 90...
87
			// TODO: setTotalItems shouldn't be a method on userinfo. This allows
90
			// TODO: setTotalItems shouldn't be a method on userinfo. This allows
88
			// for potentially updating the item count wrongly. The method setCartId
91
			// for potentially updating the item count wrongly. The method setCartId
89
			// should update the item count as well. Also, there can be a method
92
			// should update the item count as well. Also, there can be a method
90
			// called refreshItemCount() that automatically updates the number of
93
			// called refreshItemCount() that automatically updates the number of
91
			// items currently in the cart.
94
			// items currently in the cart.
-
 
95
			if(userinfo.getCartId() != -1){
92
			userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
96
				userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
-
 
97
				Widget browseHistory = userClient.getBrowseHistory(userinfo.getCartId());
-
 
98
				if(browseHistory != null){
-
 
99
					List<WidgetItem> items =  browseHistory.getItems();
-
 
100
					if(items != null){
-
 
101
						for(WidgetItem item: items){
-
 
102
							userClient.updateBrowseHistory(user.getUserId(), item.getItem_id());
-
 
103
						}
-
 
104
					}
-
 
105
				}
-
 
106
			}
-
 
107
			
-
 
108
			
93
			userinfo.setCartId(user.getActiveCartId());
109
			userinfo.setCartId(user.getActiveCartId());
94
			int totalItems = userClient.getCart(user.getActiveCartId())
110
			int totalItems = userClient.getCart(user.getActiveCartId())
95
					.getLinesSize();
111
					.getLinesSize();
96
			userinfo.setTotalItems(totalItems);
112
			userinfo.setTotalItems(totalItems);
97
 
-
 
-
 
113
			System.out.println(userinfo);
98
			return true;
114
			return true;
99
		} catch (Exception e) {
115
		} catch (Exception e) {
100
			log.error(UserMessage.USER_AUTHENTICATION_FAILURE);
116
			log.error(UserMessage.USER_AUTHENTICATION_FAILURE);
101
			return false;
117
			return false;
102
		}
118
		}