SearchNewController.java
3.04 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.yoho.search.restapi;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.aop.downgrade.PersionalRateLimit;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.service.IDiscountService;
import com.yoho.search.service.service.IProductCountService;
import com.yoho.search.service.service.IRecentService;
import com.yoho.search.service.service.SearchProductsServiceNew;
import com.yoho.search.service.service.impl.SearchSortGroupService;
@Controller
public class SearchNewController {
@Autowired
private SearchSortGroupService searchSortGroupService;
@Autowired
private IRecentService recentService;
@Autowired
private IDiscountService discountService;
@Autowired
private SearchProductsServiceNew searchProductsServiceNew;
@Autowired
private IProductCountService productCountService;
/**
* 搜索商品列表以及聚合结果的接口
*
* @param request
* @return
*/
@PersionalRateLimit(isOrderUseable = true)
@RequestMapping(method = RequestMethod.GET, value = "/search")
@ResponseBody
public SearchApiResult searchProductsNew(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return searchProductsServiceNew.searchProductsNew(paramMap);
}
/**
* 对分类进行分组查询
*
* @param request
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/sortgroup")
@ResponseBody
public SearchApiResult sortGroup(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return searchSortGroupService.sortGroup(paramMap);
}
/**
* 获取按上架日期聚合的结果
*
* @param request
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/recent")
@ResponseBody
public SearchApiResult recent(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return recentService.recent(paramMap);
}
/**
* 获取按折扣聚合的结果
*
* @param request
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/discount")
@ResponseBody
public SearchApiResult discount(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return discountService.discount(paramMap);
}
/**
* 根据关键字查询获取商品数量[目前好像没在调]
*
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/count")
@ResponseBody
public long countByQuery(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return productCountService.countByQuery(paramMap);
}
}