Merge branch 'master' into pipi
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,8 +39,15 @@ public class MemberEvaluationListVO {
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "物流评分")
|
||||
private Integer deliveryScore;
|
||||
|
||||
@ApiModelProperty(value = "服务评分")
|
||||
private Integer serviceScore;
|
||||
|
||||
@ApiModelProperty(value = "描述评分")
|
||||
private Integer descriptionScore;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
|
||||
@Autowired
|
||||
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
||||
|
||||
/**
|
||||
* 设置行业
|
||||
*/
|
||||
private final String setIndustry = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=";
|
||||
/**
|
||||
* get 获取所有的模版
|
||||
*/
|
||||
@@ -54,9 +58,18 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
|
||||
try {
|
||||
this.baseMapper.deleteAll();
|
||||
|
||||
//获取token
|
||||
String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
||||
|
||||
|
||||
//设置行业
|
||||
Map<String, Object> setIndustryParams = new HashMap<>();
|
||||
setIndustryParams.put("industry_id1", 1);//互联网/电子商务
|
||||
setIndustryParams.put("industry_id2", 5);//通信与运营商
|
||||
String context = HttpUtils.doPostWithJson(setIndustry + accessToken, setIndustryParams);
|
||||
|
||||
//获取已有模版,删除
|
||||
String context = HttpUtil.get(allMsgTpl + accessToken);
|
||||
context = HttpUtil.get(allMsgTpl + accessToken);
|
||||
JSONObject jsonObject = new JSONObject(context);
|
||||
WechatMessageUtil.wechatHandler(jsonObject);
|
||||
List<String> oldList = new ArrayList<>();
|
||||
@@ -77,7 +90,7 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
|
||||
List<WechatMessageData> tmpList = initData();
|
||||
tmpList.forEach(tplData -> {
|
||||
WechatMessage wechatMessage = new WechatMessage();
|
||||
Map params = new HashMap<>(1);
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
params.put("template_id_short", tplData.getMsgId());
|
||||
String content = HttpUtils.doPostWithJson(addTpl + accessToken, params);
|
||||
JSONObject tplContent = new JSONObject(content);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class WechatAccessTokenUtil {
|
||||
}
|
||||
//获取token
|
||||
String content = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential" +
|
||||
"&appid=" + item.getAppId() + "&secret=" + item.getAppSecret());
|
||||
"&appid=wx6cfbe6e0ace12ce8&secret=6dfbe0c72380dce5d49d65b3c91059b1");
|
||||
|
||||
JSONObject object = new JSONObject(content);
|
||||
log.info("token获取【" + clientTypeEnum.name() + "】返回" + object.toString());
|
||||
|
||||
@@ -93,7 +93,7 @@ public class WechatMessageUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("微信消息发送消息:", order.getMemberId() + "-" + sn);
|
||||
log.info("微信消息发送消息:{}", order.getMemberId() + "-" + sn);
|
||||
//获取token
|
||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class WechatMessageUtil {
|
||||
wechatMPMessageQueryWrapper.eq(WechatMPMessage::getOrderStatus, order.getOrderStatus());
|
||||
WechatMPMessage wechatMPMessage = wechatMPMessageService.getOne(wechatMPMessageQueryWrapper);
|
||||
if (wechatMPMessage == null) {
|
||||
log.error("未配置微信消息订阅");
|
||||
log.info("未配置微信消息订阅");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class WechatMessageUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("微信消息订阅消息发送:", order.getMemberId() + "-" + sn);
|
||||
log.info("微信消息订阅消息发送:{}", order.getMemberId() + "-" + sn);
|
||||
//获取token
|
||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||
|
||||
@@ -270,7 +270,7 @@ public class WechatMessageUtil {
|
||||
/**
|
||||
* 如果返回信息有错误
|
||||
*
|
||||
* @param jsonObject
|
||||
* @param jsonObject 返回消息
|
||||
*/
|
||||
public static void wechatHandler(JSONObject jsonObject) {
|
||||
if (jsonObject.containsKey("errmsg")) {
|
||||
@@ -283,9 +283,9 @@ public class WechatMessageUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果返回信息有错误....................................................................................................................................................................................333333333333333333
|
||||
* 如果返回信息有错误
|
||||
*
|
||||
* @param string
|
||||
* @param string 返回消息
|
||||
*/
|
||||
public static String wechatHandler(String string) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
@@ -26,36 +26,30 @@ public class Menu extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 7050744476203495207L;
|
||||
|
||||
@ApiModelProperty(value = "菜单/权限名称")
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "层级")
|
||||
@ApiModelProperty(value = "菜单层级")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(value = "菜单标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "赋权API地址,正则表达式")
|
||||
@ApiModelProperty(value = "路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "前端路由")
|
||||
@ApiModelProperty(value = "前端目录文件")
|
||||
private String frontRoute;
|
||||
|
||||
@ApiModelProperty(value = "图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty(value = "父id")
|
||||
private String parentId = "0";
|
||||
|
||||
@ApiModelProperty(value = "说明备注")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "排序值")
|
||||
@Column(precision = 10, scale = 2)
|
||||
private BigDecimal sortOrder;
|
||||
|
||||
@ApiModelProperty(value = "文件地址")
|
||||
private String frontComponent;
|
||||
@ApiModelProperty(value = "权限URL,*号模糊匹配,逗号分割")
|
||||
private String permission;
|
||||
|
||||
|
||||
}
|
||||
@@ -19,4 +19,10 @@ public class UserMenuVO extends Menu {
|
||||
*/
|
||||
private Boolean isSupper;
|
||||
|
||||
public Boolean getSupper() {
|
||||
if (this.isSupper == null) {
|
||||
return false;
|
||||
}
|
||||
return isSupper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -34,6 +35,12 @@ public interface EsGoodsSearchService {
|
||||
*/
|
||||
List<String> getHotWords(Integer start, Integer end);
|
||||
|
||||
/**
|
||||
* 设置热门关键词
|
||||
* @param hotWords 热词分数
|
||||
*/
|
||||
void setHotWords(HotWordsDTO hotWords);
|
||||
|
||||
/**
|
||||
* 获取筛选器
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -14,9 +15,9 @@ 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.entity.enums.HotWordsRedisKeyEnum;
|
||||
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -51,6 +52,7 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* ES商品搜索业务层实现
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/10/16
|
||||
**/
|
||||
@@ -90,7 +92,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 +104,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(HotWordsDTO hotWords) {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) {
|
||||
NativeSearchQueryBuilder builder = createSearchQueryBuilder(goodsSearch, null, true);
|
||||
@@ -318,6 +325,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
|
||||
/**
|
||||
* 查询属性处理
|
||||
*
|
||||
* @param filterBuilder
|
||||
* @param queryBuilder
|
||||
* @param searchDTO
|
||||
@@ -391,7 +399,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 +414,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;
|
||||
@@ -77,28 +77,27 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate {
|
||||
//循环权限菜单
|
||||
userMenuVOList.forEach(menu -> {
|
||||
//循环菜单,赋予用户权限
|
||||
if (menu.getPath() != null) {
|
||||
if (menu.getPermission() != null) {
|
||||
//获取路径集合
|
||||
String[] paths = menu.getPath().split("\\|");
|
||||
String[] permissionUrl = menu.getPermission().split(",");
|
||||
//for循环路径集合
|
||||
for (String path : paths) {
|
||||
for (String url : permissionUrl) {
|
||||
//如果是超级权限 则计入超级权限
|
||||
if (menu.getIsSupper() != null && menu.getIsSupper()) {
|
||||
if (menu.getSupper()) {
|
||||
//如果已有超级权限,则这里就不做权限的累加
|
||||
if (!superPermissions.contains(path)) {
|
||||
superPermissions.add(path);
|
||||
if (!superPermissions.contains(url)) {
|
||||
superPermissions.add(url);
|
||||
}
|
||||
}
|
||||
//否则计入浏览权限
|
||||
else {
|
||||
//如果已有超级权限,或者已有普通查看权限,则这里就不做权限的累加
|
||||
if (!superPermissions.contains(path) && !queryPermissions.contains(path)) {
|
||||
queryPermissions.add(path);
|
||||
//没有权限,则累加。
|
||||
if (!queryPermissions.contains(url)) {
|
||||
queryPermissions.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//去除无效的权限
|
||||
superPermissions.forEach(queryPermissions::remove);
|
||||
});
|
||||
@@ -116,11 +115,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