| 536 |
rajveer |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.serving.controllers;
|
|
|
5 |
|
|
|
6 |
import java.io.File;
|
|
|
7 |
import java.util.HashMap;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
import java.util.Map;
|
|
|
10 |
import java.util.StringTokenizer;
|
|
|
11 |
|
|
|
12 |
import in.shop2020.logistics.LogisticsService.Client;
|
|
|
13 |
import in.shop2020.serving.utils.FileUtils;
|
|
|
14 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
|
|
15 |
import in.shop2020.thrift.clients.LogisticsServiceClient;
|
|
|
16 |
import in.shop2020.util.Utils;
|
|
|
17 |
|
|
|
18 |
import org.apache.juli.logging.Log;
|
|
|
19 |
import org.apache.juli.logging.LogFactory;
|
|
|
20 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
|
|
21 |
import org.apache.struts2.rest.HttpHeaders;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* @author rajveer
|
|
|
25 |
*
|
|
|
26 |
*/
|
|
|
27 |
public class BestSellersController extends BaseController {
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
*
|
|
|
31 |
*/
|
|
|
32 |
private static Log log = LogFactory.getLog(BestSellersController.class);
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
private Map<String, String> snippets;
|
|
|
36 |
|
|
|
37 |
public BestSellersController() {
|
|
|
38 |
super();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
// GET /logout
|
|
|
42 |
public HttpHeaders index() throws Exception {
|
|
|
43 |
return new DefaultHttpHeaders("index");
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public Map<String, String> getSnippets() throws Exception {
|
|
|
47 |
CatalogServiceClient catalogClientService = new CatalogServiceClient();
|
|
|
48 |
in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
|
|
|
49 |
List<Long> items = client.getBestSellers();
|
|
|
50 |
|
|
|
51 |
snippets = new HashMap<String, String>();
|
|
|
52 |
for(Long item: items){
|
|
|
53 |
snippets.put(item.toString(), FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.toString() + File.separator +"CategorySnippet.html"));
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
return snippets;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
}
|