| 2830 |
vikas |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.user.UserCommunication;
|
| 3128 |
rajveer |
4 |
import in.shop2020.thrift.clients.UserClient;
|
| 2830 |
vikas |
5 |
|
|
|
6 |
import java.text.SimpleDateFormat;
|
|
|
7 |
import java.util.ArrayList;
|
|
|
8 |
import java.util.Date;
|
|
|
9 |
import java.util.HashMap;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
import java.util.Map;
|
|
|
12 |
import java.util.TimeZone;
|
|
|
13 |
|
|
|
14 |
import org.apache.log4j.Logger;
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* @author vikas
|
|
|
18 |
*
|
|
|
19 |
*/
|
|
|
20 |
@SuppressWarnings("serial")
|
|
|
21 |
public class UserCommunicationsController extends BaseController {
|
|
|
22 |
private static Logger log = Logger.getLogger(Class.class);
|
|
|
23 |
private long userId;
|
|
|
24 |
private List<Map<String, String>> userCommunications;
|
|
|
25 |
|
|
|
26 |
public UserCommunicationsController(){
|
|
|
27 |
super();
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
public String index() throws Exception {
|
| 3128 |
rajveer |
31 |
UserClient userServiceClient = new UserClient();
|
|
|
32 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
|
| 2830 |
vikas |
33 |
|
|
|
34 |
List<UserCommunication> communications = userClient.getUserCommunicationByUser(userId);
|
|
|
35 |
|
|
|
36 |
userCommunications = new ArrayList<Map<String,String>>();
|
|
|
37 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
38 |
sdf.setTimeZone(TimeZone.getTimeZone("IST"));
|
|
|
39 |
|
|
|
40 |
for (UserCommunication comm : communications) {
|
|
|
41 |
Map<String, String> commMap = new HashMap<String, String>();
|
|
|
42 |
commMap.put("id", Long.toString(comm.getId()));
|
|
|
43 |
commMap.put("commtype", comm.getCommunicationType().name());
|
|
|
44 |
commMap.put("subject", comm.getSubject());
|
|
|
45 |
commMap.put("time", sdf.format(new Date(comm.getCommunication_timestamp())));
|
|
|
46 |
userCommunications.add(commMap);
|
|
|
47 |
}
|
|
|
48 |
return "index";
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public void setUserId(String userId) {
|
|
|
52 |
try {
|
|
|
53 |
this.userId = Long.parseLong(userId);
|
|
|
54 |
}
|
|
|
55 |
catch (NumberFormatException e) {
|
|
|
56 |
log.error(e);
|
|
|
57 |
}
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public Long getUserId() {
|
|
|
61 |
return userId;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
public List<Map<String, String>> getUserCommunications() {
|
|
|
65 |
return userCommunications;
|
|
|
66 |
}
|
|
|
67 |
}
|