热词自定义分数线功能完善
This commit is contained in:
parent
fe8523ca3f
commit
8b861e8fe7
@ -0,0 +1,24 @@
|
||||
package cn.lili.modules.search.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 搜索热词
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-07-26 15:46
|
||||
*/
|
||||
@Data
|
||||
public class HotWordsDTO {
|
||||
|
||||
@NotBlank(message = "搜索热词不能为空")
|
||||
private String keywords;
|
||||
|
||||
@NotNull(message = "分数不能为空")
|
||||
private Integer point;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
|
||||
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.entity.dto.HotWordsDTO;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,11 +37,9 @@ public interface EsGoodsSearchService {
|
||||
|
||||
/**
|
||||
* 设置热门关键词
|
||||
*
|
||||
* @param words 关键词
|
||||
* @param point 赋予分数
|
||||
* @param hotWords 热词分数
|
||||
*/
|
||||
void setHotWords(String words, Integer point);
|
||||
void setHotWords(HotWordsDTO hotWords);
|
||||
|
||||
/**
|
||||
* 获取筛选器
|
||||
|
@ -15,6 +15,7 @@ import cn.lili.modules.goods.service.CategoryService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
|
||||
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.entity.dto.HotWordsDTO;
|
||||
import cn.lili.modules.search.entity.dto.ParamOptions;
|
||||
import cn.lili.modules.search.entity.dto.SelectorOptions;
|
||||
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
@ -111,8 +112,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHotWords(String words, Integer point) {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), words, point);
|
||||
public void setHotWords(HotWordsDTO hotWords) {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,12 +2,12 @@ package cn.lili.controller.setting;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.search.entity.dto.HotWordsDTO;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -34,13 +34,10 @@ public class HotWordsManagerController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设置热词")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字"),
|
||||
@ApiImplicitParam(name = "point", value = "权重值")
|
||||
})
|
||||
@PostMapping
|
||||
public ResultMessage paymentForm(String keywords, Integer point) {
|
||||
esGoodsSearchService.setHotWords(keywords, point);
|
||||
public ResultMessage paymentForm(@Validated HotWordsDTO hotWords) {
|
||||
|
||||
esGoodsSearchService.setHotWords(hotWords);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user