...
|
...
|
@@ -28,185 +28,185 @@ import com.yoho.search.vo.SizeSortReqBO; |
|
|
@RequestMapping("/")
|
|
|
public class SearchController {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SearchController.class);
|
|
|
private static Logger logger = LoggerFactory.getLogger(SearchController.class);
|
|
|
|
|
|
@Autowired
|
|
|
SearchService searchService;
|
|
|
SearchService searchService;
|
|
|
@Autowired
|
|
|
SearchSortSizeService searchSortSizeService;
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/search")
|
|
|
@ResponseBody
|
|
|
@ResponseBody
|
|
|
public Map searchNew(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.searchNew(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("searchNew", paramMap, e.getMessage());
|
|
|
return errorReturn("searchNew", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/discount")
|
|
|
@ResponseBody
|
|
|
public Map discount(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.discount(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("discount", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/recent")
|
|
|
@ResponseBody
|
|
|
public Map recent(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.recentShelveDay(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("recent", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/count")
|
|
|
@ResponseBody
|
|
|
public long searchCount(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
long count = searchService.searchCount(transParamType(paramMap));
|
|
|
return count;
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[※查询]失败:" + e.getMessage());
|
|
|
Map<String, Object> rtnMap = new HashMap<String, Object>();
|
|
|
rtnMap.put("code", 400);
|
|
|
rtnMap.put("status", "error");
|
|
|
rtnMap.put("errmsg", e.getMessage());
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/suggest")
|
|
|
@ResponseBody
|
|
|
public Map suggest(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.suggest(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("suggest", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/discount")
|
|
|
@ResponseBody
|
|
|
public Map discount(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.discount(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("discount", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/recent")
|
|
|
@ResponseBody
|
|
|
public Map recent(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.recentShelveDay(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("recent", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/count")
|
|
|
@ResponseBody
|
|
|
public long searchCount(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
long count = searchService.searchCount(transParamType(paramMap));
|
|
|
return count;
|
|
|
} catch (Exception e) {
|
|
|
logger.error("[※查询]失败:"+ e.getMessage());
|
|
|
Map<String, Object> rtnMap = new HashMap<String, Object>();
|
|
|
rtnMap.put("code", 400);
|
|
|
rtnMap.put("status", "error");
|
|
|
rtnMap.put("errmsg", e.getMessage());
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/suggest")
|
|
|
@ResponseBody
|
|
|
public Map suggest(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.suggest(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("suggest", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/sortgroup")
|
|
|
@ResponseBody
|
|
|
@ResponseBody
|
|
|
public Map sortGroup(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.sortGroup(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("sortGroup", paramMap, e.getMessage());
|
|
|
return errorReturn("sortGroup", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/brands")
|
|
|
@ResponseBody
|
|
|
@ResponseBody
|
|
|
public Map brands(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.brands(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("brands", paramMap, e.getMessage());
|
|
|
return errorReturn("brands", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/group_brands")
|
|
|
@ResponseBody
|
|
|
public Map groupBrands(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.groupBrands(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("groupBrands", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/new-shelve")
|
|
|
@ResponseBody
|
|
|
public Map newShelveProduct(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.newShelveProduct(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("newShelveProduct", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/new_product")
|
|
|
@ResponseBody
|
|
|
public Map newProduct(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.newProduct(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("newProduct", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/shops")
|
|
|
@ResponseBody
|
|
|
public Map shops(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.shops(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("shops", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Map errorReturn(final String funName, final Map<String, Object> paramMap, final String errorMessage) {
|
|
|
logger.error("[※查询]失败:[func={}][param={}][message={}]", funName, JsonUtil.toJson(paramMap), errorMessage);
|
|
|
Map<String, Object> rtnMap = new HashMap<String, Object>();
|
|
|
rtnMap.put("code", 400);
|
|
|
rtnMap.put("status", "error");
|
|
|
rtnMap.put("errmsg", errorMessage);
|
|
|
return rtnMap; //new ModelAndView(ISearchConstans.JSON_VIEW_NAME, rtnMap);
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/group_brands")
|
|
|
@ResponseBody
|
|
|
public Map groupBrands(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.groupBrands(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("groupBrands", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/new-shelve")
|
|
|
@ResponseBody
|
|
|
public Map newShelveProduct(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.newShelveProduct(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("newShelveProduct", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/new_product")
|
|
|
@ResponseBody
|
|
|
public Map newProduct(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.newProduct(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("newProduct", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/shops")
|
|
|
@ResponseBody
|
|
|
public Map shops(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.shops(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("shops", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Map errorReturn(final String funName, final Map<String, Object> paramMap, final String errorMessage) {
|
|
|
logger.error("[※查询]失败:[func={}][param={}][message={}]", funName, JsonUtil.toJson(paramMap), errorMessage);
|
|
|
Map<String, Object> rtnMap = new HashMap<String, Object>();
|
|
|
rtnMap.put("code", 400);
|
|
|
rtnMap.put("status", "error");
|
|
|
rtnMap.put("errmsg", errorMessage);
|
|
|
return rtnMap; // new ModelAndView(ISearchConstans.JSON_VIEW_NAME,
|
|
|
// rtnMap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将HttpServletRequest中被锁定的ParameterMap转化为普通的HashMap
|
|
|
* */
|
|
|
public static Map<String, String> transParamType(Map<String, Object> paramMap){
|
|
|
Map<String, String> rtnMap = new HashMap<String, String>();
|
|
|
Iterator<String> itKeys = paramMap.keySet().iterator();
|
|
|
while(itKeys.hasNext()){
|
|
|
String key = itKeys.next();
|
|
|
String val = ((String[])paramMap.get(key))[0];
|
|
|
rtnMap.put(key, val);
|
|
|
}
|
|
|
return rtnMap;
|
|
|
public static Map<String, String> transParamType(Map<String, Object> paramMap) {
|
|
|
Map<String, String> rtnMap = new HashMap<String, String>();
|
|
|
Iterator<String> itKeys = paramMap.keySet().iterator();
|
|
|
while (itKeys.hasNext()) {
|
|
|
String key = itKeys.next();
|
|
|
String val = ((String[]) paramMap.get(key))[0];
|
|
|
rtnMap.put(key, val);
|
|
|
}
|
|
|
return rtnMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取分类,以及分类下的型号
|
|
|
*
|
...
|
...
|
@@ -218,10 +218,10 @@ public class SearchController { |
|
|
public SearchApiResult sort_sizes(@ModelAttribute SizeSortReqBO sizeSortReqBO) {
|
|
|
return searchSortSizeService.sortSizes(sizeSortReqBO);
|
|
|
}
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/sort_size_products")
|
|
|
public Map<String,Object> sort_size_products(HttpServletRequest request) {
|
|
|
public Map<String, Object> sort_size_products(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchSortSizeService.sortSizeProducts(transParamType(paramMap));
|
...
|
...
|
@@ -231,16 +231,16 @@ public class SearchController { |
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/group_shops")
|
|
|
@ResponseBody
|
|
|
public Map groupShops(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.groupShops(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("groupShops", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/group_shops")
|
|
|
@ResponseBody
|
|
|
public Map groupShops(HttpServletRequest request) {
|
|
|
Map<String, Object> paramMap = request.getParameterMap();
|
|
|
try {
|
|
|
Map<String, Object> jsonMap = searchService.groupShops(transParamType(paramMap));
|
|
|
return jsonMap;
|
|
|
} catch (Exception e) {
|
|
|
return errorReturn("groupShops", paramMap, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|