Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
4fabc2b0
Commit
4fabc2b0
authored
Jul 16, 2019
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配oracle ,升级just auth版本
parent
98f1f55c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
16 deletions
+96
-16
guns-base-support/guns-base/src/main/java/cn/stylefeng/guns/base/db/collector/SqlSessionFactoryCreator.java
+58
-0
guns-base-support/guns-base/src/main/java/cn/stylefeng/guns/base/db/dao/DataBaseInfoDao.java
+1
-0
guns-base-support/guns-sys/pom.xml
+6
-7
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/system/warpper/UserWrapper.java
+1
-1
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/third/controller/OAuthController.java
+3
-4
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/third/factory/OAuthRequestFactory.java
+15
-0
pom.xml
+12
-4
No files found.
guns-base-support/guns-base/src/main/java/cn/stylefeng/guns/base/db/collector/SqlSessionFactoryCreator.java
View file @
4fabc2b0
package
cn
.
stylefeng
.
guns
.
base
.
db
.
collector
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer
;
import
com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties
;
import
com.baomidou.mybatisplus.autoconfigure.SpringBootVFS
;
import
com.baomidou.mybatisplus.core.MybatisConfiguration
;
import
com.baomidou.mybatisplus.core.config.GlobalConfig
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
com.baomidou.mybatisplus.core.incrementer.IKeyGenerator
;
import
com.baomidou.mybatisplus.core.injector.ISqlInjector
;
import
com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -14,10 +18,13 @@ import org.apache.ibatis.session.SqlSessionFactory;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
javax.sql.DataSource
;
import
java.util.List
;
/**
* mybatis的一些配置收集
...
...
@@ -38,15 +45,22 @@ public class SqlSessionFactoryCreator {
private
final
ApplicationContext
applicationContext
;
private
final
ResourceLoader
resourceLoader
;
private
final
List
<
ConfigurationCustomizer
>
configurationCustomizers
;
public
SqlSessionFactoryCreator
(
MybatisPlusProperties
properties
,
ResourceLoader
resourceLoader
,
ObjectProvider
<
Interceptor
[]>
interceptorsProvider
,
ObjectProvider
<
DatabaseIdProvider
>
databaseIdProvider
,
ObjectProvider
<
List
<
ConfigurationCustomizer
>>
configurationCustomizersProvider
,
ApplicationContext
applicationContext
)
{
this
.
properties
=
properties
;
this
.
interceptors
=
interceptorsProvider
.
getIfAvailable
();
this
.
databaseIdProvider
=
databaseIdProvider
.
getIfAvailable
();
this
.
applicationContext
=
applicationContext
;
this
.
resourceLoader
=
resourceLoader
;
this
.
configurationCustomizers
=
configurationCustomizersProvider
.
getIfAvailable
();
}
/**
...
...
@@ -57,6 +71,13 @@ public class SqlSessionFactoryCreator {
MybatisSqlSessionFactoryBean
factory
=
new
MybatisSqlSessionFactoryBean
();
factory
.
setDataSource
(
dataSource
);
factory
.
setVfs
(
SpringBootVFS
.
class
);
if
(
StringUtils
.
hasText
(
this
.
properties
.
getConfigLocation
()))
{
factory
.
setConfigLocation
(
this
.
resourceLoader
.
getResource
(
this
.
properties
.
getConfigLocation
()));
}
applyConfiguration
(
factory
);
if
(
this
.
properties
.
getConfigurationProperties
()
!=
null
)
{
factory
.
setConfigurationProperties
(
this
.
properties
.
getConfigurationProperties
());
}
if
(!
ObjectUtils
.
isEmpty
(
this
.
interceptors
))
{
factory
.
setPlugins
(
this
.
interceptors
);
}
...
...
@@ -66,15 +87,39 @@ public class SqlSessionFactoryCreator {
if
(
StringUtils
.
hasLength
(
this
.
properties
.
getTypeAliasesPackage
()))
{
factory
.
setTypeAliasesPackage
(
this
.
properties
.
getTypeAliasesPackage
());
}
// TODO 自定义枚举包
if
(
StringUtils
.
hasLength
(
this
.
properties
.
getTypeEnumsPackage
()))
{
factory
.
setTypeEnumsPackage
(
this
.
properties
.
getTypeEnumsPackage
());
}
if
(
this
.
properties
.
getTypeAliasesSuperType
()
!=
null
)
{
factory
.
setTypeAliasesSuperType
(
this
.
properties
.
getTypeAliasesSuperType
());
}
if
(
StringUtils
.
hasLength
(
this
.
properties
.
getTypeHandlersPackage
()))
{
factory
.
setTypeHandlersPackage
(
this
.
properties
.
getTypeHandlersPackage
());
}
if
(!
ObjectUtils
.
isEmpty
(
this
.
properties
.
resolveMapperLocations
()))
{
factory
.
setMapperLocations
(
this
.
properties
.
resolveMapperLocations
());
}
// TODO 此处必为非 NULL
GlobalConfig
globalConfig
=
this
.
properties
.
getGlobalConfig
();
//注入填充器
if
(
this
.
applicationContext
.
getBeanNamesForType
(
MetaObjectHandler
.
class
,
false
,
false
).
length
>
0
)
{
MetaObjectHandler
metaObjectHandler
=
this
.
applicationContext
.
getBean
(
MetaObjectHandler
.
class
);
globalConfig
.
setMetaObjectHandler
(
metaObjectHandler
);
}
//注入主键生成器
if
(
this
.
applicationContext
.
getBeanNamesForType
(
IKeyGenerator
.
class
,
false
,
false
).
length
>
0
)
{
IKeyGenerator
keyGenerator
=
this
.
applicationContext
.
getBean
(
IKeyGenerator
.
class
);
globalConfig
.
getDbConfig
().
setKeyGenerator
(
keyGenerator
);
}
//注入sql注入器
if
(
this
.
applicationContext
.
getBeanNamesForType
(
ISqlInjector
.
class
,
false
,
false
).
length
>
0
)
{
ISqlInjector
iSqlInjector
=
this
.
applicationContext
.
getBean
(
ISqlInjector
.
class
);
globalConfig
.
setSqlInjector
(
iSqlInjector
);
}
//globalConfig中有缓存sqlSessionFactory,目前还没别的办法
SqlSessionFactory
sqlSessionFactory
=
factory
.
getObject
();
...
...
@@ -88,4 +133,17 @@ public class SqlSessionFactoryCreator {
}
}
private
void
applyConfiguration
(
MybatisSqlSessionFactoryBean
factory
)
{
MybatisConfiguration
configuration
=
this
.
properties
.
getConfiguration
();
if
(
configuration
==
null
&&
!
StringUtils
.
hasText
(
this
.
properties
.
getConfigLocation
()))
{
configuration
=
new
MybatisConfiguration
();
}
if
(
configuration
!=
null
&&
!
CollectionUtils
.
isEmpty
(
this
.
configurationCustomizers
))
{
for
(
ConfigurationCustomizer
customizer
:
this
.
configurationCustomizers
)
{
customizer
.
customize
(
configuration
);
}
}
factory
.
setConfiguration
(
configuration
);
}
}
guns-base-support/guns-base/src/main/java/cn/stylefeng/guns/base/db/dao/DataBaseInfoDao.java
View file @
4fabc2b0
...
...
@@ -110,6 +110,7 @@ public class DataBaseInfoDao {
int
i
=
preparedStatement
.
executeUpdate
();
log
.
info
(
"删除master的databaseInfo信息!删除"
+
i
+
"条!"
);
}
catch
(
Exception
ex
)
{
log
.
info
(
"删除master的databaseInfo信息失败!"
,
ex
);
throw
new
DataSourceInitException
(
DataSourceInitException
.
ExEnum
.
QUERY_DATASOURCE_INFO_ERROR
);
}
}
...
...
guns-base-support/guns-sys/pom.xml
View file @
4fabc2b0
...
...
@@ -31,13 +31,6 @@
<version>
1.0.0
</version>
</dependency>
<!-- 第三方登录-->
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.6.0-beta
</version>
</dependency>
<!-- 最新代码生成模块 -->
<dependency>
<groupId>
cn.stylefeng
</groupId>
...
...
@@ -45,6 +38,12 @@
<version>
1.0.0
</version>
</dependency>
<!-- 第三方登录-->
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
</dependency>
</dependencies>
<build>
...
...
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/system/warpper/UserWrapper.java
View file @
4fabc2b0
...
...
@@ -54,7 +54,7 @@ public class UserWrapper extends BaseControllerWrapper {
map
.
put
(
"roleName"
,
ConstantFactory
.
me
().
getRoleName
((
String
)
map
.
get
(
"roleId"
)));
map
.
put
(
"deptName"
,
ConstantFactory
.
me
().
getDeptName
(
DecimalUtil
.
getLong
(
map
.
get
(
"deptId"
))));
map
.
put
(
"statusName"
,
ConstantFactory
.
me
().
getStatusName
((
String
)
map
.
get
(
"status"
)));
map
.
put
(
"positionName"
,
ConstantFactory
.
me
().
getPositionName
(
(
Long
)
map
.
get
(
"userId"
)));
map
.
put
(
"positionName"
,
ConstantFactory
.
me
().
getPositionName
(
DecimalUtil
.
getLong
(
map
.
get
(
"userId"
)
)));
}
}
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/third/controller/OAuthController.java
View file @
4fabc2b0
...
...
@@ -6,6 +6,7 @@ import cn.stylefeng.guns.sys.modular.third.service.LoginService;
import
cn.stylefeng.guns.sys.modular.third.service.OauthUserInfoService
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.request.AuthRequest
;
...
...
@@ -13,8 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -55,11 +54,11 @@ public class OAuthController extends BaseController {
* @Date 2019/6/9 16:45
*/
@RequestMapping
(
"/callback/{source}"
)
public
String
callback
(
@PathVariable
(
"source"
)
String
source
,
@RequestParam
(
"code"
)
String
code
,
RedirectAttributes
model
)
{
public
String
callback
(
@PathVariable
(
"source"
)
String
source
,
AuthCallback
callback
)
{
//通过回调的code,请求对应的oauth server获取用户基本信息和token
AuthRequest
authRequest
=
OAuthRequestFactory
.
getAuthRequest
(
source
);
AuthResponse
authResponse
=
authRequest
.
login
(
c
ode
);
AuthResponse
authResponse
=
authRequest
.
login
(
c
allback
);
AuthUser
oauthUser
=
(
AuthUser
)
authResponse
.
getData
();
log
.
info
(
"第三方登录回调成功:"
+
oauthUser
);
...
...
guns-base-support/guns-sys/src/main/java/cn/stylefeng/guns/sys/modular/third/factory/OAuthRequestFactory.java
View file @
4fabc2b0
...
...
@@ -31,6 +31,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/dingtalk"
)
.
state
(
"state"
)
.
build
());
break
;
case
"baidu"
:
...
...
@@ -38,6 +39,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/baidu"
)
.
state
(
"state"
)
.
build
());
break
;
case
"github"
:
...
...
@@ -45,6 +47,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/github"
)
.
state
(
"state"
)
.
build
());
break
;
case
"gitee"
:
...
...
@@ -52,6 +55,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/gitee"
)
.
state
(
"state"
)
.
build
());
break
;
case
"weibo"
:
...
...
@@ -59,6 +63,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/weibo"
)
.
state
(
"state"
)
.
build
());
break
;
case
"coding"
:
...
...
@@ -66,6 +71,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/tencentCloud"
)
.
state
(
"state"
)
.
build
());
break
;
case
"tencentCloud"
:
...
...
@@ -73,6 +79,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/tencentCloud"
)
.
state
(
"state"
)
.
build
());
break
;
case
"oschina"
:
...
...
@@ -80,6 +87,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/oschina"
)
.
state
(
"state"
)
.
build
());
break
;
case
"alipay"
:
...
...
@@ -89,6 +97,7 @@ public class OAuthRequestFactory {
.
clientSecret
(
""
)
.
alipayPublicKey
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/alipay"
)
.
state
(
"state"
)
.
build
());
break
;
case
"qq"
:
...
...
@@ -96,6 +105,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/qq"
)
.
state
(
"state"
)
.
build
());
break
;
case
"wechat"
:
...
...
@@ -103,6 +113,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/wechat"
)
.
state
(
"state"
)
.
build
());
break
;
case
"csdn"
:
...
...
@@ -110,6 +121,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/wechat"
)
.
state
(
"state"
)
.
build
());
break
;
case
"taobao"
:
...
...
@@ -117,6 +129,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/taobao"
)
.
state
(
"state"
)
.
build
());
break
;
case
"google"
:
...
...
@@ -124,6 +137,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/google"
)
.
state
(
"state"
)
.
build
());
break
;
case
"facebook"
:
...
...
@@ -131,6 +145,7 @@ public class OAuthRequestFactory {
.
clientId
(
""
)
.
clientSecret
(
""
)
.
redirectUri
(
BASE_URL
+
"/oauth/callback/facebook"
)
.
state
(
"state"
)
.
build
());
break
;
}
...
...
pom.xml
View file @
4fabc2b0
...
...
@@ -41,17 +41,18 @@
<ehcache.core.version>
2.6.11
</ehcache.core.version>
<jwt.version>
0.9.0
</jwt.version>
<oshi.version>
3.9.1
</oshi.version>
<just.auth.version>
1.8.1
</just.auth.version>
</properties>
<dependencyManagement>
<dependencies>
<!--
用just auth的jar冲突
-->
<!--
just auth兼容问题
-->
<dependency>
<groupId>
c
n.hutool
</groupId>
<artifactId>
hutool-core
</artifactId>
<version>
4.1.21
</version>
<groupId>
c
om.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.56
</version>
</dependency>
<!--核心组件-->
...
...
@@ -152,6 +153,13 @@
<version>
${oshi.version}
</version>
</dependency>
<!-- 第三方登录 -->
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
${just.auth.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment