Commit 7b4b313c authored by muhong's avatar muhong

修改 首页名称联想去重

parent 329eb876
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.Keyword;
import java.util.List;
public interface KeywordDao {
List<Keyword> findList();
}
package com.wwdz.ch.db.impl;
import com.wwdz.ch.db.dao.KeywordDao;
import com.wwdz.ch.db.domain.Keyword;
import com.wwdz.ch.db.domain.KeywordExample;
import com.wwdz.ch.db.mapper.KeywordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class KeywordDaoImpl implements KeywordDao {
@Autowired
private KeywordMapper keywordMapper;
@Override
public List<Keyword> findList() {
KeywordExample example = new KeywordExample();
example.or().andDeletedEqualTo(false);
return keywordMapper.selectByExample(example);
}
}
...@@ -31,7 +31,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer { ...@@ -31,7 +31,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js" .excludePathPatterns("/*.html", "/**/*.html", "/**/*.css", "/**/*.js"
, "/wx/user/loginByWx", "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha" , "/wx/user/loginByWx", "/wx/user/loginByMobile", "/wx/user/loginRegCaptcha", "/wx/user/updateRegCaptcha"
, "/wx/item/page", "/wx/item/info", "/wx/item/findNames", "/wx/item/recommend" , "/wx/item/page", "/wx/item/info", "/wx/item/findNames"
, "/wx/favorites/info", "/wx/favorites/itemList"); , "/wx/favorites/info", "/wx/favorites/itemList"
, "/wx/keyword/recommend");
} }
} }
...@@ -447,21 +447,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -447,21 +447,13 @@ public class FavoritesServiceImpl implements FavoritesService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(item.getTopImage())) { if (StringUtils.isNotBlank(item.getImages())) {
if (item.getTopImage().contains("_")) { String[] image = item.getImages().split(";");
homePageMap = getImageMap(item.getTopImage()); homePageMap.put("url", image[0]);
homePageMap.put("url", item.getTopImage()); if (image[0].contains("_")) {
homePageMap.put("type", 2); homePageMap = getImageMap(image[0]);
}
} else {
if (StringUtils.isNotBlank(item.getImages())) {
String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { homePageMap.put("type", 2);
homePageMap = getImageMap(image[0]);
homePageMap.put("url", image[0]);
homePageMap.put("type", 2);
}
} }
} }
if (StringUtils.isNotBlank(item.getVideos())) { if (StringUtils.isNotBlank(item.getVideos())) {
...@@ -543,21 +535,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -543,21 +535,13 @@ public class FavoritesServiceImpl implements FavoritesService {
if (CollectionUtils.isNotEmpty(favoritesItemsDtos)) { if (CollectionUtils.isNotEmpty(favoritesItemsDtos)) {
if (favoritesItemsDtos.size() <= 4) { if (favoritesItemsDtos.size() <= 4) {
for (FavoritesItemsDto favoritesItemsDto : favoritesItemsDtos) { for (FavoritesItemsDto favoritesItemsDto : favoritesItemsDtos) {
if (StringUtils.isNotBlank(favoritesItemsDto.getTopImage())) { String[] image = favoritesItemsDto.getImages().split(";");
images.add(favoritesItemsDto.getTopImage()); images.add(image[0]);
} else {
String[] image = favoritesItemsDto.getImages().split(";");
images.add(image[0]);
}
} }
} else { } else {
for (int i = 0; i < 4; i ++) { for (int i = 0; i < 4; i ++) {
if (StringUtils.isNotBlank(favoritesItemsDtos.get(i).getTopImage())) { String[] image = favoritesItemsDtos.get(i).getImages().split(";");
images.add(favoritesItemsDtos.get(i).getTopImage()); images.add(image[0]);
} else {
String[] image = favoritesItemsDtos.get(i).getImages().split(";");
images.add(image[0]);
}
} }
} }
} }
......
...@@ -289,21 +289,13 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -289,21 +289,13 @@ public class FootPrintServiceImpl implements FootPrintService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(item.getTopImage())) { if (StringUtils.isNotBlank(item.getImages())) {
if (item.getTopImage().contains("_")) { String[] image = item.getImages().split(";");
homePageMap = getImageMap(item.getTopImage()); homePageMap.put("url", image[0]);
homePageMap.put("url", item.getTopImage()); if (image[0].contains("_")) {
homePageMap.put("type", 2); homePageMap = getImageMap(image[0]);
}
} else {
if (StringUtils.isNotBlank(item.getImages())) {
String[] image = item.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { homePageMap.put("type", 2);
homePageMap = getImageMap(image[0]);
homePageMap.put("url", image[0]);
homePageMap.put("type", 2);
}
} }
} }
if (StringUtils.isNotBlank(item.getVideos())) { if (StringUtils.isNotBlank(item.getVideos())) {
......
...@@ -81,27 +81,6 @@ public class ItemServiceImpl implements ItemService { ...@@ -81,27 +81,6 @@ public class ItemServiceImpl implements ItemService {
} }
} }
@Override
public Result recommend() {
try {
List<Map<String, Object>> list = favoritesItemsRelationDao.findItemIdByCount();
if (CollectionUtils.isEmpty(list)) {
return Result.success();
}
Random random = new Random();
int index = random.nextInt(20);
Long itemId = (Long) list.get(index).get("item_id");
Item item = itemDao.findDetails(itemId);
Map<String, Object> map = new HashMap<>();
map.put("name", item.getName());
return Result.success(map);
} catch (Exception e) {
logger.error("搜索推荐失败", e);
return Result.failed("搜索推荐失败");
}
}
@Override @Override
public Result page(ItemRequestDto dto) { public Result page(ItemRequestDto dto) {
try { try {
...@@ -559,21 +538,13 @@ public class ItemServiceImpl implements ItemService { ...@@ -559,21 +538,13 @@ public class ItemServiceImpl implements ItemService {
homePageMap.put("type", 2); homePageMap.put("type", 2);
homePageMap.put("width", "0"); homePageMap.put("width", "0");
homePageMap.put("height", "0"); homePageMap.put("height", "0");
if (StringUtils.isNotBlank(es.getTopImage())) { if (StringUtils.isNotBlank(es.getImages())) {
if (es.getTopImage().contains("_")) { String[] image = es.getImages().split(";");
homePageMap = getImageMap(es.getTopImage()); homePageMap.put("url", image[0]);
homePageMap.put("url", es.getTopImage()); if (image[0].contains("_")) {
homePageMap.put("type", 2); homePageMap = getImageMap(image[0]);
}
} else {
if (StringUtils.isNotBlank(es.getImages())) {
String[] image = es.getImages().split(";");
homePageMap.put("url", image[0]); homePageMap.put("url", image[0]);
if (image[0].contains("_")) { homePageMap.put("type", 2);
homePageMap = getImageMap(image[0]);
homePageMap.put("url", image[0]);
homePageMap.put("type", 2);
}
} }
} }
if (StringUtils.isNotBlank(es.getVideos())) { if (StringUtils.isNotBlank(es.getVideos())) {
......
package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.KeywordDao;
import com.wwdz.ch.db.domain.Keyword;
import com.wwdz.ch.wx.service.KeywordService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class KeywordServiceImpl implements KeywordService {
private static final Logger logger = LoggerFactory.getLogger(KeywordServiceImpl.class);
@Autowired
private KeywordDao keywordDao;
@Override
public Result recommend() {
try {
List<String> result = new ArrayList<>();
List<Keyword> list = keywordDao.findList();
if (CollectionUtils.isNotEmpty(list)) {
result = list.stream().map(Keyword::getKeyword).collect(Collectors.toList());
}
logger.info("【请求结束】搜索词推荐成功");
return Result.success(result);
} catch (Exception e) {
logger.error("查询搜索词推荐失败", e);
return Result.failed("查询搜素词推荐失败");
}
}
}
...@@ -15,13 +15,6 @@ public interface ItemService { ...@@ -15,13 +15,6 @@ public interface ItemService {
*/ */
Result nameList(ItemRequestDto dto); Result nameList(ItemRequestDto dto);
/**
* 搜索用藏品名称推荐
*
* @return
*/
Result recommend();
/** /**
* 藏品分页 * 藏品分页
* *
......
package com.wwdz.ch.wx.service;
import com.wwdz.ch.core.type.Result;
public interface KeywordService {
Result recommend();
}
...@@ -45,12 +45,6 @@ public class WxItemController { ...@@ -45,12 +45,6 @@ public class WxItemController {
return itemService.nameList(dto); return itemService.nameList(dto);
} }
@ApiOperation(value = "推荐词汇")
@PostMapping("/recommend")
public Result recommend() {
return itemService.recommend();
}
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@PostMapping("/page") @PostMapping("/page")
public Result page(@RequestBody KlDataRequestDto klDataRequestDto) { public Result page(@RequestBody KlDataRequestDto klDataRequestDto) {
......
package com.wwdz.ch.wx.web;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.service.KeywordService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wx/keyword")
public class WxKeywordController {
private static final Logger logger = LoggerFactory.getLogger(WxKeywordController.class);
@Autowired
private KeywordService keywordService;
@ApiOperation(value = "搜索词推荐")
@PostMapping("/recommend")
public Result recommend() {
logger.info("【请求开始】搜索词推荐");
return keywordService.recommend();
}
}
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