新增资源服务和token,配置上下文
This commit is contained in:
parent
b56752436f
commit
e8dbdd18e2
79
pom.xml
79
pom.xml
@ -22,38 +22,49 @@
|
||||
<compler.maven.plugin.version>2.3.12.RELEASE</compler.maven.plugin.version>
|
||||
<!-- spring-cloud版本配置 -->
|
||||
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
|
||||
<spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>
|
||||
<!--lombok-->
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<jackson.version>2.13.3</jackson.version>
|
||||
|
||||
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
<jwt.version>0.11.1</jwt.version>
|
||||
<aliyun.version>4.5.0</aliyun.version>
|
||||
<jwt.version>0.11.5</jwt.version>
|
||||
|
||||
<spring-authorization-server.version>0.3.1</spring-authorization-server.version>
|
||||
<!-- feign-->
|
||||
<feign-hystrix.version>11.8</feign-hystrix.version>
|
||||
<feign-ribbon.version>11.8</feign-ribbon.version>
|
||||
<nacos-client.version>2.0.4</nacos-client.version>
|
||||
<!-- json解析 -->
|
||||
<jackson.version>2.13.3</jackson.version>
|
||||
<fastjson.version>2.0.11</fastjson.version>
|
||||
<!-- ORM -->
|
||||
<mybatis-plus-boot-starter.version>3.4.3</mybatis-plus-boot-starter.version>
|
||||
<mysql-jdbc.version>8.0.21</mysql-jdbc.version>
|
||||
<postgresql.version>42.5.0</postgresql.version>
|
||||
<jackson-datatype-jsr310.version>2.13.3</jackson-datatype-jsr310.version>
|
||||
<!-- spring-cloud-alibaba版本配置 -->
|
||||
<spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>
|
||||
<aliyun.version>4.5.0</aliyun.version>
|
||||
<com.alibaba.transmittable.version>2.12.2</com.alibaba.transmittable.version>
|
||||
<!-- orika-core实体类转换版本配置 -->
|
||||
<orika-core.version>1.5.4</orika-core.version>
|
||||
<!-- 斯瓦格UI版本配置 -->
|
||||
<swagger-annotations.verion>1.5.24</swagger-annotations.verion>
|
||||
<knife4j-spring-boot-starter.version>3.0.3</knife4j-spring-boot-starter.version>
|
||||
<knife4j-spring-boot-starter.version>3.0.5</knife4j-spring-boot-starter.version>
|
||||
<!-- 阿里巴巴excel解析版本配置 -->
|
||||
<easyexcel.version>2.2.11</easyexcel.version>
|
||||
<bcprov-jdk15on.version>1.70</bcprov-jdk15on.version>
|
||||
<nacos-client.version>2.0.4</nacos-client.version>
|
||||
<!-- xxl-job-core核心版本号 -->
|
||||
<xxl-job-core.version>2.3.0</xxl-job-core.version>
|
||||
|
||||
<!-- 第三方工具库 -->
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<commons-collections4.version>4.4</commons-collections4.version>
|
||||
<commons-io.version>2.11.0</commons-io.version>
|
||||
<commons-crypto.version>1.1.0</commons-crypto.version>
|
||||
<jackson-datatype-jsr310.version>2.13.3</jackson-datatype-jsr310.version>
|
||||
|
||||
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@ -98,26 +109,26 @@
|
||||
<version>${mysql-jdbc.version}</version>
|
||||
</dependency>
|
||||
<!-- JWT 依赖开始 -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.jsonwebtoken</groupId>-->
|
||||
<!-- <artifactId>jjwt-api</artifactId>-->
|
||||
<!-- <version>${jwt.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.jsonwebtoken</groupId>-->
|
||||
<!-- <artifactId>jjwt-impl</artifactId>-->
|
||||
<!-- <version>${jwt.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.jsonwebtoken</groupId>-->
|
||||
<!-- <artifactId>jjwt-jackson</artifactId>-->
|
||||
<!-- <version>${jwt.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
@ -133,11 +144,6 @@
|
||||
<artifactId>feign-hystrix</artifactId>
|
||||
<version>${feign-hystrix.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-ribbon</artifactId>
|
||||
<version>${feign-ribbon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
@ -152,7 +158,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.11</version>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@ -179,11 +185,6 @@
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger-annotations.verion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
@ -209,6 +210,18 @@
|
||||
<artifactId>commons-crypto</artifactId>
|
||||
<version>${commons-crypto.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${compler.maven.plugin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-authorization-server -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.security</groupId>-->
|
||||
|
@ -38,6 +38,11 @@
|
||||
<artifactId>zyjblogs-web-spring-boot-starter</artifactId>
|
||||
<version>${zyjblogs.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-mybatisplus-spring-boot-starter</artifactId>
|
||||
<version>${zyjblogs.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
|
@ -82,7 +82,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${compler.maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
@ -5,7 +5,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Locale;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ -14,4 +13,5 @@ public class ContextDto {
|
||||
private String userId;
|
||||
private String username;
|
||||
private String token;
|
||||
private String tenantId;
|
||||
}
|
55
zyjblogs-mybatisplus-spring-boot-starter/pom.xml
Normal file
55
zyjblogs-mybatisplus-spring-boot-starter/pom.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>zyjblogs-parent</artifactId>
|
||||
<groupId>cn.zyjblogs</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-mybatisplus-spring-boot-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 集成spring-boot自动装配依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<!-- 集成spring-boot,配置文件属性处理依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,53 @@
|
||||
package cn.zyjblogs.starter.mybatisplus.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.apache.ibatis.mapping.DatabaseIdProvider;
|
||||
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Copyright (C), 2021, 北京同创永益科技发展有限公司
|
||||
*
|
||||
* @author zhuyijun
|
||||
* @version 3.0.0
|
||||
* @description
|
||||
* @date 2022/8/17 17:09
|
||||
*/
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库兼容,在mybatis里设置相应的databaseId即可
|
||||
*/
|
||||
@Bean
|
||||
public DatabaseIdProvider databaseIdProvider() {
|
||||
DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("Oracle", "oracle");
|
||||
properties.setProperty("MySQL", "mysql");
|
||||
properties.setProperty("DB2", "db2");
|
||||
properties.setProperty("Derby", "derby");
|
||||
properties.setProperty("H2", "h2");
|
||||
properties.setProperty("HSQL", "hsql");
|
||||
properties.setProperty("Informix", "informix");
|
||||
properties.setProperty("MS-SQL", "ms-sql");
|
||||
properties.setProperty("PostgreSQL", "postgresql");
|
||||
properties.setProperty("Sybase", "sybase");
|
||||
properties.setProperty("Hana", "hana");
|
||||
databaseIdProvider.setProperties(properties);
|
||||
return databaseIdProvider;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.zyjblogs.starter.mybatisplus.config.MyBatisPlusConfig
|
@ -58,7 +58,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${compler.maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
@ -9,19 +9,18 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
|
||||
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
|
||||
/**
|
||||
* 资源服务
|
||||
*
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@RequiredArgsConstructor
|
||||
@RefreshScope
|
||||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
@Value("${spring.application.name}")
|
||||
private String resourceId;
|
||||
private final TokenStore tokenStore;
|
||||
@ -36,13 +35,12 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http .sessionManagement()
|
||||
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
|
||||
http.sessionManagement()
|
||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/**")
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.anyRequest().permitAll()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ public class OauthAccessTokenConverter extends DefaultAccessTokenConverter {
|
||||
public OAuth2AccessToken extractAccessToken(String value, Map<String, ?> map) {
|
||||
String userId = (String) map.get(ContextKeyConstant.USER_ID_KEY);
|
||||
String username = (String) map.get(ContextKeyConstant.USERNAME_KEY);
|
||||
BaseContext.set(ContextDto.builder().userId(userId).username(username).token(value).build());
|
||||
String tenantId = (String) map.get(ContextKeyConstant.TENANT_ID_KEY);
|
||||
BaseContext.set(ContextDto.builder().userId(userId).username(username).token(value).tenantId(tenantId).build());
|
||||
return super.extractAccessToken(value, map);
|
||||
}
|
||||
|
||||
|
@ -44,12 +44,8 @@
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-mybatisplus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -1,28 +0,0 @@
|
||||
package cn.zyjblogs.oauth.config.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Copyright (C), 2021, 北京同创永益科技发展有限公司
|
||||
*
|
||||
* @author zhuyijun
|
||||
* @version 3.0.0
|
||||
* @description
|
||||
* @date 2022/8/17 17:09
|
||||
*/
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package cn.zyjblogs.oauth.config.security;
|
||||
|
||||
import cn.zyjblogs.starter.common.entity.constant.ContextKeyConstant;
|
||||
import cn.zyjblogs.oauth.server.user.po.OauthUserDetails;
|
||||
import cn.zyjblogs.starter.common.entity.context.BaseContext;
|
||||
import cn.zyjblogs.starter.common.entity.dto.ContextDto;
|
||||
import cn.zyjblogs.starter.common.entity.constant.ContextKeyConstant;
|
||||
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
@ -15,18 +13,20 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* jwt内容增强器
|
||||
*
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Component
|
||||
public class JwtTokenEnhancer implements TokenEnhancer {
|
||||
/**
|
||||
* token增强
|
||||
* token增强
|
||||
*
|
||||
* @param oAuth2AccessToken
|
||||
* @param authentication
|
||||
* @author zhuyijun
|
||||
* @date 2022/8/18 下午8:51
|
||||
* @return org.springframework.security.oauth2.common.OAuth2AccessToken
|
||||
*/
|
||||
* @return org.springframework.security.oauth2.common.OAuth2AccessToken
|
||||
* @author zhuyijun
|
||||
* @date 2022/8/18 下午8:51
|
||||
*/
|
||||
@Override
|
||||
public OAuth2AccessToken enhance(OAuth2AccessToken oAuth2AccessToken, OAuth2Authentication authentication) {
|
||||
OauthUserDetails authUser = (OauthUserDetails) authentication.getPrincipal();
|
||||
@ -35,6 +35,7 @@ public class JwtTokenEnhancer implements TokenEnhancer {
|
||||
additionalInfo.put(ContextKeyConstant.USER_ID_KEY, authUser.getId());
|
||||
additionalInfo.put(ContextKeyConstant.USERNAME_KEY, authUser.getUsername());
|
||||
additionalInfo.put(ContextKeyConstant.NAME_KEY, authUser.getName());
|
||||
additionalInfo.put(ContextKeyConstant.TENANT_ID_KEY, authUser.getTenantId());
|
||||
((DefaultOAuth2AccessToken) oAuth2AccessToken).setAdditionalInformation(additionalInfo);
|
||||
return oAuth2AccessToken;
|
||||
|
||||
|
@ -23,7 +23,8 @@ public class OauthAccessTokenConverter extends DefaultAccessTokenConverter {
|
||||
public OAuth2AccessToken extractAccessToken(String value, Map<String, ?> map) {
|
||||
String userId = (String) map.get(ContextKeyConstant.USER_ID_KEY);
|
||||
String username = (String) map.get(ContextKeyConstant.USERNAME_KEY);
|
||||
BaseContext.set(ContextDto.builder().userId(userId).username(username).token(value).build());
|
||||
String tenantId = (String) map.get(ContextKeyConstant.TENANT_ID_KEY);
|
||||
BaseContext.set(ContextDto.builder().userId(userId).username(username).token(value).tenantId(tenantId).build());
|
||||
return super.extractAccessToken(value, map);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import cn.zyjblogs.oauth.server.user.constant.CommonConstant;
|
||||
import cn.zyjblogs.oauth.server.user.constant.UserEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -14,7 +13,6 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
@ -41,12 +39,21 @@ public class OauthUserDetails implements UserDetails, Serializable {
|
||||
private Integer status;
|
||||
|
||||
private Integer deleted;
|
||||
private String tenantId;
|
||||
private Collection<Role> authorities;
|
||||
private boolean accountNonExpired = true;
|
||||
private boolean accountNonLocked = true;
|
||||
private boolean credentialsNonExpired = true;
|
||||
private boolean enabled = true;
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -133,7 +140,7 @@ public class OauthUserDetails implements UserDetails, Serializable {
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return authorities == null ? Collections.emptyList():authorities;
|
||||
return authorities == null ? Collections.emptyList() : authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,11 +72,14 @@ public class UserPo implements Serializable {
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("update_user_id")
|
||||
private String updateUserId;
|
||||
@TableField("edit_user_id")
|
||||
private String editUserId;
|
||||
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("edit_time")
|
||||
private LocalDateTime editTime;
|
||||
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
}
|
||||
|
@ -27,5 +27,6 @@ spring:
|
||||
password: ${spring.cloud.nacos.config.password}
|
||||
namespace: ${spring.cloud.nacos.config.namespace}
|
||||
group: public
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
@ -48,12 +48,8 @@
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-mybatisplus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- 集成nacos-->
|
||||
<dependency>
|
||||
|
@ -1,28 +0,0 @@
|
||||
package cn.zyjblogs.rbac.config.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Copyright (C), 2021, 北京同创永益科技发展有限公司
|
||||
*
|
||||
* @author zhuyijun
|
||||
* @version 3.0.0
|
||||
* @description
|
||||
* @date 2022/8/17 17:09
|
||||
*/
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.zyjblogs.rbac.server.role.controller;
|
||||
|
||||
import cn.zyjblogs.rbac.server.role.service.RoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@ResponseBody
|
||||
@RequiredArgsConstructor
|
||||
public class RoleController {
|
||||
private final RoleService roleService;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.zyjblogs.rbac.server.role.mapper;
|
||||
|
||||
import cn.zyjblogs.rbac.server.role.po.RolePo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<RolePo> {
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.zyjblogs.rbac.server.role.po;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("role")
|
||||
public class RolePo implements Serializable {
|
||||
@TableId("id")
|
||||
private String id;
|
||||
@TableField("name")
|
||||
private String name;
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
@TableField("create_user_id")
|
||||
private String createUserId;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("edit_user_id")
|
||||
private String editUserId;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField("edit_time")
|
||||
private LocalDateTime editTime;
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package cn.zyjblogs.rbac.server.role.service;
|
||||
|
||||
import cn.zyjblogs.rbac.server.role.po.RolePo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
public interface RoleService extends IService<RolePo> {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.zyjblogs.rbac.server.role.service.impl;
|
||||
|
||||
import cn.zyjblogs.rbac.server.role.mapper.RoleMapper;
|
||||
import cn.zyjblogs.rbac.server.role.po.RolePo;
|
||||
import cn.zyjblogs.rbac.server.role.service.RoleService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zhuyijun
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RolePo> implements RoleService {
|
||||
}
|
@ -72,11 +72,14 @@ public class UserPo implements Serializable {
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("update_user_id")
|
||||
private String updateUserId;
|
||||
@TableField("edit_user_id")
|
||||
private String editUserId;
|
||||
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("edit_time")
|
||||
private LocalDateTime editTime;
|
||||
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ spring:
|
||||
password: ${spring.cloud.nacos.config.password}
|
||||
namespace: ${spring.cloud.nacos.config.namespace}
|
||||
group: public
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
#security:
|
||||
|
@ -61,7 +61,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${compler.maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
@ -19,10 +19,10 @@
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.xiaoymin</groupId>-->
|
||||
<!-- <artifactId>knife4j-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.xiaoymin</groupId>-->
|
||||
<!-- <artifactId>knife4j-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.zyjblogs.starter</groupId>
|
||||
<artifactId>zyjblogs-common-spring-boot-starter</artifactId>
|
||||
@ -46,7 +46,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${compler.maven.plugin.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user