Merge branch 'backup'
# Conflicts: # manager-api/src/main/java/cn/lili/controller/member/MemberManagerController.java # manager-api/src/main/java/cn/lili/controller/other/PageDataManagerController.java # manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java # manager-api/src/main/java/cn/lili/controller/permission/MenuManagerController.java # manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java # manager-api/src/main/java/cn/lili/controller/store/StoreManagerController.java
This commit is contained in:
27
framework/src/main/java/cn/lili/cache/Cache.java
vendored
27
framework/src/main/java/cn/lili/cache/Cache.java
vendored
@@ -60,7 +60,7 @@ public interface Cache<T> {
|
||||
* Add an item to the cache, nontransactionally, with
|
||||
* failfast semantics
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
*/
|
||||
void put(Object key, T value);
|
||||
@@ -68,7 +68,7 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 往缓存中写入内容
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
* @param exp 超时时间,单位为秒
|
||||
*/
|
||||
@@ -77,9 +77,9 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 往缓存中写入内容
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
* @param exp 过期时间
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
* @param exp 过期时间
|
||||
* @param timeUnit 过期单位
|
||||
*/
|
||||
void put(Object key, T value, Long exp, TimeUnit timeUnit);
|
||||
@@ -124,7 +124,7 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 读取缓存值
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param key 缓存key
|
||||
* @param hashKey map value
|
||||
* @return 返回缓存中的数据
|
||||
*/
|
||||
@@ -142,8 +142,7 @@ public interface Cache<T> {
|
||||
* 是否包含
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @return 缓存中的数据
|
||||
*
|
||||
* @return 缓存中的数据
|
||||
*/
|
||||
boolean hasKey(Object key);
|
||||
|
||||
@@ -164,7 +163,7 @@ public interface Cache<T> {
|
||||
* 效率较高的 计数器
|
||||
* 如需清零,按照普通key 移除即可
|
||||
*
|
||||
* @param key key值
|
||||
* @param key key值
|
||||
* @param value 去重统计值
|
||||
* @return 计数器结果
|
||||
*/
|
||||
@@ -223,6 +222,16 @@ public interface Cache<T> {
|
||||
*/
|
||||
void incrementScore(String sortedSetName, String keyword);
|
||||
|
||||
/**
|
||||
* 使用Sorted Set记录keyword
|
||||
* zincrby命令,对于一个Sorted Set,存在的就把分数加x(x可自行设定),不存在就创建一个分数为1的成员
|
||||
*
|
||||
* @param sortedSetName sortedSetName的Sorted Set不用预先创建,不存在会自动创建,存在则向里添加数据
|
||||
* @param keyword 关键词
|
||||
* @param score 分数
|
||||
*/
|
||||
void incrementScore(String sortedSetName, String keyword, Integer score);
|
||||
|
||||
/**
|
||||
* zrevrange命令, 查询Sorted Set中指定范围的值
|
||||
* 返回的有序集合中,score大的在前面
|
||||
|
||||
@@ -223,9 +223,13 @@ public class RedisCache implements Cache {
|
||||
*/
|
||||
@Override
|
||||
public void incrementScore(String sortedSetName, String keyword) {
|
||||
//x 的含义请见本方法的注释
|
||||
double x = 1.0;
|
||||
this.redisTemplate.opsForZSet().incrementScore(sortedSetName, keyword, x);
|
||||
//指向key名为KEY的zset元素
|
||||
redisTemplate.opsForZSet().incrementScore(sortedSetName,keyword, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementScore(String sortedSetName, String keyword, Integer score) {
|
||||
redisTemplate.opsForZSet().incrementScore(sortedSetName, keyword, score);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package cn.lili.modules.search.entity.enums;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2021/1/20
|
||||
**/
|
||||
public enum HotWordsRedisKeyEnum {
|
||||
|
||||
/**
|
||||
* "搜索热词"
|
||||
*/
|
||||
SEARCH_HOT_WORD("搜索热词");
|
||||
|
||||
|
||||
private final String description;
|
||||
|
||||
HotWordsRedisKeyEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,14 @@ public interface EsGoodsSearchService {
|
||||
*/
|
||||
List<String> getHotWords(Integer start, Integer end);
|
||||
|
||||
/**
|
||||
* 设置热门关键词
|
||||
*
|
||||
* @param words 关键词
|
||||
* @param point 赋予分数
|
||||
*/
|
||||
void setHotWords(String words, Integer point);
|
||||
|
||||
/**
|
||||
* 获取筛选器
|
||||
*
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.lili.modules.search.serviceimpl;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.Brand;
|
||||
@@ -16,7 +17,6 @@ import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
|
||||
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.entity.dto.ParamOptions;
|
||||
import cn.lili.modules.search.entity.dto.SelectorOptions;
|
||||
import cn.lili.modules.search.entity.enums.HotWordsRedisKeyEnum;
|
||||
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -51,6 +51,7 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* ES商品搜索业务层实现
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/10/16
|
||||
**/
|
||||
@@ -90,7 +91,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
@Override
|
||||
public Page<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
|
||||
if (CharSequenceUtil.isNotEmpty(searchDTO.getKeyword())) {
|
||||
cache.incrementScore(HotWordsRedisKeyEnum.SEARCH_HOT_WORD.name(), searchDTO.getKeyword());
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword());
|
||||
}
|
||||
NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo, true);
|
||||
NativeSearchQuery searchQuery = searchQueryBuilder.build();
|
||||
@@ -102,13 +103,18 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
@Override
|
||||
public List<String> getHotWords(Integer start, Integer end) {
|
||||
List<String> hotWords = new ArrayList<>();
|
||||
Set<DefaultTypedTuple> set = cache.reverseRangeWithScores(HotWordsRedisKeyEnum.SEARCH_HOT_WORD.name(), start, end);
|
||||
Set<DefaultTypedTuple> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), start, end);
|
||||
for (DefaultTypedTuple defaultTypedTuple : set) {
|
||||
hotWords.add(Objects.requireNonNull(defaultTypedTuple.getValue()).toString());
|
||||
}
|
||||
return hotWords;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHotWords(String words, Integer point) {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), words, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) {
|
||||
NativeSearchQueryBuilder builder = createSearchQueryBuilder(goodsSearch, null, true);
|
||||
@@ -318,6 +324,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
|
||||
/**
|
||||
* 查询属性处理
|
||||
*
|
||||
* @param filterBuilder
|
||||
* @param queryBuilder
|
||||
* @param searchDTO
|
||||
@@ -391,7 +398,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
//价格区间判定
|
||||
if (CharSequenceUtil.isNotEmpty(searchDTO.getPrice())) {
|
||||
String[] prices = searchDTO.getPrice().split("_");
|
||||
if(prices.length==0){
|
||||
if (prices.length == 0) {
|
||||
return;
|
||||
}
|
||||
double min = Convert.toDouble(prices[0], 0.0);
|
||||
@@ -406,6 +413,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
|
||||
/**
|
||||
* 关键字查询处理
|
||||
*
|
||||
* @param filterBuilder
|
||||
* @param queryBuilder
|
||||
* @param keyword
|
||||
|
||||
@@ -3,8 +3,8 @@ package cn.lili.modules.system.token;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.enums.PermissionEnum;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.security.token.TokenUtil;
|
||||
import cn.lili.common.security.token.base.AbstractTokenGenerate;
|
||||
@@ -116,11 +116,19 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate {
|
||||
*/
|
||||
void initPermission(List<String> superPermissions, List<String> queryPermissions) {
|
||||
//用户信息维护
|
||||
superPermissions.add("/manager/user/info");
|
||||
superPermissions.add("/manager/user/edit");
|
||||
superPermissions.add("/manager/user/info*");
|
||||
superPermissions.add("/manager/user/edit*");
|
||||
superPermissions.add("/manager/user/editPassword*");
|
||||
//统计查看
|
||||
|
||||
//统计查看权限
|
||||
queryPermissions.add("/manager/statistics*");
|
||||
//菜单查看权限
|
||||
queryPermissions.add("/manager/menu*");
|
||||
//商品分类查看权限
|
||||
queryPermissions.add("/manager/goods/category*");
|
||||
//查看地区接口
|
||||
queryPermissions.add("/manager/region*");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user