Skip to content

Commit

Permalink
Merge pull request #9 from matevip/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
matevip authored Oct 7, 2020
2 parents fb99681 + e587210 commit 4ce2d1d
Show file tree
Hide file tree
Showing 77 changed files with 435 additions and 189 deletions.
2 changes: 1 addition & 1 deletion mate-core/mate-starter-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author pangu
*/
@Deprecated
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
* 验证用户是否授权
* @return String
*/
public String hasPerm() default "";
String hasPerm() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ public Object around(ProceedingJoinPoint point) throws Throwable {
return point.proceed();
}

if (!StringUtils.isEmpty(preAuth.hasPerm())) {
if (hasPerm(preAuth.hasPerm())) {
return point.proceed();
}
if (hasPerm(preAuth.hasPerm())) {
return point.proceed();
} else {
throw new TokenException("权限验证不通过");
}
return point.proceed();
}


Expand All @@ -78,10 +76,14 @@ public boolean hasPerm(String permission) {
return false;
}

if (!StringUtils.isEmpty(userInfo) && StringUtils.isEmpty(permission)) {
return true;
}

// 如果用户是超级管理员,则直接跳过权限验证
// if (userInfo.getAccount().equalsIgnoreCase(Oauth2Constant.SUPER_ADMIN)) {
// return true;
// }
if (userInfo.getAccount().equalsIgnoreCase(Oauth2Constant.SUPER_ADMIN)) {
return true;
}
Map<String, Object> data = (Map<String, Object>) redisService.get(Oauth2Constant.MATE_PERMISSION_PREFIX
+ userInfo.getAccount() + StringPool.DOT + userInfo.getRoleId());
List<String> authorities = (List<String>) data.get("permissions");
Expand All @@ -98,9 +100,5 @@ public boolean hasPerm(String permission) {
private boolean hasPermissions(Collection<String> authorities, String permission) {
return authorities.stream().filter(StringUtils::hasText)
.anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x));
// return PatternMatchUtils.simpleMatch(permission, authorities);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
* @author xuzhanfu
*/
@Deprecated
@Slf4j
@Aspect
@Component
Expand Down
6 changes: 5 additions & 1 deletion mate-core/mate-starter-cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -54,6 +54,10 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
</dependencies>


Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class MateConstant {
/**
* 应用版本号
*/
public static final String MATE_APP_VERSION = "1.2.8-SNAPSHOT";
public static final String MATE_APP_VERSION = "1.2.8";

/**
* Spring 应用名 prop key
Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
13 changes: 10 additions & 3 deletions mate-core/mate-starter-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

<groupId>vip.mate</groupId>
<artifactId>mate-starter-dependencies</artifactId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
<packaging>pom</packaging>
<description>MateCloud统一版本依赖</description>

<properties>
<matecloud.core.version>1.2.8-SNAPSHOT</matecloud.core.version>
<matecloud.core.version>1.2.8</matecloud.core.version>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>

<spring.boot.version>2.3.4.RELEASE</spring.boot.version>
Expand All @@ -35,7 +35,7 @@
<mysql.connector.version>8.0.17</mysql.connector.version>
<oracle.connector.version>12.2.0.1</oracle.connector.version>
<postgresql.connector.version>42.2.6</postgresql.connector.version>
<druid.version>1.1.24</druid.version>
<druid.version>1.2.1</druid.version>
<mybatis.plus.version>3.4.0</mybatis.plus.version>
<velocity.version>1.7</velocity.version>

Expand Down Expand Up @@ -76,6 +76,8 @@
<prometheus.version>1.5.5</prometheus.version>

<jasypt.version>3.0.3</jasypt.version>

<retrofit.version>2.1.8</retrofit.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -483,6 +485,11 @@
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>${jasypt.version}</version>
</dependency>
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>${retrofit.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-dozer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-dubbo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-feign/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-file/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-gray/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-jetcache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-job/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.hibernate.validator.internal.util.Version" level="off" />

<!--可以输出项目中的debug日志,包括mybatis的sql日志-->
<logger name="vip.mate.**.mapper" level="INFO" />
Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-mail/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-oss/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-prometheus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion mate-core/mate-starter-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mate-core</artifactId>
<groupId>vip.mate</groupId>
<version>1.2.8-SNAPSHOT</version>
<version>1.2.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,43 @@

/**
* Redis基础配置类
*
* @author pangu
*/
@Configuration
@EnableConfigurationProperties(MateRedisProperties.class)
@ConditionalOnProperty(value = MateRedisProperties.PREFIX + ".enabled", havingValue = "true", matchIfMissing = true)
public class RedisConfiguration {

@SuppressWarnings("all")
@Bean(name = "redisTemplate")
@ConditionalOnClass(RedisOperations.class)
public org.springframework.data.redis.core.RedisTemplate redisTemplate(RedisConnectionFactory factory) {
org.springframework.data.redis.core.RedisTemplate template = new org.springframework.data.redis.core.RedisTemplate();
template.setConnectionFactory(factory);
@SuppressWarnings("all")
@Bean(name = "redisTemplate")
@ConditionalOnClass(RedisOperations.class)
public org.springframework.data.redis.core.RedisTemplate redisTemplate(RedisConnectionFactory factory) {
org.springframework.data.redis.core.RedisTemplate template = new org.springframework.data.redis.core.RedisTemplate();
template.setConnectionFactory(factory);

Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.activateDefaultTyping(om.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.activateDefaultTyping(om.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);

StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
// key采用String的序列化方式
template.setKeySerializer(stringRedisSerializer);
// hash的key也采用String的序列化方式
template.setHashKeySerializer(stringRedisSerializer);
// value序列化方式采用jackson
template.setValueSerializer(jackson2JsonRedisSerializer);
// hash的value序列化方式采用jackson
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
// key采用String的序列化方式
template.setKeySerializer(stringRedisSerializer);
// hash的key也采用String的序列化方式
template.setHashKeySerializer(stringRedisSerializer);
// value序列化方式采用jackson
template.setValueSerializer(jackson2JsonRedisSerializer);
// hash的value序列化方式采用jackson
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}

@Bean
@ConditionalOnBean(name = "redisTemplate")
public RedisService redisService() {
return new RedisService();
}
@Bean
@ConditionalOnBean(name = "redisTemplate")
public RedisService redisService() {
return new RedisService();
}
}
10 changes: 10 additions & 0 deletions mate-core/mate-starter-retrofit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## mate-starter-retrofit

封装了链家出品的基于springboot上应用的retrofit-spring-boot-starter

## 框架开发背景
spring-boot项目中存在大量的http请求调用,然而当时调用都是通过HttpUtils或者RestTemplate实现的,说实话很麻烦,并且不利于统一管理。 因此当时就想通过Java接口的形式来统一搞定这件事。 由于不想引入spring-cloud相关依赖,当时就没有直接用feign,另外更重要的一点就是也想做的更加轻量,因此最终才写了这个框架

## 官方教程

https://github.com/LianjiaTech/retrofit-spring-boot-starter/blob/master/README_CN.md
Loading

0 comments on commit 4ce2d1d

Please sign in to comment.