mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
🎨 Improving structure / format of the code.
This commit is contained in:
parent
7c886d6b3a
commit
78f056a179
@ -35,7 +35,6 @@ public class WebSecurityConfiguration {
|
||||
|
||||
/**
|
||||
* spring security 默认的安全策略
|
||||
*
|
||||
* @param http security注入点
|
||||
* @return SecurityFilterChain
|
||||
* @throws Exception
|
||||
@ -60,7 +59,6 @@ public class WebSecurityConfiguration {
|
||||
* 暴露静态资源
|
||||
* <p>
|
||||
* https://github.com/spring-projects/spring-security/issues/10938
|
||||
*
|
||||
* @param http
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
@ -24,34 +24,31 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 指定缓存失效时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param time 时间(秒)
|
||||
*/
|
||||
public boolean expire(String key, long time) {
|
||||
RedisTemplate<Object, Object> redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
||||
Optional.ofNullable(redisTemplate)
|
||||
.filter(template -> time > 0)
|
||||
.ifPresent(template -> template.expire(key, time, TimeUnit.SECONDS));
|
||||
.filter(template -> time > 0)
|
||||
.ifPresent(template -> template.expire(key, time, TimeUnit.SECONDS));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 key 获取过期时间
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @return 时间(秒) 返回0代表为永久有效
|
||||
*/
|
||||
public long getExpire(Object key) {
|
||||
RedisTemplate<Object, Object> redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
||||
return Optional.ofNullable(redisTemplate)
|
||||
.map(template -> template.getExpire(key, TimeUnit.SECONDS))
|
||||
.orElse(-1L);
|
||||
.map(template -> template.getExpire(key, TimeUnit.SECONDS))
|
||||
.orElse(-1L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找匹配key
|
||||
*
|
||||
* @param pattern key
|
||||
* @return /
|
||||
*/
|
||||
@ -73,10 +70,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 分页查询 key
|
||||
*
|
||||
* @param patternKey key
|
||||
* @param page 页码
|
||||
* @param size 每页数目
|
||||
* @param page 页码
|
||||
* @param size 每页数目
|
||||
* @return /
|
||||
*/
|
||||
public List<String> findKeysForPage(String patternKey, int page, int size) {
|
||||
@ -108,7 +104,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 判断key是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
@ -119,7 +114,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param keys 可以传一个值 或多个
|
||||
*/
|
||||
public void del(String... keys) {
|
||||
@ -131,24 +125,22 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获取锁
|
||||
*
|
||||
* @param lockKey 锁key
|
||||
* @param value value
|
||||
* @param lockKey 锁key
|
||||
* @param value value
|
||||
* @param expireTime:单位-秒
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getLock(String lockKey, String value, int expireTime) {
|
||||
RedisTemplate<Object, Object> redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
||||
return Optional.ofNullable(redisTemplate)
|
||||
.map(template -> template.opsForValue().setIfAbsent(lockKey, value, expireTime, TimeUnit.SECONDS))
|
||||
.orElse(false);
|
||||
.map(template -> template.opsForValue().setIfAbsent(lockKey, value, expireTime, TimeUnit.SECONDS))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放锁
|
||||
*
|
||||
* @param lockKey 锁key
|
||||
* @param value value
|
||||
* @param value value
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean releaseLock(String lockKey, String value) {
|
||||
@ -156,9 +148,9 @@ public class RedisUtils {
|
||||
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
|
||||
RedisScript<Long> redisScript = new DefaultRedisScript<>(script, Long.class);
|
||||
return Optional.ofNullable(redisTemplate.execute(redisScript, Collections.singletonList(lockKey), value))
|
||||
.map(Convert::toLong)
|
||||
.filter(SUCCESS::equals)
|
||||
.isPresent();
|
||||
.map(Convert::toLong)
|
||||
.filter(SUCCESS::equals)
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
// ============================String=============================
|
||||
@ -175,7 +167,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 批量获取
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@ -186,8 +177,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 普通缓存放入
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return true成功 false失败
|
||||
*/
|
||||
@ -202,10 +192,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 普通缓存放入并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||
* @return true成功 false 失败
|
||||
*/
|
||||
public boolean set(String key, Object value, long time) {
|
||||
@ -213,7 +202,7 @@ public class RedisUtils {
|
||||
return Optional.ofNullable(redisTemplate).map(template -> {
|
||||
if (time > 0) {
|
||||
template.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
} else {
|
||||
template.opsForValue().set(key, value);
|
||||
}
|
||||
return true;
|
||||
@ -222,10 +211,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 普通缓存放入并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间
|
||||
* @param timeUnit 类型
|
||||
* @return true成功 false 失败
|
||||
*/
|
||||
@ -234,7 +222,7 @@ public class RedisUtils {
|
||||
Optional.ofNullable(redisTemplate).map(template -> {
|
||||
if (time > 0) {
|
||||
template.opsForValue().set(key, value, time, timeUnit);
|
||||
} else {
|
||||
} else {
|
||||
template.opsForValue().set(key, value);
|
||||
}
|
||||
return true;
|
||||
@ -246,8 +234,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* HashGet
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param key 键 不能为null
|
||||
* @param hashKey 项 不能为null
|
||||
* @return 值
|
||||
*/
|
||||
@ -258,7 +245,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获取hashKey对应的所有键值
|
||||
*
|
||||
* @param key 键
|
||||
* @return 对应的多个键值
|
||||
*/
|
||||
@ -284,9 +270,8 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* HashSet 并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
* @param time 时间(秒)
|
||||
* @return true成功 false失败
|
||||
*/
|
||||
@ -319,11 +304,10 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 向一张hash表中放入数据,如果不存在将创建
|
||||
*
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param value 值
|
||||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public boolean hset(String key, String item, Object value, long time) {
|
||||
@ -339,8 +323,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 删除hash表中的值
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 可以使多个 不能为null
|
||||
*/
|
||||
public void hdel(String key, Object... item) {
|
||||
@ -350,8 +333,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 判断hash表中是否有该项的值
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 不能为null
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
@ -362,10 +344,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要增加几(大于0)
|
||||
* @param by 要增加几(大于0)
|
||||
* @return
|
||||
*/
|
||||
public double hincr(String key, String item, double by) {
|
||||
@ -375,10 +356,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* hash递减
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要减少记(小于0)
|
||||
* @param by 要减少记(小于0)
|
||||
* @return
|
||||
*/
|
||||
public double hdecr(String key, String item, double by) {
|
||||
@ -411,8 +391,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 将数据放入set缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param values 值 可以是多个
|
||||
* @return 成功个数
|
||||
*/
|
||||
@ -439,7 +418,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获取set缓存的长度
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
@ -462,7 +440,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获集合key1和集合key2的差集元素
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
@ -475,10 +452,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获取list缓存的内容
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param start 开始
|
||||
* @param end 结束 0 到 -1代表所有值
|
||||
* @param end 结束 0 到 -1代表所有值
|
||||
* @return
|
||||
*/
|
||||
public <T> List<T> lGet(String key, long start, long end) {
|
||||
@ -488,7 +464,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 获取list缓存的长度
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
@ -499,8 +474,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 通过索引 获取list中的值
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
|
||||
* @return
|
||||
*/
|
||||
@ -511,8 +485,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return
|
||||
*/
|
||||
@ -540,8 +513,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return
|
||||
*/
|
||||
@ -553,10 +525,9 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒)
|
||||
* @param time 时间(秒)
|
||||
* @return
|
||||
*/
|
||||
public boolean lSet(String key, List<Object> value, long time) {
|
||||
@ -570,8 +541,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 根据索引修改list中的某条数据
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param index 索引
|
||||
* @param value 值
|
||||
* @return /
|
||||
@ -584,8 +554,7 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 移除N个值为value
|
||||
*
|
||||
* @param key 键
|
||||
* @param key 键
|
||||
* @param count 移除多少个
|
||||
* @param value 值
|
||||
* @return 移除的个数
|
||||
@ -597,7 +566,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* 将zSet数据放入缓存
|
||||
*
|
||||
* @param key
|
||||
* @param time
|
||||
* @param tuples
|
||||
@ -615,7 +583,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* Sorted set:有序集合获取
|
||||
*
|
||||
* @param key
|
||||
* @param min
|
||||
* @param max
|
||||
@ -630,7 +597,6 @@ public class RedisUtils {
|
||||
|
||||
/**
|
||||
* Sorted set:有序集合获取 正序
|
||||
*
|
||||
* @param key
|
||||
* @param start
|
||||
* @param end
|
||||
|
@ -68,7 +68,6 @@ public class PigFeignAutoConfiguration {
|
||||
|
||||
/**
|
||||
* set connection close header
|
||||
*
|
||||
* @return RequestInterceptor
|
||||
*/
|
||||
@Bean
|
||||
|
@ -48,213 +48,213 @@ import java.util.Map;
|
||||
*/
|
||||
public class PigFeignClientsRegistrar implements ImportBeanDefinitionRegistrar, BeanClassLoaderAware, EnvironmentAware {
|
||||
|
||||
private final static String BASE_URL = "http://127.0.0.1:${server.port}${server.servlet.context-path}";
|
||||
private final static String BASE_URL = "http://127.0.0.1:${server.port}${server.servlet.context-path}";
|
||||
|
||||
@Getter
|
||||
private ClassLoader beanClassLoader;
|
||||
@Getter
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
@Getter
|
||||
private Environment environment;
|
||||
@Getter
|
||||
private Environment environment;
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
|
||||
registerFeignClients(registry);
|
||||
}
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
|
||||
registerFeignClients(registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
private void registerFeignClients(BeanDefinitionRegistry registry) {
|
||||
private void registerFeignClients(BeanDefinitionRegistry registry) {
|
||||
|
||||
List<String> feignClients = new ArrayList<>(
|
||||
SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()));
|
||||
List<String> feignClients = new ArrayList<>(
|
||||
SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()));
|
||||
|
||||
// 支持 springboot 2.7 + 最新版本的配置方式
|
||||
ImportCandidates.load(FeignClient.class, getBeanClassLoader()).forEach(feignClients::add);
|
||||
// 如果 spring.factories 里为空
|
||||
if (feignClients.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (String className : feignClients) {
|
||||
try {
|
||||
Class<?> clazz = beanClassLoader.loadClass(className);
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz,
|
||||
FeignClient.class);
|
||||
if (attributes == null) {
|
||||
continue;
|
||||
}
|
||||
// 支持 springboot 2.7 + 最新版本的配置方式
|
||||
ImportCandidates.load(FeignClient.class, getBeanClassLoader()).forEach(feignClients::add);
|
||||
// 如果 spring.factories 里为空
|
||||
if (feignClients.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (String className : feignClients) {
|
||||
try {
|
||||
Class<?> clazz = beanClassLoader.loadClass(className);
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz,
|
||||
FeignClient.class);
|
||||
if (attributes == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果是单体项目自动注入 & url 为空
|
||||
Boolean isMicro = environment.getProperty("spring.cloud.nacos.discovery.enabled", Boolean.class, true);
|
||||
// 如果已经存在该 bean,支持原生的 Feign
|
||||
if (registry.containsBeanDefinition(className) && isMicro) {
|
||||
continue;
|
||||
}
|
||||
// 如果是单体项目自动注入 & url 为空
|
||||
Boolean isMicro = environment.getProperty("spring.cloud.nacos.discovery.enabled", Boolean.class, true);
|
||||
// 如果已经存在该 bean,支持原生的 Feign
|
||||
if (registry.containsBeanDefinition(className) && isMicro) {
|
||||
continue;
|
||||
}
|
||||
|
||||
registerClientConfiguration(registry, getClientName(attributes), attributes.get("configuration"));
|
||||
registerClientConfiguration(registry, getClientName(attributes), attributes.get("configuration"));
|
||||
|
||||
validate(attributes);
|
||||
BeanDefinitionBuilder definition = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(FeignClientFactoryBean.class);
|
||||
definition.addPropertyValue("url", getUrl(registry, attributes));
|
||||
definition.addPropertyValue("path", getPath(attributes));
|
||||
String name = getName(attributes);
|
||||
definition.addPropertyValue("name", name);
|
||||
validate(attributes);
|
||||
BeanDefinitionBuilder definition = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(FeignClientFactoryBean.class);
|
||||
definition.addPropertyValue("url", getUrl(registry, attributes));
|
||||
definition.addPropertyValue("path", getPath(attributes));
|
||||
String name = getName(attributes);
|
||||
definition.addPropertyValue("name", name);
|
||||
|
||||
// 兼容最新版本的 spring-cloud-openfeign,尚未发布
|
||||
StringBuilder aliasBuilder = new StringBuilder(18);
|
||||
if (attributes.containsKey("contextId")) {
|
||||
String contextId = getContextId(attributes);
|
||||
aliasBuilder.append(contextId);
|
||||
definition.addPropertyValue("contextId", contextId);
|
||||
} else {
|
||||
aliasBuilder.append(name);
|
||||
}
|
||||
// 兼容最新版本的 spring-cloud-openfeign,尚未发布
|
||||
StringBuilder aliasBuilder = new StringBuilder(18);
|
||||
if (attributes.containsKey("contextId")) {
|
||||
String contextId = getContextId(attributes);
|
||||
aliasBuilder.append(contextId);
|
||||
definition.addPropertyValue("contextId", contextId);
|
||||
} else {
|
||||
aliasBuilder.append(name);
|
||||
}
|
||||
|
||||
definition.addPropertyValue("type", className);
|
||||
definition.addPropertyValue("decode404", attributes.get("decode404"));
|
||||
definition.addPropertyValue("fallback", attributes.get("fallback"));
|
||||
definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory"));
|
||||
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
|
||||
definition.addPropertyValue("type", className);
|
||||
definition.addPropertyValue("decode404", attributes.get("decode404"));
|
||||
definition.addPropertyValue("fallback", attributes.get("fallback"));
|
||||
definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory"));
|
||||
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
|
||||
|
||||
AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();
|
||||
AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();
|
||||
|
||||
// alias
|
||||
String alias = aliasBuilder.append("FeignClient").toString();
|
||||
// alias
|
||||
String alias = aliasBuilder.append("FeignClient").toString();
|
||||
|
||||
// has a default, won't be null
|
||||
boolean primary = (Boolean) attributes.get("primary");
|
||||
// has a default, won't be null
|
||||
boolean primary = (Boolean) attributes.get("primary");
|
||||
|
||||
beanDefinition.setPrimary(primary);
|
||||
beanDefinition.setPrimary(primary);
|
||||
|
||||
String qualifier = getQualifier(attributes);
|
||||
if (StringUtils.hasText(qualifier)) {
|
||||
alias = qualifier;
|
||||
}
|
||||
String qualifier = getQualifier(attributes);
|
||||
if (StringUtils.hasText(qualifier)) {
|
||||
alias = qualifier;
|
||||
}
|
||||
|
||||
BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className,
|
||||
new String[]{alias});
|
||||
BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
|
||||
BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className,
|
||||
new String[]{alias});
|
||||
BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class used by {@link SpringFactoriesLoader} to load configuration
|
||||
* candidates.
|
||||
*
|
||||
* @return the factory class
|
||||
*/
|
||||
private Class<?> getSpringFactoriesLoaderFactoryClass() {
|
||||
return PigFeignAutoConfiguration.class;
|
||||
}
|
||||
/**
|
||||
* Return the class used by {@link SpringFactoriesLoader} to load configuration
|
||||
* candidates.
|
||||
*
|
||||
* @return the factory class
|
||||
*/
|
||||
private Class<?> getSpringFactoriesLoaderFactoryClass() {
|
||||
return PigFeignAutoConfiguration.class;
|
||||
}
|
||||
|
||||
private void validate(Map<String, Object> attributes) {
|
||||
AnnotationAttributes annotation = AnnotationAttributes.fromMap(attributes);
|
||||
// This blows up if an aliased property is overspecified
|
||||
FeignClientsRegistrar.validateFallback(annotation.getClass("fallback"));
|
||||
FeignClientsRegistrar.validateFallbackFactory(annotation.getClass("fallbackFactory"));
|
||||
}
|
||||
private void validate(Map<String, Object> attributes) {
|
||||
AnnotationAttributes annotation = AnnotationAttributes.fromMap(attributes);
|
||||
// This blows up if an aliased property is overspecified
|
||||
FeignClientsRegistrar.validateFallback(annotation.getClass("fallback"));
|
||||
FeignClientsRegistrar.validateFallbackFactory(annotation.getClass("fallbackFactory"));
|
||||
}
|
||||
|
||||
private String getName(Map<String, Object> attributes) {
|
||||
String name = (String) attributes.get("serviceId");
|
||||
if (!StringUtils.hasText(name)) {
|
||||
name = (String) attributes.get("name");
|
||||
}
|
||||
if (!StringUtils.hasText(name)) {
|
||||
name = (String) attributes.get("value");
|
||||
}
|
||||
name = resolve(name);
|
||||
return FeignClientsRegistrar.getName(name);
|
||||
}
|
||||
private String getName(Map<String, Object> attributes) {
|
||||
String name = (String) attributes.get("serviceId");
|
||||
if (!StringUtils.hasText(name)) {
|
||||
name = (String) attributes.get("name");
|
||||
}
|
||||
if (!StringUtils.hasText(name)) {
|
||||
name = (String) attributes.get("value");
|
||||
}
|
||||
name = resolve(name);
|
||||
return FeignClientsRegistrar.getName(name);
|
||||
}
|
||||
|
||||
private String getContextId(Map<String, Object> attributes) {
|
||||
String contextId = (String) attributes.get("contextId");
|
||||
if (!StringUtils.hasText(contextId)) {
|
||||
return getName(attributes);
|
||||
}
|
||||
private String getContextId(Map<String, Object> attributes) {
|
||||
String contextId = (String) attributes.get("contextId");
|
||||
if (!StringUtils.hasText(contextId)) {
|
||||
return getName(attributes);
|
||||
}
|
||||
|
||||
contextId = resolve(contextId);
|
||||
return FeignClientsRegistrar.getName(contextId);
|
||||
}
|
||||
contextId = resolve(contextId);
|
||||
return FeignClientsRegistrar.getName(contextId);
|
||||
}
|
||||
|
||||
private String resolve(String value) {
|
||||
if (StringUtils.hasText(value)) {
|
||||
return this.environment.resolvePlaceholders(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
private String resolve(String value) {
|
||||
if (StringUtils.hasText(value)) {
|
||||
return this.environment.resolvePlaceholders(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String getUrl(BeanDefinitionRegistry registry, Map<String, Object> attributes) {
|
||||
private String getUrl(BeanDefinitionRegistry registry, Map<String, Object> attributes) {
|
||||
|
||||
// 如果是单体项目自动注入 & url 为空
|
||||
Boolean isMicro = environment.getProperty("spring.cloud.nacos.discovery.enabled", Boolean.class, true);
|
||||
// 如果是单体项目自动注入 & url 为空
|
||||
Boolean isMicro = environment.getProperty("spring.cloud.nacos.discovery.enabled", Boolean.class, true);
|
||||
|
||||
if (isMicro) {
|
||||
return null;
|
||||
}
|
||||
if (isMicro) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String url = resolve(BASE_URL);
|
||||
String url = resolve(BASE_URL);
|
||||
|
||||
return FeignClientsRegistrar.getUrl(url);
|
||||
}
|
||||
return FeignClientsRegistrar.getUrl(url);
|
||||
}
|
||||
|
||||
private String getPath(Map<String, Object> attributes) {
|
||||
String path = resolve((String) attributes.get("path"));
|
||||
return FeignClientsRegistrar.getPath(path);
|
||||
}
|
||||
private String getPath(Map<String, Object> attributes) {
|
||||
String path = resolve((String) attributes.get("path"));
|
||||
return FeignClientsRegistrar.getPath(path);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getQualifier(@Nullable Map<String, Object> client) {
|
||||
if (client == null) {
|
||||
return null;
|
||||
}
|
||||
String qualifier = (String) client.get("qualifier");
|
||||
if (StringUtils.hasText(qualifier)) {
|
||||
return qualifier;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
private String getQualifier(@Nullable Map<String, Object> client) {
|
||||
if (client == null) {
|
||||
return null;
|
||||
}
|
||||
String qualifier = (String) client.get("qualifier");
|
||||
if (StringUtils.hasText(qualifier)) {
|
||||
return qualifier;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getClientName(@Nullable Map<String, Object> client) {
|
||||
if (client == null) {
|
||||
return null;
|
||||
}
|
||||
String value = (String) client.get("contextId");
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("value");
|
||||
}
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("name");
|
||||
}
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("serviceId");
|
||||
}
|
||||
if (StringUtils.hasText(value)) {
|
||||
return value;
|
||||
}
|
||||
@Nullable
|
||||
private String getClientName(@Nullable Map<String, Object> client) {
|
||||
if (client == null) {
|
||||
return null;
|
||||
}
|
||||
String value = (String) client.get("contextId");
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("value");
|
||||
}
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("name");
|
||||
}
|
||||
if (!StringUtils.hasText(value)) {
|
||||
value = (String) client.get("serviceId");
|
||||
}
|
||||
if (StringUtils.hasText(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
throw new IllegalStateException(
|
||||
"Either 'name' or 'value' must be provided in @" + FeignClient.class.getSimpleName());
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"Either 'name' or 'value' must be provided in @" + FeignClient.class.getSimpleName());
|
||||
}
|
||||
|
||||
private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object configuration) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class);
|
||||
builder.addConstructorArgValue(name);
|
||||
builder.addConstructorArgValue(configuration);
|
||||
registry.registerBeanDefinition(name + "." + FeignClientSpecification.class.getSimpleName(),
|
||||
builder.getBeanDefinition());
|
||||
}
|
||||
private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object configuration) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class);
|
||||
builder.addConstructorArgValue(name);
|
||||
builder.addConstructorArgValue(configuration);
|
||||
registry.registerBeanDefinition(name + "." + FeignClientSpecification.class.getSimpleName(),
|
||||
builder.getBeanDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class SqlFilterArgumentResolver implements HandlerMethodArgumentResolver
|
||||
.ifPresent(s -> orderItemList.addAll(Arrays.stream(s)
|
||||
.filter(desc -> !SqlInjectionUtils.check(desc))
|
||||
.map(OrderItem::desc)
|
||||
.collect(Collectors.toList())));
|
||||
.collect(Collectors.toList())));
|
||||
page.addOrder(orderItemList);
|
||||
|
||||
return page;
|
||||
|
@ -100,7 +100,7 @@ public class SysLogController {
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('sys_log_export')")
|
||||
public List<SysLog> export(SysLogDTO sysLog) {
|
||||
public List<SysLog> export(SysLogDTO sysLog) {
|
||||
return sysLogService.getList(sysLog);
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,9 @@ public interface SysLogService extends IService<SysLog> {
|
||||
|
||||
/**
|
||||
* 查询日志列表
|
||||
*
|
||||
* @param sysLog 查询条件
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
List<SysLog> getList(SysLogDTO sysLog);
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
|
||||
/**
|
||||
* 插入日志
|
||||
*
|
||||
* @param sysLog 日志对象
|
||||
* @return true/false
|
||||
*/
|
||||
@ -65,7 +64,6 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
|
||||
/**
|
||||
* 查询日志列表
|
||||
*
|
||||
* @param sysLog 查询条件
|
||||
* @return List<SysLog>
|
||||
*/
|
||||
@ -76,7 +74,6 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*
|
||||
* @param sysLog 前端条件
|
||||
* @return LambdaQueryWrapper
|
||||
*/
|
||||
@ -88,7 +85,7 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
|
||||
if (ArrayUtil.isNotEmpty(sysLog.getCreateTime())) {
|
||||
wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTime()[0])
|
||||
.le(SysLog::getCreateTime, sysLog.getCreateTime()[1]);
|
||||
.le(SysLog::getCreateTime, sysLog.getCreateTime()[1]);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
|
@ -445,9 +445,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
public R checkPassword(String password) {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
SysUser condition = new SysUser();
|
||||
condition.setUsername(username);
|
||||
SysUser sysUser = this.getOne(new QueryWrapper<>(condition));
|
||||
SysUser condition = new SysUser();
|
||||
condition.setUsername(username);
|
||||
SysUser sysUser = this.getOne(new QueryWrapper<>(condition));
|
||||
|
||||
if (!ENCODER.matches(password, sysUser.getPassword())) {
|
||||
log.info("原密码错误");
|
||||
|
Loading…
Reference in New Issue
Block a user