| 2644 |
varun.gupt |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
|
|
5 |
import in.shop2020.model.v1.user.UserContextService;
|
|
|
6 |
import in.shop2020.model.v1.user.UserNote;
|
|
|
7 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
8 |
|
|
|
9 |
import org.apache.log4j.Logger;
|
|
|
10 |
import org.apache.struts2.convention.annotation.Action;
|
|
|
11 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
*
|
|
|
15 |
* @author Varun Gupta
|
|
|
16 |
*
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
@SuppressWarnings("serial")
|
|
|
20 |
public class MyNotesController extends BaseController {
|
|
|
21 |
|
|
|
22 |
private String id;
|
|
|
23 |
|
|
|
24 |
private static Logger logger = Logger.getLogger(Class.class);
|
|
|
25 |
|
|
|
26 |
private List<UserNote> notes;
|
|
|
27 |
|
|
|
28 |
public MyNotesController() {
|
|
|
29 |
super();
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
@Action(value="my-notes",interceptorRefs={@InterceptorRef("myDefault")})
|
|
|
33 |
public String show() {
|
|
|
34 |
try {
|
|
|
35 |
long entityId = Long.parseLong(this.id);
|
|
|
36 |
UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
|
|
|
37 |
this.notes = userClient.getUserNotes(userinfo.getUserId(), entityId);
|
|
|
38 |
} catch (NumberFormatException e) {
|
|
|
39 |
logger.error("Number Format Exception. String: " + this.id);
|
|
|
40 |
} catch (Exception e) {
|
|
|
41 |
logger.error("Exception: " + e.getMessage());
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
return "show";
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
// Handle /putnote/
|
|
|
48 |
@Action(value="save-note",interceptorRefs={@InterceptorRef("createuser"),@InterceptorRef("myDefault")})
|
|
|
49 |
public String create() {
|
|
|
50 |
|
|
|
51 |
try {
|
|
|
52 |
long entityId = Long.parseLong(request.getParameter("entity"));
|
|
|
53 |
long slideId = Long.parseLong(request.getParameter("slide"));
|
|
|
54 |
String note = request.getParameter("note");
|
|
|
55 |
|
|
|
56 |
UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
|
|
|
57 |
userClient.putUserNote(userinfo.getUserId(), entityId, slideId, note);
|
|
|
58 |
|
|
|
59 |
} catch (NumberFormatException e) {
|
|
|
60 |
logger.error("Number Format Exception: " + e.getMessage());
|
|
|
61 |
} catch (Exception e) {
|
|
|
62 |
logger.error("Exception: " + e.getMessage());
|
|
|
63 |
}
|
|
|
64 |
return "success";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public List<UserNote> getNotes() {
|
|
|
68 |
return this.notes;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public String getId() {
|
|
|
72 |
return this.id;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* @param id
|
|
|
77 |
*/
|
|
|
78 |
public void setId(String id) {
|
|
|
79 |
this.id = id;
|
|
|
80 |
}
|
|
|
81 |
}
|