Commit b11a0192 authored by zhangyong's avatar zhangyong

1

parent 0dc47a17
......@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.GsonUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
......@@ -147,29 +148,26 @@ public class GoodsController {
return Rjx.jsonOk().set("list", listMap).set("page",page).toJson();
}
@ApiOperation("统一搜索(未完成,要弄搜索引擎)")
@ApiOperation("统一搜索(支持品牌,分类,关键字,仓库等)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = "00029997"),
@ApiImplicitParam(paramType = "query", name = "queryStr", dataType = "String", required = false, value = "搜索内容()", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, value = "JSON参数", defaultValue = "{\"topCategoryNO\":\"01\",\"upCategoryNO\":\"\",\"categoryID\":[\"\"],\"brandID\":[\"\"],\"agentID\":\"\",\"warehouseNO\":\"\",\"scopeTypeID\":\"1\",\"districtID\":\"\",\"keyword\":\"*\",\"index\":1,\"userNO\":\"00034\",\"shopNO\":\"167728271\"}"),
})
@RequestMapping(value = "/searchGoods",method=RequestMethod.GET)
@RequestMapping(value = "/searchGoods",method=RequestMethod.POST)
public String searchGoods(HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> listMap;
Map<String,Object> params=new HashMap<>();
params.put("orgNO", request.getParameter("orgNO"));
params.put("shopNO", request.getParameter("shopNO")==null?"":request.getParameter("shopNO"));
params.put("queryStr", request.getParameter("queryStr")==null?"%":request.getParameter("queryStr"));
Page page=new Page();
page.setIndex(Long.valueOf(request.getParameter("index")==null?"1":request.getParameter("index")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"10":request.getParameter("limit")));
page.setLimitKey("GoodsID desc");
listMap=goodsService.GetCategoryGoods(params,page);
return Rjx.jsonOk().set("list", listMap).set("page",page).toJson();
String reqJson = ServletUtil.readReqJson(request);
System.out.println("searchGoods-------"+reqJson);
Map<String, Object> argsMap = new HashMap<String,Object>();
try {
argsMap = GsonUtil.toMap(reqJson);
if(!argsMap.containsKey("index") || !argsMap.containsKey("limit") || !argsMap.containsKey("userNO") || !argsMap.containsKey("shopNO") || !argsMap.containsKey("orgNO")) {
return Rjx.jsonErr().setCode(-100).setMessage("参数缺失").set("errorMsg", "index,limit,userNO,shopNO,orgNO为必填项").toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage("查询参数格式错误").toJson();
}
return goodsService.searchGoods(argsMap);
}
......
......@@ -14,7 +14,7 @@ public interface GoodsService {
public List<Map<String,Object>> GetCategoryGoods (Map<String,Object> map, Page page);
List<Map<String, Object>> searchGoods(Map<String, Object> map, Page page);
String searchGoods(Map<String, Object> map);
List<Map<String, Object>> hotSearchKey(Map<String, Object> map, Page page);
......
......@@ -67,6 +67,7 @@ public class SolrGoodsServiceImpl implements SolrGoodsService {
String[] limitKeys = page.getLimitKey();
if(limitKeys != null) {
for(String key : limitKeys) {
System.out.println("key---"+key);
String[] kv = key.split(" ", 2);
ORDER sc = kv[1] == null || kv[1].trim().length() == 0 || kv[1].equalsIgnoreCase("asc") ? ORDER.asc : ORDER.desc;
solrQuery.addSort(kv[0], sc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment