TblRelationController.java
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.yoho.search.consumer.restapi;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.flow.ProductIndexHeatValueUpdateFlow;
import com.yoho.search.consumer.job.ProductHeatValueJob;
import com.yoho.search.consumer.service.logic.tbl.TblBrandRelationLogicService;
import com.yoho.search.consumer.service.logic.tbl.TblSortRelationLogicService;
import com.yoho.search.consumer.suggests.common.RetryBusinessFlowExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
/**
* Created by wangnan on 2017/3/7.
*/
@Controller
public class TblRelationController {
private static final Logger logger = LoggerFactory.getLogger(ProductHeatValueJob.class);
@Autowired
private TblSortRelationLogicService tblSortRelationLogicService;
@Autowired
private TblBrandRelationLogicService tblBrandRelationLogicService;
private ProductIndexHeatValueUpdateFlow productIndexHeatValueUpdateFlow;
@RequestMapping(value = "/doUpdateProductIndexHeatValue")
@ResponseBody
public Map<String, Object> doUpdateProductIndexHeatValue() {
Map<String, Object> rt = new HashMap<String, Object>();
try {
long begin = System.currentTimeMillis();
RetryBusinessFlowExecutor flowExecutor = new RetryBusinessFlowExecutor(productIndexHeatValueUpdateFlow, ISearchConstants.SEARCH_INDEX_BATCH_MAX_THREAD_SIZE, ISearchConstants.SEARCH_INDEX_BATCH_LIMIT);
boolean result = flowExecutor.execute();
logger.info("ProductHeatValueJob.doUpdateProductIndexHeatValue end----[result={}][cost={}]", result, System.currentTimeMillis() - begin);
rt.put("code", 200);
rt.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
rt.put("code", 400);
rt.put("message", e.getMessage());
}
return rt;
}
@RequestMapping(value = "/tblSortRelation")
@ResponseBody
public Map<String, Object> loadSortRelationData() {
Map<String, Object> result = new HashMap<String, Object>();
try {
tblSortRelationLogicService.loadSortRelationData();
result.put("code", 200);
result.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
result.put("code", 400);
result.put("message", e.getMessage());
}
return result;
}
@RequestMapping(value = "/tblBrandRelation")
@ResponseBody
public Map<String, Object> loadBrandRelationData() {
Map<String, Object> result = new HashMap<String, Object>();
try {
tblBrandRelationLogicService.loadBrandRelationData();
result.put("data", "");
result.put("code", 200);
result.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
result.put("code", 400);
result.put("message", e.getMessage());
}
return result;
}
}