Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
93073a89
Commit
93073a89
authored
Mar 28, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
10866ad3
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
105 additions
and
189 deletions
+105
-189
DataxAuthApplication.java
...uth/src/main/java/cn/datax/auth/DataxAuthApplication.java
+0
-4
bootstrap.yml
datax-auth/src/main/resources/bootstrap.yml
+0
-1
EnableDatabase.java
...a/cn/datax/common/database/annotation/EnableDatabase.java
+0
-14
AutoConfiguration.java
...va/cn/datax/common/database/config/AutoConfiguration.java
+0
-21
spring.factories
...mon-database/src/main/resources/META-INF/spring.factories
+2
-0
LogAspect.java
.../src/main/java/cn/datax/common/log/aspectj/LogAspect.java
+7
-4
AsyncTask.java
...og/src/main/java/cn/datax/common/log/async/AsyncTask.java
+12
-15
AutoConfiguration.java
...in/java/cn/datax/common/log/config/AutoConfiguration.java
+2
-4
LogAsyncConfig.java
.../main/java/cn/datax/common/log/config/LogAsyncConfig.java
+32
-0
LogEvent.java
...log/src/main/java/cn/datax/common/log/event/LogEvent.java
+0
-17
AutoConfiguration.java
...ava/cn/datax/common/mybatis/config/AutoConfiguration.java
+0
-3
AutoConfiguration.java
.../java/cn/datax/common/redis/config/AutoConfiguration.java
+0
-2
EnableDataAuthExceptionHandler.java
...n/security/annotation/EnableDataAuthExceptionHandler.java
+0
-14
EnableDataFeignClients.java
...ax/common/security/annotation/EnableDataFeignClients.java
+0
-22
EnableDataOauth2FeignClient.java
...mmon/security/annotation/EnableDataOauth2FeignClient.java
+0
-14
EnableDataSecurity.java
.../datax/common/security/annotation/EnableDataSecurity.java
+0
-16
EnableDataServerProtect.java
...x/common/security/annotation/EnableDataServerProtect.java
+2
-1
DataAuthExceptionConfiguration.java
...ommon/security/config/DataAuthExceptionConfiguration.java
+0
-2
DataOAuth2FeignConfiguration.java
.../common/security/config/DataOAuth2FeignConfiguration.java
+0
-14
DataServerProtectConfiguration.java
...ommon/security/config/DataServerProtectConfiguration.java
+0
-2
DataFeignRequestInterceptor.java
...ax/common/security/feign/DataFeignRequestInterceptor.java
+0
-2
spring.factories
...mon-security/src/main/resources/META-INF/spring.factories
+2
-0
DataFactoryApplication.java
...cn/datax/service/data/factory/DataFactoryApplication.java
+4
-6
LogServiceFeign.java
...va/cn/datax/service/system/api/feign/LogServiceFeign.java
+1
-1
UserServiceFeign.java
...a/cn/datax/service/system/api/feign/UserServiceFeign.java
+1
-1
DataxSystemApplication.java
.../java/cn/datax/service/system/DataxSystemApplication.java
+4
-4
DataResourceServerConfig.java
...datax/service/system/config/DataResourceServerConfig.java
+2
-1
LogController.java
...ava/cn/datax/service/system/controller/LogController.java
+4
-3
LoginController.java
...a/cn/datax/service/system/controller/LoginController.java
+30
-1
No files found.
datax-auth/src/main/java/cn/datax/auth/DataxAuthApplication.java
View file @
93073a89
...
...
@@ -2,19 +2,15 @@ package cn.datax.auth;
import
cn.datax.common.mybatis.annotation.EnableDataMybatis
;
import
cn.datax.common.redis.annotation.EnableDataRedis
;
import
cn.datax.common.security.annotation.EnableDataAuthExceptionHandler
;
import
cn.datax.common.security.annotation.EnableDataServerProtect
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
@EnableDataAuthExceptionHandler
@EnableDataServerProtect
@EnableDataMybatis
@EnableDataRedis
@EnableFeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
})
@ComponentScan
(
basePackages
=
{
"cn.datax"
})
@SpringCloudApplication
public
class
DataxAuthApplication
{
...
...
datax-auth/src/main/resources/bootstrap.yml
View file @
93073a89
...
...
@@ -9,7 +9,6 @@ spring:
cloud
:
config
:
fail-fast
:
true
# uri: http://localhost:8611
name
:
${spring.application.name}
profile
:
${spring.profiles.active}
discovery
:
...
...
datax-common/datax-common-database/src/main/java/cn/datax/common/database/annotation/EnableDatabase.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
database
.
annotation
;
import
cn.datax.common.database.config.AutoConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
AutoConfiguration
.
class
})
public
@interface
EnableDatabase
{
}
datax-common/datax-common-database/src/main/java/cn/datax/common/database/config/AutoConfiguration.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
database
.
config
;
import
cn.datax.common.database.DataSourceFactory
;
import
cn.datax.common.database.datasource.CacheDataSourceFactoryBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* 扫描注入bean
*
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.database"
})
public
class
AutoConfiguration
{
@Bean
public
DataSourceFactory
dataSourceFactory
(){
return
new
CacheDataSourceFactoryBean
();
}
}
datax-common/datax-common-database/src/main/resources/META-INF/spring.factories
0 → 100644
View file @
93073a89
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.datax.common.database.datasource.CacheDataSourceFactoryBean
datax-common/datax-common-log/src/main/java/cn/datax/common/log/aspectj/LogAspect.java
View file @
93073a89
...
...
@@ -3,10 +3,9 @@ package cn.datax.common.log.aspectj;
import
java.lang.reflect.Method
;
import
cn.datax.common.log.annotation.LogAop
;
import
cn.datax.common.log.
event.LogEvent
;
import
cn.datax.common.log.
async.AsyncTask
;
import
cn.datax.common.utils.RequestHolder
;
import
cn.datax.common.utils.SecurityUtil
;
import
cn.datax.common.utils.SpringContextHolder
;
import
cn.datax.service.system.api.dto.LogDto
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
...
...
@@ -20,6 +19,7 @@ import org.aspectj.lang.annotation.*;
import
org.aspectj.lang.reflect.MethodSignature
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -27,6 +27,9 @@ import javax.servlet.http.HttpServletRequest;
@Aspect
public
class
LogAspect
{
@Autowired
private
AsyncTask
asyncTask
;
// 配置织入点
@Pointcut
(
"@annotation(cn.datax.common.log.annotation.LogAop)"
)
public
void
logPointCut
()
{}
...
...
@@ -86,8 +89,8 @@ public class LogAspect {
logDto
.
setModule
(
logAop
.
module
()).
setTitle
(
logAop
.
value
())
.
setClassName
(
className
).
setMethodName
(
methodName
);
// 异步保存
会造成DataFeignRequestInterceptor报错,后期采用kafka
SpringContextHolder
.
publishEvent
(
new
LogEvent
(
logDto
)
);
// 异步保存
数据库
asyncTask
.
doTask
(
logDto
);
}
/**
...
...
datax-common/datax-common-log/src/main/java/cn/datax/common/log/
event/LogListener
.java
→
datax-common/datax-common-log/src/main/java/cn/datax/common/log/
async/AsyncTask
.java
View file @
93073a89
package
cn
.
datax
.
common
.
log
.
event
;
package
cn
.
datax
.
common
.
log
.
async
;
import
cn.datax.service.system.api.dto.LogDto
;
import
cn.datax.service.system.api.feign.LogServiceFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 异步监听日志事件
*
* @author yuwei
* @since 2019/10/30
*/
@Slf4j
public
class
LogListener
{
@Component
public
class
AsyncTask
{
@Autowired
private
LogServiceFeign
logServiceFeign
;
@EventListener
(
LogEvent
.
class
)
public
void
saveSysLog
(
LogEvent
event
)
{
LogDto
logDto
=
(
LogDto
)
event
.
getSource
();
log
.
info
(
"日志{}"
,
logDto
);
@Async
(
"dataLogExecutor"
)
public
void
doTask
(
LogDto
logDto
)
{
logServiceFeign
.
saveLog
(
logDto
);
}
}
}
\ No newline at end of file
datax-common/datax-common-log/src/main/java/cn/datax/common/log/config/AutoConfiguration.java
View file @
93073a89
package
cn
.
datax
.
common
.
log
.
config
;
import
cn.datax.common.log.aspectj.LogAspect
;
import
cn.datax.common.log.event.LogListener
;
import
org.springframework.context.annotation.ComponentScan
;
import
cn.datax.common.log.async.AsyncTask
;
import
org.springframework.context.annotation.Import
;
/**
...
...
@@ -11,8 +10,7 @@ import org.springframework.context.annotation.Import;
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.log"
})
@Import
({
LogAspect
.
class
,
LogListener
.
class
})
@Import
({
LogAspect
.
class
,
AsyncTask
.
class
,
LogAsyncConfig
.
class
})
public
class
AutoConfiguration
{
}
datax-common/datax-common-log/src/main/java/cn/datax/common/log/config/LogAsyncConfig.java
0 → 100644
View file @
93073a89
package
cn
.
datax
.
common
.
log
.
config
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
@EnableAsync
public
class
LogAsyncConfig
{
private
static
int
corePoolSize
=
5
;
private
static
int
maxPoolSize
=
10
;
private
static
int
queueCapacity
=
20
;
@Bean
(
"dataLogExecutor"
)
public
Executor
dataLogExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
corePoolSize
);
executor
.
setMaxPoolSize
(
maxPoolSize
);
executor
.
setQueueCapacity
(
queueCapacity
);
executor
.
setKeepAliveSeconds
(
60
);
executor
.
setThreadNamePrefix
(
"dataLogExecutor-"
);
executor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
executor
.
setAwaitTerminationSeconds
(
60
);
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
executor
.
initialize
();
return
executor
;
}
}
\ No newline at end of file
datax-common/datax-common-log/src/main/java/cn/datax/common/log/event/LogEvent.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
log
.
event
;
import
cn.datax.service.system.api.dto.LogDto
;
import
org.springframework.context.ApplicationEvent
;
/**
* 系统日志事件
*
* @author yuwei
* @since 2019/10/30
*/
public
class
LogEvent
extends
ApplicationEvent
{
public
LogEvent
(
LogDto
logDto
)
{
super
(
logDto
);
}
}
datax-common/datax-common-mybatis/src/main/java/cn/datax/common/mybatis/config/AutoConfiguration.java
View file @
93073a89
package
cn
.
datax
.
common
.
mybatis
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Import
;
/**
...
...
@@ -9,7 +7,6 @@ import org.springframework.context.annotation.Import;
* @author yuwei
* @since 2019/10/25
*/
@ComponentScan
({
"cn.datax.common.mybatis"
})
@Import
({
DataBatisPlusConfig
.
class
,
DataMetaObjectHandler
.
class
})
public
class
AutoConfiguration
{
}
datax-common/datax-common-redis/src/main/java/cn/datax/common/redis/config/AutoConfiguration.java
View file @
93073a89
package
cn
.
datax
.
common
.
redis
.
config
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Import
;
/**
...
...
@@ -8,7 +7,6 @@ import org.springframework.context.annotation.Import;
* @author yuwei
* @since 2019/10/25
*/
@ComponentScan
({
"cn.datax.common.redis"
})
@Import
({
RedisConfig
.
class
})
public
class
AutoConfiguration
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/annotation/EnableDataAuthExceptionHandler.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
security
.
annotation
;
import
cn.datax.common.security.config.DataAuthExceptionConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
DataAuthExceptionConfiguration
.
class
})
public
@interface
EnableDataAuthExceptionHandler
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/annotation/EnableDataFeignClients.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
security
.
annotation
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
java.lang.annotation.*
;
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@EnableFeignClients
public
@interface
EnableDataFeignClients
{
String
[]
value
()
default
{};
String
[]
basePackages
()
default
{
"cn.datax.service"
};
Class
<?>[]
basePackageClasses
()
default
{};
Class
<?>[]
defaultConfiguration
()
default
{};
Class
<?>[]
clients
()
default
{};
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/annotation/EnableDataOauth2FeignClient.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
security
.
annotation
;
import
cn.datax.common.security.config.DataOAuth2FeignConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
DataOAuth2FeignConfiguration
.
class
})
public
@interface
EnableDataOauth2FeignClient
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/annotation/EnableDataSecurity.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
security
.
annotation
;
import
cn.datax.common.security.config.DataAuthExceptionConfiguration
;
import
cn.datax.common.security.config.DataOAuth2FeignConfiguration
;
import
cn.datax.common.security.config.DataServerProtectConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
DataAuthExceptionConfiguration
.
class
,
DataOAuth2FeignConfiguration
.
class
,
DataServerProtectConfiguration
.
class
})
public
@interface
EnableDataSecurity
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/annotation/EnableDataServerProtect.java
View file @
93073a89
package
cn
.
datax
.
common
.
security
.
annotation
;
import
cn.datax.common.security.config.DataAuthExceptionConfiguration
;
import
cn.datax.common.security.config.DataServerProtectConfiguration
;
import
org.springframework.context.annotation.Import
;
...
...
@@ -9,6 +10,6 @@ import java.lang.annotation.*;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
({
DataServerProtectConfiguration
.
class
})
@Import
({
DataServerProtectConfiguration
.
class
,
DataAuthExceptionConfiguration
.
class
})
public
@interface
EnableDataServerProtect
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/config/DataAuthExceptionConfiguration.java
View file @
93073a89
...
...
@@ -4,7 +4,6 @@ import cn.datax.common.security.handler.DataAccessDeniedHandler;
import
cn.datax.common.security.handler.DataAuthExceptionEntryPoint
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* 异常翻译配置
...
...
@@ -12,7 +11,6 @@ import org.springframework.context.annotation.ComponentScan;
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.security.handler"
})
public
class
DataAuthExceptionConfiguration
{
@Bean
...
...
datax-common/datax-common-security/src/main/java/cn/datax/common/security/config/DataOAuth2FeignConfiguration.java
deleted
100644 → 0
View file @
10866ad3
package
cn
.
datax
.
common
.
security
.
config
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* OAuth2 Feign配置
*
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.security.feign"
})
public
class
DataOAuth2FeignConfiguration
{
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/config/DataServerProtectConfiguration.java
View file @
93073a89
...
...
@@ -4,7 +4,6 @@ import cn.datax.common.security.interceptor.DataServerProtectInterceptor;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
...
...
@@ -17,7 +16,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* @author yuwei
* @since 2019/10/30
*/
@ComponentScan
({
"cn.datax.common.security.interceptor"
})
@Import
({
DataServerProtectInterceptor
.
class
})
public
class
DataServerProtectConfiguration
implements
WebMvcConfigurer
{
...
...
datax-common/datax-common-security/src/main/java/cn/datax/common/security/feign/DataFeignRequestInterceptor.java
View file @
93073a89
...
...
@@ -3,7 +3,6 @@ package cn.datax.common.security.feign;
import
cn.datax.common.core.DataConstant
;
import
feign.RequestInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails
;
import
org.springframework.util.Base64Utils
;
...
...
@@ -14,7 +13,6 @@ import org.springframework.util.Base64Utils;
* @author yuwei
* @since 2019/10/30
*/
@Configuration
public
class
DataFeignRequestInterceptor
{
@Bean
...
...
datax-common/datax-common-security/src/main/resources/META-INF/spring.factories
0 → 100644
View file @
93073a89
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.datax.common.security.feign.DataFeignRequestInterceptor
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/DataFactoryApplication.java
View file @
93073a89
package
cn
.
datax
.
service
.
data
.
factory
;
import
cn.datax.common.database.annotation.EnableDatabase
;
import
cn.datax.common.log.annotation.EnableDataLog
;
import
cn.datax.common.mybatis.annotation.EnableDataMybatis
;
import
cn.datax.common.redis.annotation.EnableDataRedis
;
import
cn.datax.common.security.annotation.EnableDataFeignClients
;
import
cn.datax.common.security.annotation.EnableDataSecurity
;
import
cn.datax.common.security.annotation.EnableDataServerProtect
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableDataSe
curity
@EnableDataSe
rverProtect
@EnableDataMybatis
@EnableDataRedis
@EnableDataLog
@EnableDataFeignClients
@EnableDatabase
@EnableFeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
})
@SpringCloudApplication
public
class
DataFactoryApplication
{
...
...
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/LogServiceFeign.java
View file @
93073a89
...
...
@@ -10,6 +10,6 @@ import org.springframework.web.bind.annotation.RequestBody;
@FeignClient
(
contextId
=
"logServiceFeign"
,
value
=
"datax-service-system"
,
fallbackFactory
=
LogServiceFeignFallbackFactory
.
class
)
public
interface
LogServiceFeign
{
@PostMapping
(
"/logs"
)
@PostMapping
(
"/
inner/
logs"
)
R
saveLog
(
@RequestBody
LogDto
logDto
);
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/UserServiceFeign.java
View file @
93073a89
...
...
@@ -9,6 +9,6 @@ import org.springframework.web.bind.annotation.PathVariable;
@FeignClient
(
contextId
=
"userServiceFeign"
,
value
=
"datax-service-system"
,
fallbackFactory
=
UserServiceFeignFallbackFactory
.
class
)
public
interface
UserServiceFeign
{
@GetMapping
(
"/
inner/
login/username/{username}"
)
@GetMapping
(
"/login/username/{username}"
)
R
loginByUsername
(
@PathVariable
(
"username"
)
String
username
);
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/DataxSystemApplication.java
View file @
93073a89
...
...
@@ -3,16 +3,16 @@ package cn.datax.service.system;
import
cn.datax.common.log.annotation.EnableDataLog
;
import
cn.datax.common.mybatis.annotation.EnableDataMybatis
;
import
cn.datax.common.redis.annotation.EnableDataRedis
;
import
cn.datax.common.security.annotation.EnableDataFeignClients
;
import
cn.datax.common.security.annotation.EnableDataSecurity
;
import
cn.datax.common.security.annotation.EnableDataServerProtect
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableDataSe
curity
@EnableDataSe
rverProtect
@EnableDataMybatis
@EnableDataRedis
@EnableDataLog
@Enable
DataFeignClients
@Enable
FeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
})
@SpringCloudApplication
public
class
DataxSystemApplication
{
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/config/DataResourceServerConfig.java
View file @
93073a89
...
...
@@ -59,7 +59,8 @@ public class DataResourceServerConfig extends ResourceServerConfigurerAdapter {
"/swagger-resources/**"
,
"/webjars/**"
,
// feign 内部调用不用授权
"/inner/**"
"/inner/**"
,
"/login/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
csrf
().
disable
();
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/LogController.java
View file @
93073a89
...
...
@@ -3,6 +3,7 @@ package cn.datax.service.system.controller;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.common.security.annotation.DataInner
;
import
cn.datax.service.system.api.dto.LogDto
;
import
cn.datax.service.system.api.entity.LogEntity
;
import
cn.datax.service.system.api.query.LogQuery
;
...
...
@@ -33,7 +34,6 @@ import java.util.stream.Collectors;
*/
@Api
(
value
=
"系统管理接口"
,
tags
=
{
"系统管理"
})
@RestController
@RequestMapping
(
"/logs"
)
public
class
LogController
extends
BaseController
{
@Autowired
...
...
@@ -42,9 +42,10 @@ public class LogController extends BaseController {
@Autowired
private
LogMapper
logMapper
;
@DataInner
@ApiOperation
(
value
=
"创建日志"
,
notes
=
"根据log对象创建日志"
)
@ApiImplicitParam
(
name
=
"log"
,
value
=
"日志详细实体log"
,
required
=
true
,
dataType
=
"logDto"
)
@PostMapping
()
@PostMapping
(
"/inner/logs"
)
public
R
saveLog
(
@RequestBody
LogDto
log
)
{
logService
.
saveLog
(
log
);
return
R
.
ok
();
...
...
@@ -54,7 +55,7 @@ public class LogController extends BaseController {
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"logQuery"
,
value
=
"查询实体logQuery"
,
required
=
true
,
dataTypeClass
=
LogQuery
.
class
)
})
@GetMapping
(
"/page"
)
@GetMapping
(
"/
logs/
page"
)
public
R
getPostPage
(
LogQuery
logQuery
)
{
QueryWrapper
<
LogEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
logQuery
.
getTitle
()),
"title"
,
logQuery
.
getTitle
());
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/LoginController.java
View file @
93073a89
...
...
@@ -8,14 +8,18 @@ import cn.datax.service.system.service.UserService;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.security.oauth2.common.OAuth2AccessToken
;
import
org.springframework.security.oauth2.common.OAuth2RefreshToken
;
import
org.springframework.security.oauth2.provider.token.TokenStore
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
@Slf4j
@RestController
@RequestMapping
(
"/inner"
)
public
class
LoginController
extends
BaseController
{
@Autowired
...
...
@@ -24,6 +28,18 @@ public class LoginController extends BaseController {
@Autowired
private
TokenStore
tokenStore
;
@Autowired
private
RestTemplate
restTemplate
;
@Value
(
"${security.oauth2.client.access-token-uri}"
)
private
String
accessTokenUri
;
@Value
(
"${security.oauth2.client.client-id}"
)
private
String
clientId
;
@Value
(
"${security.oauth2.client.client-secret}"
)
private
String
clientSecret
;
@Value
(
"${security.oauth2.client.scope}"
)
private
String
scope
;
@DataInner
@GetMapping
(
"/login/username/{username}"
)
public
R
loginByUsername
(
@PathVariable
String
username
)
{
...
...
@@ -31,6 +47,19 @@ public class LoginController extends BaseController {
return
R
.
ok
().
setData
(
userInfo
);
}
@PostMapping
(
"/login"
)
public
R
login
(
String
username
,
String
password
)
{
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
paramsMap
.
set
(
"username"
,
username
);
paramsMap
.
set
(
"password"
,
password
);
paramsMap
.
set
(
"grant_type"
,
"password"
);
paramsMap
.
set
(
"scope"
,
scope
);
paramsMap
.
set
(
"client_id"
,
clientId
);
paramsMap
.
set
(
"client_secret"
,
clientSecret
);
HttpEntity
<
MultiValueMap
<
String
,
String
>>
request
=
new
HttpEntity
(
paramsMap
,
null
);
return
restTemplate
.
postForObject
(
accessTokenUri
,
request
,
R
.
class
);
}
@DeleteMapping
(
"/logout/{token}"
)
public
R
logout
(
@PathVariable
(
"token"
)
String
token
)
{
if
(
StrUtil
.
isBlank
(
token
))
{
...
...
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