| 1597 |
ankur.sing |
1 |
package in.shop2020.support.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.user.UserType;
|
|
|
4 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
|
|
5 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
6 |
|
|
|
7 |
import javax.servlet.http.HttpServletRequest;
|
|
|
8 |
import javax.servlet.http.HttpServletResponse;
|
|
|
9 |
|
|
|
10 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
11 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
|
|
12 |
|
|
|
13 |
public class StatisticsController implements ServletResponseAware, ServletRequestAware{
|
|
|
14 |
|
|
|
15 |
private HttpServletRequest request;
|
|
|
16 |
private HttpServletResponse response;
|
|
|
17 |
|
|
|
18 |
private String errorMsg = "";
|
|
|
19 |
private long noOfRegisterUsers;
|
|
|
20 |
private long noOfOrders;
|
|
|
21 |
public StatisticsController(){
|
|
|
22 |
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
@Override
|
|
|
26 |
public void setServletRequest(HttpServletRequest req) {
|
|
|
27 |
this.request = req;
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
@Override
|
|
|
31 |
public void setServletResponse(HttpServletResponse res) {
|
|
|
32 |
this.response = res;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public String index() {
|
|
|
36 |
UserContextServiceClient usc;
|
|
|
37 |
TransactionServiceClient tsc;
|
|
|
38 |
try {
|
|
|
39 |
usc = new UserContextServiceClient();
|
|
|
40 |
in.shop2020.model.v1.user.UserContextService.Client uclient = usc.getClient();
|
|
|
41 |
noOfRegisterUsers = uclient.getUserCount(UserType.USER);
|
|
|
42 |
|
|
|
43 |
tsc = new TransactionServiceClient();
|
|
|
44 |
in.shop2020.model.v1.order.TransactionService.Client tClient = tsc.getClient();
|
|
|
45 |
noOfOrders = tClient.getValidOrderCount();
|
|
|
46 |
} catch (Exception e) {
|
|
|
47 |
e.printStackTrace();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
return "index";
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public String show(){
|
|
|
54 |
return null;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
// Handles the POST request (Form Submission)
|
|
|
58 |
|
|
|
59 |
public String getErrorMsg() {
|
|
|
60 |
return errorMsg;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public long getNoOfRegisterUsers() {
|
|
|
64 |
return noOfRegisterUsers;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public long getNoOfOrders() {
|
|
|
68 |
return noOfOrders;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public static void main(String[] args) {
|
|
|
72 |
StatisticsController sc = new StatisticsController();
|
|
|
73 |
sc.index();
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|