同步master,解决冲突
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.cache;
|
||||
package cn.lili.cache;
|
||||
|
||||
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
@@ -19,7 +19,7 @@ public interface Cache<T> {
|
||||
/**
|
||||
* Get an item from the cache, nontransactionally
|
||||
*
|
||||
* @param key
|
||||
* @param key 缓存key
|
||||
* @return the cached object or <tt>null</tt>
|
||||
*/
|
||||
T get(Object key);
|
||||
@@ -27,7 +27,7 @@ public interface Cache<T> {
|
||||
/**
|
||||
* Get an item from the cache, nontransactionally
|
||||
*
|
||||
* @param key
|
||||
* @param key 缓存key
|
||||
* @return the cached object or <tt>null</tt>
|
||||
*/
|
||||
String getString(Object key);
|
||||
@@ -37,14 +37,14 @@ public interface Cache<T> {
|
||||
* multiGet
|
||||
*
|
||||
* @param keys 要查询的key集合
|
||||
* @return
|
||||
* @return 集合
|
||||
*/
|
||||
List multiGet(Collection keys);
|
||||
|
||||
/**
|
||||
* 批量set
|
||||
*
|
||||
* @param map
|
||||
* @param map 键值对
|
||||
*/
|
||||
void multiSet(Map map);
|
||||
|
||||
@@ -60,16 +60,16 @@ public interface Cache<T> {
|
||||
* Add an item to the cache, nontransactionally, with
|
||||
* failfast semantics
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
*/
|
||||
void put(Object key, T value);
|
||||
|
||||
/**
|
||||
* 往缓存中写入内容
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
* @param exp 超时时间,单位为秒
|
||||
*/
|
||||
void put(Object key, T value, Long exp);
|
||||
@@ -77,24 +77,24 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 往缓存中写入内容
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param exp
|
||||
* @param timeUnit 写入单位
|
||||
* @param key 缓存key
|
||||
* @param value 缓存value
|
||||
* @param exp 过期时间
|
||||
* @param timeUnit 过期单位
|
||||
*/
|
||||
void put(Object key, T value, Long exp, TimeUnit timeUnit);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param key
|
||||
* @param key 缓存key
|
||||
*/
|
||||
void remove(Object key);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param key
|
||||
* @param key 缓存key
|
||||
*/
|
||||
void vagueDel(Object key);
|
||||
|
||||
@@ -116,33 +116,33 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 玩缓存中写入内容
|
||||
*
|
||||
* @param key
|
||||
* @param map
|
||||
* @param key 缓存key
|
||||
* @param map map value
|
||||
*/
|
||||
void putAllHash(Object key, Map map);
|
||||
|
||||
/**
|
||||
* 读取缓存值
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @return
|
||||
* @param key 缓存key
|
||||
* @param hashKey map value
|
||||
* @return 返回缓存中的数据
|
||||
*/
|
||||
T getHash(Object key, Object hashKey);
|
||||
|
||||
/**
|
||||
* 读取缓存值
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @param key 缓存key
|
||||
* @return 缓存中的数据
|
||||
*/
|
||||
Map<Object, Object> getHash(Object key);
|
||||
|
||||
/**
|
||||
* 是否包含
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @param key 缓存key
|
||||
* @return 缓存中的数据
|
||||
*/
|
||||
boolean hasKey(Object key);
|
||||
|
||||
@@ -150,8 +150,8 @@ public interface Cache<T> {
|
||||
/**
|
||||
* 模糊匹配key
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
* @param pattern 模糊key
|
||||
* @return 缓存中的数据
|
||||
*/
|
||||
List<String> keys(String pattern);
|
||||
|
||||
@@ -163,9 +163,9 @@ public interface Cache<T> {
|
||||
* 效率较高的 计数器
|
||||
* 如需清零,按照普通key 移除即可
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
* @param key key值
|
||||
* @param value 去重统计值
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long cumulative(Object key, Object value);
|
||||
|
||||
@@ -175,8 +175,8 @@ public interface Cache<T> {
|
||||
* 效率较高的 计数器 统计返回
|
||||
* 如需清零,按照普通key 移除即可
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @param key 计数器key
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long counter(Object key);
|
||||
|
||||
@@ -184,7 +184,7 @@ public interface Cache<T> {
|
||||
* 批量计数
|
||||
*
|
||||
* @param keys 要查询的key集合
|
||||
* @return
|
||||
* @return 批量计数
|
||||
*/
|
||||
List multiCounter(Collection keys);
|
||||
|
||||
@@ -194,8 +194,8 @@ public interface Cache<T> {
|
||||
* 效率较高的 计数器 统计返回
|
||||
* 如需清零,按照普通key 移除即可
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @param key key值
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long mergeCounter(Object... key);
|
||||
//---------------------------------------------------用于特殊场景,redis去重统计-----------------------------------------
|
||||
@@ -208,7 +208,7 @@ public interface Cache<T> {
|
||||
*
|
||||
* @param key 为累计的key,同一key每次调用则值 +1
|
||||
* @param liveTime 单位秒后失效
|
||||
* @return
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long incr(String key, long liveTime);
|
||||
//-----------------------------------------------redis计数---------------------------------------------
|
||||
@@ -222,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大的在前面
|
||||
@@ -230,7 +240,7 @@ public interface Cache<T> {
|
||||
* @param sortedSetName sortedSetName
|
||||
* @param start 查询范围开始位置
|
||||
* @param end 查询范围结束位置
|
||||
* @return
|
||||
* @return 获取满足条件的集合
|
||||
*/
|
||||
Set<ZSetOperations.TypedTuple<Object>> reverseRangeWithScores(String sortedSetName, Integer start, Integer end);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.common.cache;
|
||||
package cn.lili.cache;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
|
||||
/**
|
||||
* 缓存前缀
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.mongo;
|
||||
package cn.lili.cache.config.mongo;
|
||||
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.MongoCredential;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.cache;
|
||||
package cn.lili.cache.config.redis;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
@@ -11,7 +11,6 @@ import java.nio.charset.Charset;
|
||||
* 要实现对象的缓存,定义自己的序列化和反序列化器。使用阿里的fastjson来实现的比较多
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 12:25 上午
|
||||
*/
|
||||
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.cache;
|
||||
package cn.lili.cache.config.redis;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
@@ -36,7 +36,6 @@ import java.util.Map;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2021/3/20 09:37
|
||||
*/
|
||||
|
||||
@@ -54,8 +53,8 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
/**
|
||||
* 当有多个管理器的时候,必须使用该注解在一个管理器上注释:表示该管理器为默认的管理器
|
||||
*
|
||||
* @param connectionFactory
|
||||
* @return
|
||||
* @param connectionFactory 链接工厂
|
||||
* @return 缓存
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.common.cache.impl;
|
||||
package cn.lili.cache.impl;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
@@ -86,7 +86,7 @@ public class RedisCache implements Cache {
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param key
|
||||
* @param key 模糊删除key
|
||||
*/
|
||||
@Override
|
||||
public void vagueDel(Object key) {
|
||||
@@ -130,7 +130,7 @@ public class RedisCache implements Cache {
|
||||
* 获取符合条件的key
|
||||
*
|
||||
* @param pattern 表达式
|
||||
* @return
|
||||
* @return 模糊匹配key
|
||||
*/
|
||||
@Override
|
||||
public List<String> keys(String pattern) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +240,7 @@ public class RedisCache implements Cache {
|
||||
* @param sortedSetName sortedSetName
|
||||
* @param start 查询范围开始位置
|
||||
* @param end 查询范围结束位置
|
||||
* @return
|
||||
* @return 符合排序的集合
|
||||
*/
|
||||
@Override
|
||||
public Set<ZSetOperations.TypedTuple<Object>> reverseRangeWithScores(String sortedSetName, Integer start, Integer end) {
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.common.aop.limiter.annotation;
|
||||
package cn.lili.cache.limit.annotation;
|
||||
|
||||
|
||||
import cn.lili.common.aop.limiter.LimitType;
|
||||
import cn.lili.cache.limit.enums.LimitTypeEnums;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -60,5 +60,5 @@ public @interface LimitPoint {
|
||||
*
|
||||
* @return LimitType
|
||||
*/
|
||||
LimitType limitType() default LimitType.IP;
|
||||
LimitTypeEnums limitType() default LimitTypeEnums.IP;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.aop.limiter;
|
||||
package cn.lili.cache.limit.enums;
|
||||
|
||||
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ package cn.lili.common.aop.limiter;
|
||||
* @since 2018年2月02日 下午4:58:52
|
||||
*/
|
||||
|
||||
public enum LimitType {
|
||||
public enum LimitTypeEnums {
|
||||
/**
|
||||
* 自定义key(即全局限流)
|
||||
*/
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.common.aop.limiter;
|
||||
package cn.lili.cache.limit.interceptor;
|
||||
|
||||
import cn.lili.common.aop.limiter.annotation.LimitPoint;
|
||||
import cn.lili.cache.limit.enums.LimitTypeEnums;
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -43,12 +44,12 @@ public class LimitInterceptor {
|
||||
|
||||
@Before("@annotation(limitPointAnnotation)")
|
||||
public void interceptor(LimitPoint limitPointAnnotation) {
|
||||
LimitType limitType = limitPointAnnotation.limitType();
|
||||
LimitTypeEnums limitTypeEnums = limitPointAnnotation.limitType();
|
||||
String name = limitPointAnnotation.name();
|
||||
String key;
|
||||
int limitPeriod = limitPointAnnotation.period();
|
||||
int limitCount = limitPointAnnotation.limit();
|
||||
switch (limitType) {
|
||||
switch (limitTypeEnums) {
|
||||
case CUSTOMER:
|
||||
key = limitPointAnnotation.key();
|
||||
break;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.utils;
|
||||
package cn.lili.cache.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,7 +29,7 @@ public class RedisUtil {
|
||||
*
|
||||
* @param key 键
|
||||
* @param time 时间(秒)
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean expire(String key, long time) {
|
||||
try {
|
||||
@@ -133,7 +133,7 @@ public class RedisUtil {
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, Object value) {
|
||||
try {
|
||||
@@ -151,7 +151,7 @@ public class RedisUtil {
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒)
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, Object value, long time) {
|
||||
try {
|
||||
@@ -171,7 +171,7 @@ public class RedisUtil {
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, List<Object> value) {
|
||||
try {
|
||||
@@ -190,7 +190,7 @@ public class RedisUtil {
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒)
|
||||
* @return
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, List<Object> value, long time) {
|
||||
try {
|
||||
@@ -211,10 +211,10 @@ public class RedisUtil {
|
||||
/**
|
||||
* 向Zset里添加成员
|
||||
*
|
||||
* @param key
|
||||
* @param score
|
||||
* @param value
|
||||
* @return
|
||||
* @param key 键
|
||||
* @param score 分数
|
||||
* @param value 值
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean zadd(String key, long score, String value) {
|
||||
return redisTemplate.opsForZSet().add(key, value, score);
|
||||
@@ -225,10 +225,10 @@ public class RedisUtil {
|
||||
/**
|
||||
* 获取 某key 下 某一分值区间的队列
|
||||
*
|
||||
* @param key
|
||||
* @param from
|
||||
* @param to
|
||||
* @return
|
||||
* @param key 键
|
||||
* @param from 起始位置
|
||||
* @param to 结束为止
|
||||
* @return 符合条件的结果集
|
||||
*/
|
||||
public Set<DefaultTypedTuple> zrangeByScoreWithScores(String key, int from, long to) {
|
||||
Set<DefaultTypedTuple> set = redisTemplate.opsForZSet().rangeByScoreWithScores(key, from, to);
|
||||
@@ -238,9 +238,9 @@ public class RedisUtil {
|
||||
/**
|
||||
* 移除 Zset队列值
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
* @param key 键
|
||||
* @param value 值集合
|
||||
* @return 移除数量
|
||||
*/
|
||||
public Long zremove(String key, String... value) {
|
||||
return redisTemplate.opsForZSet().remove(key, value);
|
||||
@@ -1,101 +0,0 @@
|
||||
package cn.lili.common.cache;
|
||||
|
||||
import cn.lili.common.utils.SpringContextUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.cache.Cache;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* MybatisRedisCache
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since
|
||||
* 2020-04-01 2:59 下午
|
||||
* 不赞成使用此方式注解,统一使用Cacheable 更为合适
|
||||
*
|
||||
* 使用方法 @CacheNamespace(implementation= MybatisRedisCache.class,eviction=MybatisRedisCache.class)
|
||||
*/
|
||||
@Deprecated
|
||||
@Slf4j
|
||||
public class MybatisRedisCache implements Cache {
|
||||
|
||||
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(true);
|
||||
|
||||
|
||||
private RedisTemplate<Object, Object> getRedisTemplate() {
|
||||
return (RedisTemplate<Object, Object>) SpringContextUtil.getBean("redisTemplate");
|
||||
}
|
||||
|
||||
private final String id;
|
||||
|
||||
public MybatisRedisCache(final String id) {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("Cache instances require an ID");
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putObject(Object key, Object value) {
|
||||
try {
|
||||
if (value != null) {
|
||||
log.info("写入缓存:" + key.toString()+"----"+value.toString());
|
||||
getRedisTemplate().opsForValue().set(key.toString(), value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("写入mybatis缓存异常 ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(Object key) {
|
||||
try {
|
||||
if (key != null) {
|
||||
log.info("获取缓存:" + key);
|
||||
return getRedisTemplate().opsForValue().get(key.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("mybatis缓存获取异常 ", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object removeObject(Object key) {
|
||||
if (key != null) {
|
||||
getRedisTemplate().delete(key.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
Set<Object> keys = getRedisTemplate().keys("*:" + this.id + "*");
|
||||
if (!CollectionUtils.isEmpty(keys)) {
|
||||
getRedisTemplate().delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
Long size = getRedisTemplate().execute(RedisServerCommands::dbSize);
|
||||
return size.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadWriteLock getReadWriteLock() {
|
||||
return this.readWriteLock;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.context;
|
||||
package cn.lili.common.context;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.context;
|
||||
package cn.lili.common.context;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.context;
|
||||
package cn.lili.common.context;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
@@ -12,7 +12,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/12/9 10:44
|
||||
*/
|
||||
public class ThreadContextHolderInterceptorAdapter extends HandlerInterceptorAdapter {
|
||||
@@ -21,11 +20,11 @@ public class ThreadContextHolderInterceptorAdapter extends HandlerInterceptorAda
|
||||
/**
|
||||
* 拦截request和response并放到上下文中
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @param request 请求
|
||||
* @param response 响应
|
||||
* @param handler 处理程序
|
||||
* @return 处理结果
|
||||
* @throws Exception 未知异常
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
@@ -41,11 +40,11 @@ public class ThreadContextHolderInterceptorAdapter extends HandlerInterceptorAda
|
||||
/**
|
||||
* 从上下文中移除 request 和response
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @param ex
|
||||
* @throws Exception
|
||||
* @param request 请求
|
||||
* @param response 响应
|
||||
* @param handler 处理程序
|
||||
* @param ex 异常
|
||||
* @throws Exception 完成之前处理异常
|
||||
*/
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.config.interceptor;
|
||||
package cn.lili.common.context.interceptor;
|
||||
|
||||
import cn.lili.config.context.ThreadContextHolder;
|
||||
import cn.lili.common.context.ThreadContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.config.interceptor;
|
||||
package cn.lili.common.context.interceptor;
|
||||
|
||||
import cn.lili.config.properties.IgnoredUrlsProperties;
|
||||
import cn.lili.common.properties.IgnoredUrlsProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||
@@ -32,7 +32,8 @@ public class UrlConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 开放资源 这里配置swagger可以在前端访问
|
||||
* @param registry
|
||||
*
|
||||
* @param registry 资源处理
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
@@ -5,7 +5,7 @@ package cn.lili.common.enums;
|
||||
* 客户端类型
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/12/8 9:46
|
||||
* @since 2020/12/8 9:46
|
||||
*/
|
||||
|
||||
public enum ClientTypeEnum {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package cn.lili.modules.promotion.entity.enums;
|
||||
package cn.lili.common.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 促销分类枚举
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2021/2/1 19:32
|
||||
* @since 2021/2/1 19:32
|
||||
*/
|
||||
public enum PromotionTypeEnum {
|
||||
/**
|
||||
@@ -5,7 +5,7 @@ package cn.lili.common.enums;
|
||||
* 第一位 1:商品;2:用户;3:交易,4:促销,5:店铺,6:页面,7:设置,8:其他
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/4/8 1:36 下午
|
||||
* @since 2020/4/8 1:36 下午
|
||||
*/
|
||||
public enum ResultCode {
|
||||
|
||||
@@ -201,6 +201,7 @@ public enum ResultCode {
|
||||
AFTER_SALES_LOGISTICS_ERROR(33005, "物流公司错误,请重新选择"),
|
||||
AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"),
|
||||
RETURN_MONEY_OFFLINE_BANK_ERROR(33007, "当账号类型为银行转账时,银行信息不能为空"),
|
||||
AFTER_SALES_PRICE_ERROR(33004, "申请退款金额错误"),
|
||||
|
||||
/**
|
||||
* 投诉
|
||||
@@ -219,6 +220,7 @@ public enum ResultCode {
|
||||
WALLET_NOT_EXIT_ERROR(34000, "钱包不存在,请联系管理员"),
|
||||
WALLET_INSUFFICIENT(34001, "余额不足以支付订单,请充值!"),
|
||||
WALLET_WITHDRAWAL_INSUFFICIENT(34002, "可提现金额不足!"),
|
||||
WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT(34006, "冻结金额不足,无法处理提现申请请求!"),
|
||||
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
|
||||
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
|
||||
WALLET_APPLY_ERROR(34005, "提现申请异常!"),
|
||||
@@ -246,11 +248,12 @@ public enum ResultCode {
|
||||
/**
|
||||
* 优惠券
|
||||
*/
|
||||
COUPON_LIMIT_ERROR(41000, "超出领取限制"),
|
||||
COUPON_EDIT_STATUS_SUCCESS(41001, "修改状态成功!"),
|
||||
COUPON_CANCELLATION_SUCCESS(41002, "会员优惠券作废成功"),
|
||||
COUPON_EXPIRED(41003, "优惠券已使用/已过期,不能使用"),
|
||||
COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"),
|
||||
COUPON_RECEIVE_ERROR(41005, "当前优惠券状态不可领取"),
|
||||
COUPON_RECEIVE_ERROR(41005, "当前优惠券已经被领取完了,下次要早点来哦"),
|
||||
COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"),
|
||||
COUPON_NOT_EXIST(41007, "当前优惠券不存在"),
|
||||
COUPON_LIMIT_NUM_LESS_THAN_0(41008, "领取限制数量不能为负数"),
|
||||
|
||||
@@ -33,8 +33,8 @@ public class ResultUtil<T> {
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
* @param t 范型
|
||||
* @return 消息
|
||||
*/
|
||||
public ResultMessage<T> setData(T t) {
|
||||
this.resultMessage.setResult(t);
|
||||
@@ -58,9 +58,9 @@ public class ResultUtil<T> {
|
||||
|
||||
/**
|
||||
* 抽象静态方法,返回结果集
|
||||
* @param t
|
||||
* @param <T>
|
||||
* @return
|
||||
* @param t 范型
|
||||
* @param <T> 范型
|
||||
* @return 消息
|
||||
*/
|
||||
public static <T> ResultMessage<T> data(T t) {
|
||||
return new ResultUtil<T>().setData(t);
|
||||
@@ -70,6 +70,7 @@ public class ResultUtil<T> {
|
||||
* 返回成功
|
||||
*
|
||||
* @param resultCode 返回状态码
|
||||
* @return 消息
|
||||
*/
|
||||
public static <T> ResultMessage<T> success(ResultCode resultCode) {
|
||||
return new ResultUtil<T>().setSuccessMsg(resultCode);
|
||||
@@ -77,6 +78,7 @@ public class ResultUtil<T> {
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
* @return 消息
|
||||
*/
|
||||
public static <T> ResultMessage<T> success() {
|
||||
return new ResultUtil<T>().setSuccessMsg(ResultCode.SUCCESS);
|
||||
@@ -86,6 +88,7 @@ public class ResultUtil<T> {
|
||||
* 返回失败
|
||||
*
|
||||
* @param resultCode 返回状态码
|
||||
* @return 消息
|
||||
*/
|
||||
public static <T> ResultMessage<T> error(ResultCode resultCode) {
|
||||
return new ResultUtil<T>().setErrorMsg(resultCode);
|
||||
@@ -96,6 +99,7 @@ public class ResultUtil<T> {
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回消息
|
||||
* @return 消息
|
||||
*/
|
||||
public static <T> ResultMessage<T> error(Integer code, String msg) {
|
||||
return new ResultUtil<T>().setErrorMsg(code, msg);
|
||||
@@ -103,8 +107,8 @@ public class ResultUtil<T> {
|
||||
|
||||
/**
|
||||
* 服务器异常 追加状态码
|
||||
*
|
||||
* @param resultCode 返回码
|
||||
* @return 消息
|
||||
*/
|
||||
public ResultMessage<T> setErrorMsg(ResultCode resultCode) {
|
||||
this.resultMessage.setSuccess(false);
|
||||
@@ -118,6 +122,7 @@ public class ResultUtil<T> {
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回消息
|
||||
* @return 消息
|
||||
*/
|
||||
public ResultMessage<T> setErrorMsg(Integer code, String msg) {
|
||||
this.resultMessage.setSuccess(false);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ServiceException extends RuntimeException {
|
||||
private ResultCode resultCode;
|
||||
|
||||
public ServiceException(String msg) {
|
||||
super(msg);
|
||||
this.resultCode = ResultCode.ERROR;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.rocketmq;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lili.sms")
|
||||
public class SmsTemplateSetting {
|
||||
public class SmsTemplateProperties {
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -9,7 +9,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2021/2/21 10:19
|
||||
*/
|
||||
@Data
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lili.system")
|
||||
public class SystemSetting {
|
||||
public class SystemSettingProperties {
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.properties;
|
||||
package cn.lili.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -1,36 +0,0 @@
|
||||
package cn.lili.common.security.context;
|
||||
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 获取用户信息 处理
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/14 20:35
|
||||
*/
|
||||
@Component
|
||||
public class AuthenticationHandler {
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AuthUser getAuthUser() {
|
||||
//获取spring security 权限信息,如果token有权限,在这里就会得到内容
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
Object object = authentication.getDetails();
|
||||
if (object instanceof AuthUser) {
|
||||
return (AuthUser) authentication.getDetails();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package cn.lili.common.security.context;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.enums.SecurityEnum;
|
||||
import cn.lili.common.token.SecretKeyUtil;
|
||||
import cn.lili.common.security.token.SecretKeyUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
@@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/14 20:27
|
||||
*/
|
||||
public class UserContext {
|
||||
@@ -27,7 +26,7 @@ public class UserContext {
|
||||
/**
|
||||
* 根据request获取用户信息
|
||||
*
|
||||
* @return
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static AuthUser getCurrentUser() {
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
@@ -44,7 +43,7 @@ public class UserContext {
|
||||
*
|
||||
* @param cache 缓存
|
||||
* @param accessToken token
|
||||
* @return
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static AuthUser getAuthUser(Cache cache, String accessToken) {
|
||||
try {
|
||||
@@ -61,7 +60,7 @@ public class UserContext {
|
||||
* 根据jwt获取token重的用户信息
|
||||
*
|
||||
* @param accessToken token
|
||||
* @return
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static AuthUser getAuthUser(String accessToken) {
|
||||
try {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package cn.lili.common.security.context;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 给予用户上下文,初始化参数
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/14 20:30
|
||||
*/
|
||||
@Component
|
||||
public class UserContextInit implements ApplicationRunner {
|
||||
|
||||
/**
|
||||
* 用户信息holder,认证信息的获取者
|
||||
*/
|
||||
@Autowired
|
||||
private AuthenticationHandler authenticationHandler;
|
||||
|
||||
/**
|
||||
* 在项目加载时指定认证信息获取者
|
||||
* 默认是由spring 安全上下文中获取
|
||||
*
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
//UserContext.setHolder(authenticationHandler);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package cn.lili.common.token;
|
||||
package cn.lili.common.security.enums;
|
||||
|
||||
/**
|
||||
* 权限枚举值
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/25 09:21
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,6 @@ package cn.lili.common.security.enums;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @Description:
|
||||
* @since 2020/8/18 15:23
|
||||
*/
|
||||
public enum UserEnums {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.token;
|
||||
package cn.lili.common.security.token;
|
||||
|
||||
import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
|
||||
import io.jsonwebtoken.io.Decoders;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.token;
|
||||
package cn.lili.common.security.token;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package cn.lili.common.token;
|
||||
package cn.lili.common.security.token;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.enums.SecurityEnum;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.config.properties.JWTTokenProperties;
|
||||
import cn.lili.common.properties.JWTTokenProperties;
|
||||
import com.google.gson.Gson;
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.security.SignatureException;
|
||||
@@ -37,7 +37,8 @@ public class TokenUtil {
|
||||
* @param username 主体
|
||||
* @param claim 私有声明
|
||||
* @param longTerm 长时间特殊token 如:移动端,微信小程序等
|
||||
* @return
|
||||
* @param userEnums 用户枚举
|
||||
* @return TOKEN
|
||||
*/
|
||||
public Token createToken(String username, Object claim, boolean longTerm, UserEnums userEnums) {
|
||||
Token token = new Token();
|
||||
@@ -61,6 +62,7 @@ public class TokenUtil {
|
||||
* 刷新token
|
||||
*
|
||||
* @param oldRefreshToken 刷新token
|
||||
* @param userEnums 用户枚举
|
||||
* @return token
|
||||
*/
|
||||
public Token refreshToken(String oldRefreshToken, UserEnums userEnums) {
|
||||
@@ -118,7 +120,7 @@ public class TokenUtil {
|
||||
* @param username 主体
|
||||
* @param claim 私有神明内容
|
||||
* @param expirationTime 过期时间(分钟)
|
||||
* @return
|
||||
* @return token字符串
|
||||
*/
|
||||
private String createToken(String username, Object claim, Long expirationTime) {
|
||||
//JWT 生成
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.common.token.base;
|
||||
package cn.lili.common.security.token.base;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.security.token.Token;
|
||||
|
||||
/**
|
||||
* AbstractToken
|
||||
@@ -18,7 +18,7 @@ public abstract class AbstractTokenGenerate {
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param longTerm 是否长时间有效
|
||||
* @return
|
||||
* @return TOKEN对象
|
||||
*/
|
||||
public abstract Token createToken(String username, Boolean longTerm);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.swagger;
|
||||
package cn.lili.common.swagger;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -1,36 +0,0 @@
|
||||
package cn.lili.common.test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.test.context.TestExecutionListener;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* BaseTest
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since
|
||||
* 2020-06-13 12:17
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Rollback()
|
||||
@ContextConfiguration
|
||||
@Configuration
|
||||
@ComponentScan("cn.lili")
|
||||
public class BaseTest implements TestExecutionListener {
|
||||
@Override
|
||||
public void beforeTestClass(TestContext testContext) throws Exception {
|
||||
//设置环境变量 解决es冲突
|
||||
System.setProperty("es.set.netty.runtime.available.processors", "false");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.config.thread;
|
||||
package cn.lili.common.thread;
|
||||
|
||||
import cn.lili.config.properties.ThreadProperties;
|
||||
import cn.lili.common.properties.ThreadProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
@@ -1,9 +1,5 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -236,29 +232,4 @@ public class Base64Utils {
|
||||
return new String(data, charset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 二进制流转Base64字符串
|
||||
*
|
||||
* @param data 二进制流
|
||||
* @return data
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
public static String getImageString(byte[] data) throws IOException {
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
return data != null ? encoder.encode(data) : "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Base64字符串转 二进制流
|
||||
*
|
||||
* @param base64String Base64
|
||||
* @return base64String
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
public static byte[] getStringImage(String base64String) throws IOException {
|
||||
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
|
||||
return base64String != null ? decoder.decodeBuffer(base64String) : null;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ public class BeanUtil {
|
||||
/**
|
||||
* 复制属性
|
||||
*
|
||||
* @param objectFrom
|
||||
* @param objectTo
|
||||
* @param objectFrom 源自对象
|
||||
* @param objectTo 复制给对象
|
||||
*/
|
||||
public static void copyProperties(Object objectFrom, Object objectTo) {
|
||||
BeanUtils.copyProperties(objectFrom, objectTo);
|
||||
@@ -25,6 +25,8 @@ public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 获取属性名数组
|
||||
* @param o 获取字段的对象
|
||||
* @return 返回各个字段
|
||||
*/
|
||||
public static String[] getFiledName(Object o) {
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
@@ -67,6 +69,8 @@ public class BeanUtil {
|
||||
/**
|
||||
* 将对象转换为key value
|
||||
* A=a&B=b&C=c 格式
|
||||
* @param object 对象
|
||||
* @return 格式化结果
|
||||
*/
|
||||
public static String formatKeyValuePair(Object object) {
|
||||
//准备接受的字符串
|
||||
@@ -91,6 +95,10 @@ public class BeanUtil {
|
||||
/**
|
||||
* key value键值对 转换为 对象
|
||||
* A=a&B=b&C=c 格式 转换为对象
|
||||
* @param str 对象字符串
|
||||
* @param t 范型
|
||||
* @param <T> 范型
|
||||
* @return 格式化结果
|
||||
*/
|
||||
public static <T> T formatKeyValuePair(String str, T t) {
|
||||
//填写对参数键值对
|
||||
|
||||
@@ -11,8 +11,8 @@ public class CommonUtil {
|
||||
|
||||
/**
|
||||
* 以UUID重命名
|
||||
* @param fileName
|
||||
* @return
|
||||
* @param fileName 文件名称
|
||||
* @return 格式化名称
|
||||
*/
|
||||
public static String rename(String fileName) {
|
||||
String extName = fileName.substring(fileName.lastIndexOf("."));
|
||||
@@ -32,20 +32,4 @@ public class CommonUtil {
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量递归删除时 判断target是否在ids中 避免重复删除
|
||||
* @param target
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public static Boolean judgeIds(String target, String[] ids){
|
||||
Boolean flag = false;
|
||||
for(String id : ids){
|
||||
if(id.equals(target)){
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.math.BigDecimal;
|
||||
* 金额计算工具
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
* @since: 2021/7/9 1:40 上午
|
||||
*/
|
||||
public final class CurrencyUtil {
|
||||
/**
|
||||
@@ -130,8 +130,8 @@ public final class CurrencyUtil {
|
||||
/**
|
||||
* 金额转分
|
||||
*
|
||||
* @param money
|
||||
* @return
|
||||
* @param money 金额
|
||||
* @return 转换单位为分
|
||||
*/
|
||||
public static Integer fen(Double money) {
|
||||
double price = mul(money, 100);
|
||||
@@ -141,15 +141,11 @@ public final class CurrencyUtil {
|
||||
/**
|
||||
* 金额转分
|
||||
*
|
||||
* @param money
|
||||
* @return
|
||||
* @param money 金额
|
||||
* @return double类型分
|
||||
*/
|
||||
public static double reversalFen(Double money) {
|
||||
double price = div(money, 100);
|
||||
return price;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(fen(23.4324));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DateUtil {
|
||||
/**
|
||||
* 当天的开始时间
|
||||
*
|
||||
* @return
|
||||
* @return 今天开始时间
|
||||
*/
|
||||
public static Date startOfTodDayTime() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@@ -36,8 +36,8 @@ public class DateUtil {
|
||||
|
||||
/**
|
||||
* 当天的开始时间
|
||||
*
|
||||
* @return
|
||||
* @param date 时间
|
||||
* @return 根据传入的时间获取开始时间
|
||||
*/
|
||||
public static Date startOfTodDayTime(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@@ -51,7 +51,7 @@ public class DateUtil {
|
||||
/**
|
||||
* 当天的开始时间
|
||||
*
|
||||
* @return
|
||||
* @return 今天开始时间
|
||||
*/
|
||||
public static long startOfTodDay() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@@ -63,14 +63,10 @@ public class DateUtil {
|
||||
return date.getTime() / 1000;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 当天的结束时间
|
||||
*
|
||||
* @return
|
||||
* @return 今天结束时间
|
||||
*/
|
||||
public static Date endOfDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@@ -83,8 +79,8 @@ public class DateUtil {
|
||||
|
||||
/**
|
||||
* 当天的结束时间
|
||||
*
|
||||
* @return
|
||||
* @param date 传入日期
|
||||
* @return 获得传入日期当天结束时间
|
||||
*/
|
||||
public static Date endOfDate(Date date) {
|
||||
if (date == null) {
|
||||
@@ -125,7 +121,7 @@ public class DateUtil {
|
||||
*
|
||||
* @param date 字符串日期
|
||||
* @param pattern 日期格式
|
||||
* @return
|
||||
* @return date
|
||||
*/
|
||||
public static Date toDate(String date, String pattern) {
|
||||
if ("".equals("" + date)) {
|
||||
@@ -148,7 +144,7 @@ public class DateUtil {
|
||||
/**
|
||||
* 获取上个月的开始结束时间
|
||||
*
|
||||
* @return
|
||||
* @return 上个月的开始结束时间
|
||||
*/
|
||||
public static Long[] getLastMonth() {
|
||||
//取得系统当前时间
|
||||
@@ -198,7 +194,7 @@ public class DateUtil {
|
||||
* 把日期转换成字符串型
|
||||
*
|
||||
* @param date 日期
|
||||
* @return
|
||||
* @return 字符串时间
|
||||
*/
|
||||
public static String toString(Date date) {
|
||||
return toString(date, STANDARD_FORMAT);
|
||||
@@ -207,8 +203,8 @@ public class DateUtil {
|
||||
/**
|
||||
* 把日期转换成字符串型
|
||||
*
|
||||
* @param Long 日期
|
||||
* @return
|
||||
* @param date 日期
|
||||
* @return 字符串时间
|
||||
*/
|
||||
public static String toString(Long date) {
|
||||
return toString(date, STANDARD_FORMAT);
|
||||
@@ -219,7 +215,7 @@ public class DateUtil {
|
||||
*
|
||||
* @param date 日期
|
||||
* @param pattern 类型
|
||||
* @return
|
||||
* @return 字符串时间
|
||||
*/
|
||||
public static String toString(Date date, String pattern) {
|
||||
if (date == null) {
|
||||
@@ -243,7 +239,7 @@ public class DateUtil {
|
||||
*
|
||||
* @param time 时间戳
|
||||
* @param pattern 格式
|
||||
* @return
|
||||
* @return 字符串时间
|
||||
*/
|
||||
public static String toString(Long time, String pattern) {
|
||||
if (time > 0) {
|
||||
@@ -251,8 +247,7 @@ public class DateUtil {
|
||||
time = time * 1000;
|
||||
}
|
||||
Date date = new Date(time);
|
||||
String str = DateUtil.toString(date, pattern);
|
||||
return str;
|
||||
return DateUtil.toString(date, pattern);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -321,7 +316,7 @@ public class DateUtil {
|
||||
* 获取几个月之前的日期时间戳
|
||||
*
|
||||
* @param beforeMonth 几个月之前
|
||||
* @return
|
||||
* @return 时间戳
|
||||
*/
|
||||
public static long getBeforeMonthDateline(int beforeMonth) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(STANDARD_FORMAT);
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 代理对象实例化
|
||||
* @author Chopper
|
||||
*/
|
||||
public class HibernateProxyTypeAdapter extends TypeAdapter<HibernateProxy> {
|
||||
|
||||
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
return (HibernateProxy.class.isAssignableFrom(type.getRawType()) ? (TypeAdapter<T>) new HibernateProxyTypeAdapter(gson) : null);
|
||||
}
|
||||
};
|
||||
private final Gson context;
|
||||
|
||||
private HibernateProxyTypeAdapter(Gson context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateProxy read(JsonReader in) throws IOException {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void write(JsonWriter out, HibernateProxy value) throws IOException {
|
||||
if (value == null) {
|
||||
out.nullValue();
|
||||
return;
|
||||
}
|
||||
//Retrieve the original (not proxy) class
|
||||
Class<?> baseType = Hibernate.getClass(value);
|
||||
//Get the TypeAdapter of the original class, to delegate the serialization
|
||||
TypeAdapter delegate = context.getAdapter(TypeToken.get(baseType));
|
||||
//Get a filled instance of the original class
|
||||
Object unproxiedValue = ((HibernateProxy) value).getHibernateLazyInitializer()
|
||||
.getImplementation();
|
||||
//Serialize the value
|
||||
delegate.write(out, unproxiedValue);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
* HttpClientUtils
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:40 上午
|
||||
* @since: 2021/7/9 1:40 上午
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpClientUtils {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
@@ -4,7 +4,6 @@ package cn.lili.common.utils;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.lili.modules.connect.util.IpUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,8 +39,8 @@ public class IpHelper {
|
||||
/**
|
||||
* 获取IP返回地理信息
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @param request 请求参数
|
||||
* @return 城市信息
|
||||
*/
|
||||
public String getIpCity(HttpServletRequest request) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -14,29 +14,32 @@ public class JasyptUtil {
|
||||
* Jasypt生成加密结果
|
||||
* @param password 配置文件中设定的加密密码 jasypt.encryptor.password
|
||||
* @param value 待加密值
|
||||
* @return
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encyptPwd(String password,String value){
|
||||
public static String encryptPwd(String password, String value){
|
||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||
encryptor.setConfig(cryptor(password));
|
||||
String result = encryptor.encrypt(value);
|
||||
return result;
|
||||
encryptor.setConfig(encryptor(password));
|
||||
return encryptor.encrypt(value);
|
||||
}
|
||||
/**
|
||||
* 解密
|
||||
* @param password 配置文件中设定的加密密码 jasypt.encryptor.password
|
||||
* @param value 待解密密文
|
||||
* @return
|
||||
* @return 揭秘字符串
|
||||
*/
|
||||
public static String decyptPwd(String password,String value){
|
||||
public static String decryptPwd(String password, String value){
|
||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||
encryptor.setConfig(cryptor(password));
|
||||
encryptor.setConfig(encryptor(password));
|
||||
encryptor.decrypt(value);
|
||||
String result = encryptor.decrypt(value);
|
||||
return result;
|
||||
return encryptor.decrypt(value);
|
||||
}
|
||||
|
||||
public static SimpleStringPBEConfig cryptor(String password){
|
||||
/**
|
||||
* 加密处理
|
||||
* @param password 密码
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static SimpleStringPBEConfig encryptor(String password){
|
||||
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
|
||||
config.setPassword(password);
|
||||
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
|
||||
@@ -52,8 +55,8 @@ public class JasyptUtil {
|
||||
public static void main(String[] args){
|
||||
|
||||
//加密 若修改了第一个参数加密password记得在配置文件同步修改
|
||||
System.out.println(encyptPwd("jasypt.encryptor.password","123456"));
|
||||
System.out.println(encryptPwd("jasypt.encryptor.password","123456"));
|
||||
//解密
|
||||
System.out.println(decyptPwd("jasypt.encryptor.password","PYVnAYh+j5C3jkMV1d+myj6JzDaUk7pcfTWUaYsvQdEVkuvIVf7Y0mOU9XkffxT8"));
|
||||
System.out.println(decryptPwd("jasypt.encryptor.password","PYVnAYh+j5C3jkMV1d+myj6JzDaUk7pcfTWUaYsvQdEVkuvIVf7Y0mOU9XkffxT8"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
@@ -10,7 +9,6 @@ import java.lang.reflect.Method;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -49,99 +47,6 @@ public class StringUtils extends StrUtil {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将object转为数字
|
||||
*
|
||||
* @param obj 需要转object的对象
|
||||
* @param checked 如果为true格式不正确抛出异常
|
||||
* @return
|
||||
*/
|
||||
public static int toInt(Object obj, boolean checked) {
|
||||
int value = 0;
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
value = Convert.toInt(obj.toString());
|
||||
} catch (Exception ex) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("整型数字格式不正确");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字串转为long,如果无空,则返回默认值
|
||||
*
|
||||
* @param str 要转换的数字字串
|
||||
* @param defaultValue 默认值
|
||||
* @return
|
||||
*/
|
||||
public static Long toLong(String str, Long defaultValue) {
|
||||
Long value = defaultValue;
|
||||
if (str == null || "".equals(str)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
value = Long.parseLong(str);
|
||||
} catch (Exception ex) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个object转为double 如果object 为 null 则返回0;
|
||||
*
|
||||
* @param obj 需要转成Double的对象
|
||||
* @param checked 如果为true格式不正确抛出异常
|
||||
* @return
|
||||
*/
|
||||
public static Double toDouble(Object obj, boolean checked) {
|
||||
Double value = 0d;
|
||||
if (obj == null) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("数字格式不正确");
|
||||
} else {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
try {
|
||||
value = Double.valueOf(obj.toString());
|
||||
} catch (Exception ex) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("数字格式不正确");
|
||||
} else {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字串转为Double,如果无空,则返回默认值
|
||||
*
|
||||
* @param str 要转换的数字字串
|
||||
* @param defaultValue 默认值
|
||||
* @return
|
||||
*/
|
||||
public static Double toDouble(String str, Double defaultValue) {
|
||||
Double value = defaultValue;
|
||||
if (str == null || "".equals(str)) {
|
||||
return 0d;
|
||||
}
|
||||
try {
|
||||
value = Double.valueOf(str);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机数
|
||||
*
|
||||
@@ -158,18 +63,6 @@ public class StringUtils extends StrUtil {
|
||||
return sRand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断一个数组是否为空,并且长度大于0
|
||||
*
|
||||
* @param list
|
||||
* @return true 不空/false 空
|
||||
*/
|
||||
public static boolean isNotEmpty(List list) {
|
||||
|
||||
return list != null && list.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切个字符串,如果超出长度则切割
|
||||
*
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.regex.Pattern;
|
||||
* 支持手机号+电话同时校验
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:41 上午
|
||||
* @since: 2021/7/9 1:41 上午
|
||||
*/
|
||||
public class MobileValidator implements ConstraintValidator<Mobile, String> {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
|
||||
* 手机号校验
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/7/9 1:42 上午
|
||||
* @since: 2021/7/9 1:42 上午
|
||||
*/
|
||||
public class PhoneValidator implements ConstraintValidator<Phone, String> {
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.io.Serializable;
|
||||
* 查询参数
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/26 14:43
|
||||
*/
|
||||
@Data
|
||||
public class PageVO implements Serializable {
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.io.Serializable;
|
||||
* 前后端交互VO
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/26 14:40
|
||||
*/
|
||||
@Data
|
||||
public class ResultMessage<T> implements Serializable {
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.Date;
|
||||
* 日期搜索参数
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/26 14:43
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.io.InputStream;
|
||||
* 序列化的input stream
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2021-03-25 16:32
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package cn.lili.config.websocket;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSocketMessageBroker
|
||||
public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
/**
|
||||
* 注册stomp端点
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
|
||||
//允许使用socketJs方式访问 即可通过http://IP:PORT/manager/ws来和服务端websocket连接
|
||||
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息代理
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
|
||||
//订阅Broker名称 user点对点 topic广播即群发
|
||||
registry.enableSimpleBroker("/user","/topic");
|
||||
//全局(客户端)使用的消息前缀
|
||||
registry.setApplicationDestinationPrefixes("/app");
|
||||
//点对点使用的前缀 无需配置 默认/user
|
||||
registry.setUserDestinationPrefix("/user");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.common.elasticsearch;
|
||||
package cn.lili.elasticsearch;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.lili.config.elasticsearch.ElasticsearchProperties;
|
||||
import cn.lili.elasticsearch.config.ElasticsearchProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
@@ -335,7 +335,7 @@ public abstract class BaseElasticsearchService {
|
||||
* @param index index名
|
||||
* @return boolean
|
||||
* @author fanxb
|
||||
* @date 2019/7/24 14:57
|
||||
* @since 2019/7/24 14:57
|
||||
*/
|
||||
public boolean indexExist(String index) {
|
||||
try {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.common.elasticsearch;
|
||||
package cn.lili.elasticsearch;
|
||||
|
||||
/**
|
||||
* elasticsearch 索引后缀
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.elasticsearch;
|
||||
package cn.lili.elasticsearch.config;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.config.elasticsearch;
|
||||
package cn.lili.elasticsearch.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -9,7 +9,6 @@ import cn.lili.modules.connect.exception.AuthException;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/12/4 12:17
|
||||
*/
|
||||
public interface ConnectAuth {
|
||||
|
||||
@@ -6,7 +6,6 @@ package cn.lili.modules.connect.config;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/12/4 14:10
|
||||
*/
|
||||
public enum ConnectAuthEnum implements ConnectAuth {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Connect implements Serializable {
|
||||
|
||||
@CreatedDate
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.connect.entity;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectConfigEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/12/4 23:48
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -5,7 +5,6 @@ package cn.lili.modules.connect.entity.enums;
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/25 18:20
|
||||
*/
|
||||
public enum ConnectEnum {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
@@ -12,7 +12,7 @@ import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.AuthChecker;
|
||||
import cn.lili.modules.connect.util.HttpUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.modules.connect.util.UuidUtils;
|
||||
import com.xkcoding.http.util.UrlUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
@@ -14,7 +14,7 @@ import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.GlobalAuthUtils;
|
||||
import cn.lili.modules.connect.util.HttpUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
@@ -11,7 +11,7 @@ import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.HttpUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
@@ -12,7 +12,7 @@ import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.GlobalAuthUtils;
|
||||
import cn.lili.modules.connect.util.HttpUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
@@ -13,8 +13,8 @@ import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.HttpUtils;
|
||||
import cn.lili.modules.connect.util.IpUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.IpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.connect.service;
|
||||
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.dto.WechatMPLoginParams;
|
||||
|
||||
@@ -2,17 +2,17 @@ package cn.lili.modules.connect.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.token.base.generate.MemberTokenGenerate;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.modules.member.token.MemberTokenGenerate;
|
||||
import cn.lili.common.utils.CookieUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.config.context.ThreadContextHolder;
|
||||
import cn.lili.common.context.ThreadContextHolder;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuth;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.config.properties.ApiProperties;
|
||||
import cn.lili.config.properties.DomainProperties;
|
||||
import cn.lili.common.properties.ApiProperties;
|
||||
import cn.lili.common.properties.DomainProperties;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
|
||||
import cn.lili.common.utils.Base64Utils;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.distribution.entity.dos;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.modules.distribution.entity.dto.DistributionApplyDTO;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum;
|
||||
@@ -19,7 +19,7 @@ import javax.validation.constraints.Size;
|
||||
* 分销员对象
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.distribution.entity.dos;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionCashStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
* 分销佣金
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@@ -48,7 +48,7 @@ public class DistributionCash extends BaseEntity {
|
||||
|
||||
@CreatedDate
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "支付时间")
|
||||
private Date payTime;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
* 分销商品
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@@ -56,7 +56,7 @@ public class DistributionGoods {
|
||||
|
||||
@CreatedDate
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Date;
|
||||
* 分销订单
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@@ -45,7 +45,7 @@ public class DistributionOrder {
|
||||
|
||||
@CreatedDate
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Date createTime;
|
||||
|
||||
@@ -17,7 +17,7 @@ import javax.persistence.Table;
|
||||
* 分销员已选择分销商品
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
|
||||
@@ -9,7 +9,7 @@ import javax.validation.constraints.Size;
|
||||
/**
|
||||
* 分销员申请DTO
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/6/30 11:07 上午
|
||||
* @since: 2021/6/30 11:07 上午
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
||||
* 分销员商品查询条件
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
public class DistributionGoodsSearchParams extends PageVO {
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
* 分销查询参数
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2021/3/20 10:13
|
||||
* @since 2021/3/20 10:13
|
||||
*/
|
||||
@Data
|
||||
public class DistributionSearchParams {
|
||||
|
||||
@@ -4,7 +4,7 @@ package cn.lili.modules.distribution.entity.enums;
|
||||
* 分销佣金状态
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
public enum DistributionCashStatusEnum {
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,6 @@ package cn.lili.modules.distribution.entity.enums;
|
||||
* 分销员订单状态
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
*/
|
||||
public enum DistributionOrderStatusEnum {
|
||||
//待结算(冻结)
|
||||
|
||||
@@ -4,7 +4,7 @@ package cn.lili.modules.distribution.entity.enums;
|
||||
* 分销员状态
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
public enum DistributionStatusEnum {
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import lombok.Data;
|
||||
* 分销佣金查询信息
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-26 09:04:53
|
||||
* @since 2020-03-26 09:04:53
|
||||
*/
|
||||
@Data
|
||||
public class DistributionCashSearchParams extends PageVO {
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Date;
|
||||
* 分销商品信息
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-26 09:04:53
|
||||
* @since 2020-03-26 09:04:53
|
||||
*/
|
||||
@Data
|
||||
public class DistributionGoodsVO {
|
||||
@@ -52,7 +52,7 @@ public class DistributionGoodsVO {
|
||||
private Double commission;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Date;
|
||||
* 分销员对象
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "分销订单查询对象")
|
||||
@@ -40,12 +40,12 @@ public class DistributionOrderSearchParams extends PageVO {
|
||||
private String storeId;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Date endTime;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* 分销佣金数据处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-26 18:45:56
|
||||
* @since 2020-03-26 18:45:56
|
||||
*/
|
||||
public interface DistributionCashMapper extends BaseMapper<DistributionCash> {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
* 分销商品数据处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-24 23:04:56
|
||||
* @since 2020-03-24 23:04:56
|
||||
*/
|
||||
public interface DistributionGoodsMapper extends BaseMapper<DistributionGoods> {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Update;
|
||||
* 分销员数据处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-14 23:04:56
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Update;
|
||||
* 分销订单数据处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-03-15 10:45:56
|
||||
* @since 2020-03-15 10:45:56
|
||||
*/
|
||||
public interface DistributionOrderMapper extends BaseMapper<DistributionOrder> {
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user