|
|
@@ -20,11 +20,14 @@ import com.uas.search.model.Sort;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.mobile.device.DeviceResolver;
|
|
|
+import org.springframework.mobile.device.LiteDeviceResolver;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
@@ -51,6 +54,7 @@ public class SearcherServiceImpl implements SearcherService {
|
|
|
private BrandDao brandDao;
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+ private final DeviceResolver deviceResolver = new LiteDeviceResolver();
|
|
|
|
|
|
/**
|
|
|
* 智能搜索类目
|
|
|
@@ -170,7 +174,7 @@ public class SearcherServiceImpl implements SearcherService {
|
|
|
if (!CollectionUtils.isEmpty(componentIds)) {
|
|
|
for (int i = 0 ;i < componentIds.size() ; i++){
|
|
|
Long cid = Long.valueOf(componentIds.get(i).toString());
|
|
|
- Long gid = goodsIds.get(i) == null ? null : Long.valueOf(goodsIds.get(i).toString());
|
|
|
+ Long gid = goodsIds.get(i) == null ? 0L : Long.valueOf(goodsIds.get(i).toString());
|
|
|
ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(cid, gid);
|
|
|
if (componentGoods != null){
|
|
|
components.add(componentGoods);
|
|
|
@@ -251,7 +255,7 @@ public class SearcherServiceImpl implements SearcherService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getCollectlistBySearchComponentGoods(String keyword, String collectList, String paramJSON) {
|
|
|
+ public List<Map<String, Object>> getCollectlistBySearchComponentGoods(String keyword, String collectList, String paramJSON , HttpServletRequest request) {
|
|
|
List<Map<String, Object>> collectResult = new ArrayList<>();
|
|
|
JSONObject jsonObject = FastjsonUtils.parseObject(paramJSON);
|
|
|
Set<Entry<String,Object>> paramEntry = jsonObject.entrySet();
|
|
|
@@ -264,9 +268,11 @@ public class SearcherServiceImpl implements SearcherService {
|
|
|
} catch (SearchException e) {
|
|
|
throwSystemException(e);
|
|
|
}
|
|
|
- if ("goods_brand".equals(collectList)){
|
|
|
- for (Map<String,Object> m: collectResult) {
|
|
|
- m.put("logoUrl",brandDao.findOne(Long.parseLong(m.get("br_id").toString())).getLogoUrl());
|
|
|
+ if ("goods_brand".equals(collectList)) {
|
|
|
+ if (this.deviceResolver.resolveDevice(request).isMobile()) {
|
|
|
+ for (Map<String, Object> m : collectResult) {
|
|
|
+ m.put("logoUrl", brandDao.findOne(Long.parseLong(m.get("br_id").toString())).getLogoUrl());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return collectResult;
|