Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
545 rajveer 1
package in.shop2020.serving.services;
2
 
3
import in.shop2020.serving.utils.Utils;
4
 
5
import java.util.Date;
6
 
7
public class UserSessionInfo {
8
	private boolean isLoggedIn;
9
	private long userId;
10
	private long sessionId;
11
	private String email;
12
	private String nameOfUser;
13
	private int totalItems;
14
	private long cartId;
15
 
16
	public UserSessionInfo(){
17
		this.isLoggedIn = false;
18
		this.userId = -1;
19
		this.sessionId = (new Date()).getTime();
20
		this.email = "";
21
		this.nameOfUser = "";
22
		this.totalItems = 0;
23
		this.cartId = -1;
24
	}
25
 
26
	public UserSessionInfo(long userId, boolean isSessionId){
27
		if(!isSessionId){
28
			this.isLoggedIn = true;
29
			this.userId = userId;
30
			this.sessionId = (new Date()).getTime();
31
			this.email = Utils.getEmailId(userId);
32
			this.nameOfUser = Utils.getNameOfUser(userId);
33
			//this.totalItems = 0;
34
			//this.cartId = -1;
35
			this.cartId = Utils.getCartId(userId);
36
			this.totalItems = Utils.getNumberOfItemsInCart(this.cartId);
37
 
38
		}
39
		else{
40
			this.isLoggedIn = false;
41
			this.userId = -1;
42
			this.sessionId = userId;
43
			this.email = "";
44
			this.nameOfUser = "";
45
			this.totalItems = 0;
46
			this.cartId = -1;
47
		}
48
	}
49
 
50
	public boolean isSessionId() {
51
		return !isLoggedIn;
52
	}
53
 
54
	public boolean isLoggedIn() {
55
		return isLoggedIn;
56
	}
57
 
58
	public void setLoggedIn(boolean isLoggedIn) {
59
		this.isLoggedIn = isLoggedIn;
60
	}
61
 
62
	public long getUserId() {
63
		return userId;
64
	}
65
 
66
	public void setUserId(long userId) {
67
		this.userId = userId;
68
	}
69
 
70
	public long getSessionId() {
71
		return sessionId;
72
	}
73
 
74
	public void setSessionId(long sessionId) {
75
		this.sessionId = sessionId;
76
	}
77
 
78
	public String getEmail() {
79
		return email;
80
	}
81
 
82
	public void setEmail(String email) {
83
		this.email = email;
84
	}
85
 
86
	public String getNameOfUser() {
87
		return nameOfUser;
88
	}
89
 
90
	public void setNameOfUser(String nameOfUser) {
91
		this.nameOfUser = nameOfUser;
92
	}
93
 
94
	public int getTotalItems() {
95
		return totalItems;
96
	}
97
 
98
	public void setTotalItems(int totalItems) {
99
		this.totalItems = totalItems;
100
	}
101
	public long getCartId() {
102
		return cartId;
103
	}
104
 
105
	public void setCartId(long cartId) {
106
		this.cartId = cartId;
107
	}	
108
 
109
}