Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
507 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.AddressType;
8
import in.shop2020.model.v1.user.UserContext;
9
import in.shop2020.model.v1.user.UserPrimaryInfo;
10
import in.shop2020.model.v1.user.UserState;
11
import in.shop2020.serving.pages.PageContentKeys;
12
import in.shop2020.serving.pages.PageEnum;
13
import in.shop2020.serving.pages.PageManager;
14
import in.shop2020.serving.utils.Utils;
15
import in.shop2020.thrift.clients.UserContextServiceClient;
16
 
17
import java.io.UnsupportedEncodingException;
18
import java.util.Date;
19
import java.util.HashMap;
20
import java.util.Map;
21
 
22
import org.apache.juli.logging.Log;
23
import org.apache.juli.logging.LogFactory;
24
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.struts2.interceptor.ParameterAware;
27
import org.apache.struts2.rest.DefaultHttpHeaders;
28
import org.apache.struts2.rest.HttpHeaders;
29
 
30
/**
31
 * @author rajveer
32
 *
33
 */
34
 
517 rajveer 35
public class PersonalDetailsController extends BaseController 
507 rajveer 36
	implements ParameterAware {
37
 
38
 
39
	/**
40
	 * 
41
	 */
517 rajveer 42
	private static Log log = LogFactory.getLog(PersonalDetailsController.class);
507 rajveer 43
 
44
	private Map<String,String> htmlSnippets;
45
	/**
46
	 * 
47
	 */
48
 
49
 
50
	private Map<String, String[]> reqparams;
51
 
52
	private String id;
53
 
54
	private int action;
55
 
56
 
517 rajveer 57
	public PersonalDetailsController() {
507 rajveer 58
		super();
59
	}
60
 
61
    // POST /logindetails
62
    public String create() {
63
    	log.info("PersonaldetailsController.create");
64
 
65
 
66
		String name = this.request.getParameter("txtName");
67
		int month = Integer.parseInt(this.request.getParameter("month"));
68
		int day = Integer.parseInt(this.request.getParameter("day"));
69
		int year = Integer.parseInt(this.request.getParameter("year"));
70
		String sex = this.request.getParameter("sex");
71
		String communicationEmail = this.request.getParameter("txtCommEmail");
72
		String subscribeNewsletter = this.request.getParameter("subscribe");
73
 
74
		if(this.userinfo.isLoggedIn()){
75
			if(Utils.UpdatePersonalDetails(userinfo.getUserId(), name, month,day,year,sex,communicationEmail,subscribeNewsletter))
76
			{
77
				return "success";
78
			}
79
    	}
80
		return "failure";
81
    }
82
 
83
 
84
    // GET /test
85
    public HttpHeaders index() throws UnsupportedEncodingException {
86
    	log.info("this.request=" + this.request);
87
 
88
    	String userId = "";
89
 
90
    	if(this.userinfo.isLoggedIn()){
91
    		userId = (new Long(this.userinfo.getUserId())).toString();
92
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
93
			params.put(PageContentKeys.CUSTOMER_ID, userId);
94
			params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
95
 
96
			htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.PERSONAL_DETAILS_PAGE, params);
97
			return new DefaultHttpHeaders("index").disableCaching();
98
 
99
    	}else{
100
    		return new DefaultHttpHeaders("login").disableCaching();
101
    	}
102
 
103
    }
104
 
105
    public String getHeaderSnippet(){
106
		return htmlSnippets.get("HEADER");
107
	}
108
 
109
	public String getMainMenuSnippet(){
110
		return htmlSnippets.get("MAIN_MENU");
111
	}
112
 
113
	public String getSearchBarSnippet(){
114
		return htmlSnippets.get("SEARCH_BAR");
115
	}
116
 
117
 
118
	public String getCustomerServiceSnippet(){
119
		return htmlSnippets.get("CUSTOMER_SERVICE");
120
	}
121
 
122
	public String getMyaccountHeaderSnippet(){
123
		return htmlSnippets.get("MYACCOUNT_HEADER");
124
	}
125
 
126
	public String getPersonalDetailsSnippet(){
127
		return htmlSnippets.get("PERSONAL_DETAILS");
128
	}
129
 
130
	public String getMyResearchSnippet(){
131
		return htmlSnippets.get("MY_RESEARCH");
132
	}
133
 
134
	public String getFooterSnippet(){
135
		return htmlSnippets.get("FOOTER");
136
	}
137
 
138
	public String getJsFileSnippet(){
139
		return htmlSnippets.get("JS_FILES");
140
	}
141
 
142
	public String getCssFileSnippet(){
143
		return htmlSnippets.get("CSS_FILES");
144
	}
145
 
146
    /**
147
     * 
148
     * @param id
149
     */
150
    public void setId(String id) {
151
        this.id = id;
152
    }
153
 
154
 
155
    /**
156
     * 
157
     */
158
//    @Override
159
//	public void setServletRequest(HttpServletRequest request) {
160
//		this.request = request;
161
//	}
162
 
163
 
164
	@Override
165
	public void setParameters(Map<String, String[]> reqmap) {
166
		log.info("setParameters:" + reqmap);
167
 
168
		this.reqparams = reqmap;
169
	}
170
 
171
}