增加可选择(数据库,内存)oauth2服务商client保存方式配置属性,默认jdbc存储。
增加程序启动时多数据源自动执行各自初始化sql脚本功能
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
USE micro;
|
||||
create table oauth_client_details (
|
||||
client_id VARCHAR(256) PRIMARY KEY,
|
||||
resource_ids VARCHAR(256),
|
||||
client_secret VARCHAR(256),
|
||||
scope VARCHAR(256),
|
||||
authorized_grant_types VARCHAR(256),
|
||||
web_server_redirect_uri VARCHAR(256),
|
||||
authorities VARCHAR(256),
|
||||
access_token_validity INTEGER,
|
||||
refresh_token_validity INTEGER,
|
||||
additional_information VARCHAR(4096),
|
||||
autoapprove VARCHAR(256)
|
||||
);
|
||||
+1
-1
@@ -25,7 +25,7 @@ USE micro;
|
||||
-- ucenter_user_details ucenter用户详情表
|
||||
-- ------------------------------------
|
||||
DROP TABLE IF EXISTS ucenter_user_details;
|
||||
CREATE TABLE ucenter_user_details (
|
||||
CREATE TABLE ucenter_user_details (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`signature` VARCHAR(300) DEFAULT NULL
|
||||
|
||||
+1
-2
@@ -1,16 +1,15 @@
|
||||
package com.micro.fast.boot.starter.common.exception.handler;
|
||||
|
||||
import com.micro.fast.boot.starter.common.exception.SystemException;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.boot.starter.common.util.ExceptionUtil;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
- oauth2中相同的用户会得到相同的token
|
||||
- `ms.security.oauth2.storeType`token的策略,不设置这个值的是时候默认生成`jwt`的token,如果设置值为`redis`的时候生成的默认的token将会存储在redis中
|
||||
- `ms.security.oauth2.jwtSigningKey` 生成jwt的token的秘钥
|
||||
- `ms.security.oauth2.clientStoreType` oauth2服务商client详情的存储方式,默认mysql.填写其他值会存储在内存中
|
||||
- `ms.security.oauth2.providerLoginPage`oauth2服务提供商提供用户登录的页面
|
||||
- `ms.security.oauth2.providerLoginProcessUrl`oauth2服务提供商处理用户登录进程的url
|
||||
- `ms.security.oauth2.clients[i].clientId` 配置oauth2授权的clientId
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
@@ -54,6 +58,17 @@
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<!--数据库连接-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--数据库连接池相关依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
|
||||
+21
-12
@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.oauth2.config.annotation.builders.InMemoryClientDetailsServiceBuilder;
|
||||
import org.springframework.security.oauth2.config.annotation.builders.JdbcClientDetailsServiceBuilder;
|
||||
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,6 +45,9 @@ public class AuthorizationProviderConfig extends AuthorizationServerConfigurerAd
|
||||
@Autowired
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
/**
|
||||
* jwtToken转换器
|
||||
* 只有在jwt环境下才生效
|
||||
@@ -91,18 +96,22 @@ public class AuthorizationProviderConfig extends AuthorizationServerConfigurerAd
|
||||
*/
|
||||
@Override
|
||||
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
|
||||
InMemoryClientDetailsServiceBuilder builder = clients.inMemory();
|
||||
if (ArrayUtils.isNotEmpty(securityProperties.getOauth2().getClients())){
|
||||
for (OAuth2ClientProperties client: securityProperties.getOauth2().getClients()){
|
||||
builder.withClient(client.getClientId()).secret(client.getClientSecret())
|
||||
//token的过期时间
|
||||
.accessTokenValiditySeconds(client.getAccessTokenValiditySeconds())
|
||||
//授权类型
|
||||
.authorizedGrantTypes(client.getAuthorizedGrantTypes())
|
||||
//refreshToken的过期时间,refreshToken是用来在用户无感知的情况下换取token的
|
||||
.refreshTokenValiditySeconds(client.getAccessTokenValiditySeconds())
|
||||
//授权scope
|
||||
.scopes(client.getScopes());
|
||||
if ("mysql".equals(securityProperties.getOauth2().getClientStoreType())) {
|
||||
JdbcClientDetailsServiceBuilder jdbc = clients.jdbc(dataSource);
|
||||
} else {
|
||||
InMemoryClientDetailsServiceBuilder builder = clients.inMemory();
|
||||
if (ArrayUtils.isNotEmpty(securityProperties.getOauth2().getClients())){
|
||||
for (OAuth2ClientProperties client: securityProperties.getOauth2().getClients()){
|
||||
builder.withClient(client.getClientId()).secret(client.getClientSecret())
|
||||
//token的过期时间
|
||||
.accessTokenValiditySeconds(client.getAccessTokenValiditySeconds())
|
||||
//授权类型
|
||||
.authorizedGrantTypes(client.getAuthorizedGrantTypes())
|
||||
//refreshToken的过期时间,refreshToken是用来在用户无感知的情况下换取token的
|
||||
.refreshTokenValiditySeconds(client.getAccessTokenValiditySeconds())
|
||||
//授权scope
|
||||
.scopes(client.getScopes());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -7,12 +7,13 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* oauth2服务提供商的授权拦截的配置,用于拦截/oauth/authorize过滤器链的优先级高于资源服务器授权过滤连的优先级
|
||||
* @author lsy
|
||||
*/
|
||||
@EnableWebSecurity
|
||||
//@EnableWebSecurity
|
||||
public class Oauth2ProviderSecurity extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
@@ -50,6 +51,10 @@ public class Oauth2ProviderSecurity extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/oauth/authorize")
|
||||
.authenticated()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/user/login")
|
||||
.permitAll()
|
||||
.and()
|
||||
.csrf()
|
||||
.disable();
|
||||
}
|
||||
|
||||
+2
@@ -35,4 +35,6 @@ public class OAuth2Properties {
|
||||
* 服务提供商授权时处理登录的路径
|
||||
*/
|
||||
private String providerLoginProcessUrl = "/oauth/login/process";
|
||||
|
||||
private String clientStoreType = "mysql";
|
||||
}
|
||||
|
||||
@@ -19,3 +19,12 @@
|
||||
- 如果传入的是单参数且参数类型是一个array数组的时候,collection的属性值为array .
|
||||
- 如果传入的参数是多个的时候,我们就需要把它们封装成一个Map了,当然单参数也可以封装成map,实际上如果你在传入参数的时候,在MyBatis里面也是会把它封装成一个Map的,map的key就是参数名,所以这个时候collection属性值就是传入的List或array对象在自己封装的map里面的key.
|
||||
|
||||
### boot-starter-ssm模块提供了增强的程序运行时运行初始化数据库脚本功能
|
||||
spring-boot提供了默认的启动时执行数据库脚本功能,指定`spring.datasource.schema`属性即可。boot-starter-ssm对此功能进行了增强,
|
||||
默认提供了主从两个数据源的配置bean.如果想要某个数据源程序启动时执行sql脚本。只需在druid数据源配置增加`sql-path`属性,并且保证
|
||||
配置`username,password,url,driver-class-name`.如果这仍然不满足你的需求,你想要配置更多的数据源,并且需要启动时各自执行各自的sql
|
||||
脚本。对于以上需求本项目也是满足的。你只需参照[druid官网的配置说明](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter)配置
|
||||
更多的数据源,像增加多个druid数据源一样增加`com.micro.fast.common.init.properties.SqlInitProperties`类的配置bean,然后满足上述
|
||||
两个数据源时同样要求即可。
|
||||
|
||||
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.micro.fast.common.init;
|
||||
|
||||
import com.micro.fast.common.init.properties.SqlInitProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.io.Resources;
|
||||
import org.apache.ibatis.jdbc.ScriptRunner;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单一数据源时初始化数据库表结构和数据
|
||||
* 如果配置多个数据源,按此自行添加
|
||||
* @author lsy
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class InitUpmsSystem implements ApplicationListener<ContextRefreshedEvent> {
|
||||
public static final String ANNOTATION_CONFIG_EMBEDDED_WEB_APPLICATION_CONTEXT = "AnnotationConfigEmbeddedWebApplicationContext";
|
||||
public static final String ANNOTATION_CONFIG_APPLICATION_CONTEXT = "AnnotationConfigApplicationContext";
|
||||
|
||||
@Autowired
|
||||
private Map<String,SqlInitProperties> sqlInitPropertiesMap;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
ApplicationContext applicationContext = event.getApplicationContext();
|
||||
ApplicationContext parent = applicationContext.getParent();
|
||||
// 保证springBoot上下文初始化完毕
|
||||
if (applicationContext.getDisplayName().contains(ANNOTATION_CONFIG_EMBEDDED_WEB_APPLICATION_CONTEXT)
|
||||
&& parent.getDisplayName().contains(ANNOTATION_CONFIG_APPLICATION_CONTEXT)) {
|
||||
// 初始化数据表
|
||||
sqlInitPropertiesMap.forEach((key,value) -> {
|
||||
if (value != null) {
|
||||
runInitSql(value.getDriverClassName(),value.getUrl(),value.getUsername(),value.getPassword(),value.getSqlPath());
|
||||
}
|
||||
});
|
||||
log.info("name:{} displayName: {} parentName:{} parentName: {}",
|
||||
applicationContext.getApplicationName(),
|
||||
applicationContext.getDisplayName(),
|
||||
parent.getApplicationName(),
|
||||
parent.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行初始化sql
|
||||
* @param driver 数据库驱动全类名
|
||||
* @param url 数据库连接url
|
||||
* @param username 数据库连接的用户名
|
||||
* @param password 数据库连接的密码
|
||||
* @param sqlPath sql脚本的路径
|
||||
*/
|
||||
private void runInitSql(String driver,String url,String username,String password,String sqlPath){
|
||||
try {
|
||||
// 执行sql脚本
|
||||
Class.forName(driver);
|
||||
Connection connection = DriverManager.getConnection(url, username, password);
|
||||
ScriptRunner scriptRunner = new ScriptRunner(connection);
|
||||
Resources.setCharset(Charset.forName("utf-8"));
|
||||
Reader resourceAsReader = Resources.getResourceAsReader(sqlPath);
|
||||
scriptRunner.runScript(resourceAsReader);
|
||||
scriptRunner.closeConnection();
|
||||
connection.close();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.micro.fast.common.init.config;
|
||||
|
||||
import com.micro.fast.common.init.properties.SqlInitProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* sql初始化配置类
|
||||
* @author lsy
|
||||
*/
|
||||
@Configuration
|
||||
public class InitConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.druid")
|
||||
@ConditionalOnProperty("spring.datasource.druid.sql-path")
|
||||
public SqlInitProperties dataSourceInitProperties(){
|
||||
return new SqlInitProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.druid.master")
|
||||
@ConditionalOnProperty("spring.datasource.druid.master.sql-path")
|
||||
public SqlInitProperties masterDataSourceInitProperties(){
|
||||
return new SqlInitProperties();
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.micro.fast.common.init.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 运行sql脚本相关的配置
|
||||
* @author lsy
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SqlInitProperties {
|
||||
|
||||
|
||||
/**
|
||||
* 数据库连接用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 数据库连接密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 数据库连接驱动全类名
|
||||
*/
|
||||
private String driverClassName;
|
||||
|
||||
/**
|
||||
* 数据库连接url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 执行脚本的classpath路径
|
||||
*/
|
||||
private String sqlPath;
|
||||
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>ms</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
</parent>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
create table IF NOT EXISTS oauth_client_details (
|
||||
client_id VARCHAR(256) PRIMARY KEY,
|
||||
resource_ids VARCHAR(256),
|
||||
client_secret VARCHAR(256),
|
||||
scope VARCHAR(256),
|
||||
authorized_grant_types VARCHAR(256),
|
||||
web_server_redirect_uri VARCHAR(256),
|
||||
authorities VARCHAR(256),
|
||||
access_token_validity INTEGER,
|
||||
refresh_token_validity INTEGER,
|
||||
additional_information VARCHAR(4096),
|
||||
autoapprove VARCHAR(256)
|
||||
);
|
||||
# 初始化数据
|
||||
INSERT INTO oauth_client_details VALUE ('ms',NULL ,'ms','all,write,read','code,password,custom,refresh_token',NULL ,NULL ,NULL ,NULL,NULL ,NULL);
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Source Server : 127.0.0.1
|
||||
Source Host : localhost:3317
|
||||
Source Database : micro
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 5.7
|
||||
File Encoding : utf-8
|
||||
Author : lishouyu
|
||||
Email : 18332763730@163.com
|
||||
*/
|
||||
# 外键检查,不允许有外键
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
-- ucenter用户中心
|
||||
-- ------------------------------------
|
||||
-- ucenter_user_details ucenter用户详情表
|
||||
-- ------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS ucenter_user_details (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`signature` VARCHAR(300) DEFAULT NULL
|
||||
COMMENT '个性签名',
|
||||
`real_name` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '真实姓名',
|
||||
`birthday` DATETIME DEFAULT NULL
|
||||
COMMENT '出生日期',
|
||||
`question` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '账号安全问题',
|
||||
`answer` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '账号安全答案',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
-- ------------------------------------
|
||||
-- ucenter_user ucenter用户表
|
||||
-- ------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS ucenter_user (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`password` VARCHAR(200) NOT NULL
|
||||
COMMENT '密码(MD5(密码+salt))',
|
||||
`salt` VARCHAR(32) DEFAULT NULL
|
||||
COMMENT '盐值',
|
||||
`nickname` VARCHAR(32) DEFAULT NULL
|
||||
COMMENT '昵称',
|
||||
`sex` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '性别 0未知 1男 2女',
|
||||
`avatar` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '头像',
|
||||
`create_ip` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '注册ip',
|
||||
`last_login_time` DATETIME DEFAULT NULL
|
||||
COMMENT '最后登陆时间',
|
||||
`last_login_ip` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '最后登录的ip',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
-- -----------------------------
|
||||
-- ucenter_user_log 用户操作日志表
|
||||
-- -----------------------------
|
||||
CREATE TABLE IF NOT EXISTS ucenter_user_log (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`user_id` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '用户编号',
|
||||
`content` VARBINARY(100) DEFAULT NULL
|
||||
COMMENT '内容',
|
||||
`ip` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '操作ip',
|
||||
`agent` VARBINARY(200) DEFAULT NULL
|
||||
COMMENT '操作环境',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ucenter_user_log_user_id_index` (`user_id`) USING BTREE
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
-- ------------------------------
|
||||
-- ucenter_user_oauth 用户认证方式表
|
||||
-- -------------------------------
|
||||
CREATE TABLE IF NOT EXISTS ucenter_user_oauth (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`user_id` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '用户编号',
|
||||
`oauth_id` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '认证方式编号',
|
||||
`open_id` VARBINARY(50) DEFAULT NULL
|
||||
COMMENT '第三方id',
|
||||
`status` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '绑定状态 0绑定 1解绑',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ucenter_user_oauth_user_id_index` (`user_id`) USING BTREE
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
-- ------------------------
|
||||
-- ucenter_oauth 认证方式表
|
||||
-- ------------------------
|
||||
CREATE TABLE IF NOT EXISTS ucenter_oauth(
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL COMMENT '编号',
|
||||
`name` VARCHAR(20) NOT NULL COMMENT '认证方式名称',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)ENGINE =InnoDB DEFAULT CHARSET =utf8;
|
||||
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
Source Server : 127.0.0.1
|
||||
Source Host : localhost:3317
|
||||
Source Database : micro
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 5.7
|
||||
File Encoding : utf-8
|
||||
Author : lishouyu
|
||||
Email : 18332763730@163.com
|
||||
*/
|
||||
# 外键检查,不能有外键
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
-- upms用户权限管理系统
|
||||
|
||||
-- -------------------------
|
||||
-- upms_log upms操作日志
|
||||
-- -------------------------
|
||||
CREATE TABLE IF NOT EXISTS `upms_log` (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '日志编号',
|
||||
`descirption` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '操作描述',
|
||||
`username` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '操作用户',
|
||||
`start_time` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '操作时间',
|
||||
`spend_time` INT UNSIGNED DEFAULT NULL
|
||||
COMMENT '消耗时间',
|
||||
`base_path` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '根路径',
|
||||
`uri` VARCHAR(200) DEFAULT NULL
|
||||
COMMENT 'URI',
|
||||
`url` VARCHAR(200) DEFAULT NULL
|
||||
COMMENT 'URL',
|
||||
`method` VARCHAR(10) DEFAULT NULL
|
||||
COMMENT '请求的类型',
|
||||
`parameter` MEDIUMTEXT DEFAULT NULL
|
||||
COMMENT '请求参数',
|
||||
`user_agent` VARCHAR(200) DEFAULT NULL
|
||||
COMMENT '用户标识',
|
||||
`ip` VARCHAR(30) DEFAULT NULL
|
||||
COMMENT 'ip地址',
|
||||
`result` MEDIUMTEXT DEFAULT NULL
|
||||
COMMENT '响应结果',
|
||||
`permissions` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '权限值',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
-- ------------------
|
||||
-- upms_user upms用户表
|
||||
-- ------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_user (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '用户的编号',
|
||||
`username` VARCHAR(20) NOT NULL
|
||||
COMMENT '用户名',
|
||||
`password` VARCHAR(200) NOT NULL
|
||||
COMMENT '密码加密后的md5值(密码+盐值)',
|
||||
`salt` VARCHAR(32) DEFAULT NULL
|
||||
COMMENT '盐值',
|
||||
`realname` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '真实姓名',
|
||||
`avatar` VARCHAR(150) DEFAULT NULL
|
||||
COMMENT '头像',
|
||||
`phone` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '电话',
|
||||
`email` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '电子邮箱',
|
||||
`sex` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '性别',
|
||||
`locked` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '账号状态',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
-- --------------------------
|
||||
-- upms_organization upms组织表
|
||||
-- ---------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_organization (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '组织的编号',
|
||||
`pid` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '所属上级',
|
||||
`name` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '组织名称',
|
||||
`description` VARCHAR(1000) DEFAULT NULL
|
||||
COMMENT '组织描述',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
-- ---------------------
|
||||
-- upms_role upms角色表
|
||||
-- ---------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_role (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '角色编号',
|
||||
`name` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '角色名称',
|
||||
`description` VARCHAR(1000) DEFAULT NULL
|
||||
COMMENT '角色描述',
|
||||
`orders` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '排序',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
-- ---------------------------
|
||||
-- upms_permission upms权限
|
||||
-- ---------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_permission (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '权限编号',
|
||||
`system_id` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '所属系统',
|
||||
`pid` INT(10) UNSIGNED DEFAULT NULL
|
||||
COMMENT '所属上级',
|
||||
`name` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '名称',
|
||||
`description` VARCHAR(200) DEFAULT NULL
|
||||
COMMENT '权限描述',
|
||||
`type` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '类型 1.视图授权2.数据授权',
|
||||
`permission_value` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '权限值',
|
||||
`uri` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '路径',
|
||||
`icon` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '图标',
|
||||
`status` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '状态 0 禁止 1 正常',
|
||||
`orders` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '排序',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `upms_permission_system_id_index` (`system_id`) USING BTREE COMMENT 'B+树索引'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
-- -------------------------
|
||||
-- upms_system upms系统表
|
||||
-- -------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_system (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
|
||||
COMMENT '系统编号',
|
||||
`icon` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '图标',
|
||||
`banner` VARCHAR(150) DEFAULT NULL
|
||||
COMMENT '背景',
|
||||
`theme` VARCHAR(50) DEFAULT NULL
|
||||
COMMENT '主题',
|
||||
`basepath` VARCHAR(100) DEFAULT NULL
|
||||
COMMENT '根目录',
|
||||
`status` TINYINT(4) DEFAULT NULL
|
||||
COMMENT '状态 0 黑名单 1 正常',
|
||||
`name` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '系统名称',
|
||||
`route` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '系统路由',
|
||||
`title` VARCHAR(20) DEFAULT NULL
|
||||
COMMENT '系统标题',
|
||||
`description` VARCHAR(300) DEFAULT NULL
|
||||
COMMENT '系统描述',
|
||||
`orders` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '排序',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
# 关联关系表
|
||||
-- --------------------------
|
||||
-- upms_user_organization 用户_组织关联表
|
||||
-- --------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_user_organization (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`user_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '用户编号',
|
||||
`organization_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '组织编号',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `upms_user_organization_user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
|
||||
KEY `upms_user_organization_organization_id_index` (`organization_id`) USING BTREE COMMENT 'B+树索引'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- upms_user_role 用户_角色关联表
|
||||
-- ----------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_user_role (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`user_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '用户编号',
|
||||
`role_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '角色编号',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY ` upms_user_role_user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
|
||||
KEY ` upms_user_role_role_id_index` (`role_id`) USING BTREE COMMENT 'B+树索引'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
# -- ----------------------------------
|
||||
# -- upms_user_permission 用户_权限关联表
|
||||
# -- ----------------------------------
|
||||
# CREATE TABLE IF NOT EXISTS upms_user_permission (
|
||||
# `id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
# COMMENT '编号',
|
||||
# `user_id` INT(10) UNSIGNED NOT NULL
|
||||
# COMMENT '用户编号',
|
||||
# `permission_id` INT(10) UNSIGNED NOT NULL
|
||||
# COMMENT '权限编号',
|
||||
# `type` TINYINT(4) NOT NULL
|
||||
# COMMENT '权限类型 -1 减权限',
|
||||
# `ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
# COMMENT '创建时间',
|
||||
# `uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
# COMMENT '修改时间',
|
||||
# `version` INT(10) UNSIGNED DEFAULT 0
|
||||
# COMMENT '数据版本',
|
||||
# PRIMARY KEY (`id`),
|
||||
# KEY `upms_user_permission_user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
|
||||
# KEY `upms_user_permission_permission_id_index` (`permission_id`) USING BTREE COMMENT 'B+树索引'
|
||||
# )
|
||||
# ENGINE = InnoDB
|
||||
# DEFAULT CHARSET utf8;
|
||||
|
||||
-- ----------------------------------
|
||||
-- upms_role_permission 角色_权限关联表
|
||||
-- ----------------------------------
|
||||
CREATE TABLE IF NOT EXISTS upms_role_permission (
|
||||
`id` INT(10) UNSIGNED AUTO_INCREMENT NOT NULL
|
||||
COMMENT '编号',
|
||||
`role_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '角色编号',
|
||||
`permission_id` INT(10) UNSIGNED NOT NULL
|
||||
COMMENT '权限编号',
|
||||
`ctime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '创建时间',
|
||||
`uptime` BIGINT(20) UNSIGNED DEFAULT NULL
|
||||
COMMENT '修改时间',
|
||||
`version` INT(10) UNSIGNED DEFAULT 0
|
||||
COMMENT '数据版本',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `upms_role_permission_role_id_index` (`role_id`) USING BTREE COMMENT 'B+树索引',
|
||||
KEY `upms_role_permission_permission_id_index` (`permission_id`) USING BTREE COMMENT 'B+树索引'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8;
|
||||
|
||||
# ##########################
|
||||
# 初始化数据
|
||||
# ##########################
|
||||
|
||||
# 初始化管理员数据
|
||||
INSERT INTO upms_user VALUE (1,'admin','$2a$10$Tqf5dVNDPBLwGSKrtK4zeuxMHY54qoJgqRQiLQZsLSsFmsWqY/gOa',NULL ,'micro-fast'
|
||||
,NULL ,'18332751256','18332763730@163.com',0,0,unix_timestamp(now()),unix_timestamp(now()) ,0);
|
||||
|
||||
# 初始化组织数据
|
||||
INSERT INTO upms_organization VALUE (1,0,'micro-fast项目部','负责micro-fast项目开源工作',unix_timestamp(now()),unix_timestamp(now()),0);
|
||||
@@ -43,6 +43,7 @@
|
||||
<spring-cloud-task.version>1.2.2.RELEASE</spring-cloud-task.version>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<!--/主要版本控制属性-->
|
||||
<activiti.version>5.21.0</activiti.version>
|
||||
<ratelimit.version>1.4.0.RELEASE</ratelimit.version>
|
||||
<docker.repository>registry.cn-hangzhou.aliyuncs.com/lishouyu/hub</docker.repository>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
Reference in New Issue
Block a user