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
f173a2a5
Commit
f173a2a5
authored
Nov 05, 2019
by
yw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
88f36356
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
32 deletions
+89
-32
pom.xml
datax-auth/pom.xml
+6
-0
DataxAuthApplication.java
...uth/src/main/java/cn/datax/auth/DataxAuthApplication.java
+2
-0
DataUserDetailService.java
...ain/java/cn/datax/auth/service/DataUserDetailService.java
+18
-1
SwaggerHeaderFilter.java
...ain/java/cn/datax/gateway/filter/SwaggerHeaderFilter.java
+0
-31
UserServiceFeign.java
...a/cn/datax/service/system/api/feign/UserServiceFeign.java
+14
-0
UserServiceFeignFallbackFactory.java
...em/api/feign/factory/UserServiceFeignFallbackFactory.java
+17
-0
UserServiceFeignFallbackImpl.java
...stem/api/feign/fallback/UserServiceFeignFallbackImpl.java
+21
-0
DataxSystemApplication.java
.../java/cn/datax/service/system/DataxSystemApplication.java
+2
-0
UserController.java
...va/cn/datax/service/system/controller/UserController.java
+9
-0
No files found.
datax-auth/pom.xml
View file @
f173a2a5
...
...
@@ -50,6 +50,12 @@
<artifactId>
datax-common-redis
</artifactId>
<version>
${app.version}
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
system-service-api
</artifactId>
<version>
${app.version}
</version>
</dependency>
</dependencies>
<build>
...
...
datax-auth/src/main/java/cn/datax/auth/DataxAuthApplication.java
View file @
f173a2a5
...
...
@@ -9,6 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
@EnableDiscoveryClient
@EnableCircuitBreaker
...
...
@@ -17,6 +18,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableDataMybatis
@EnableDataRedis
@EnableFeignClients
@ComponentScan
({
"cn.datax"
})
@SpringBootApplication
public
class
DataxAuthApplication
{
...
...
datax-auth/src/main/java/cn/datax/auth/service/DataUserDetailService.java
View file @
f173a2a5
package
cn
.
datax
.
auth
.
service
;
import
cn.datax.common.core.R
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.api.feign.UserServiceFeign
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -12,15 +18,26 @@ import org.springframework.stereotype.Service;
import
java.util.HashSet
;
import
java.util.Set
;
@Slf4j
@Service
public
class
DataUserDetailService
implements
UserDetailsService
{
@Autowired
private
UserServiceFeign
userServiceFeign
;
@Override
public
UserDetails
loadUserByUsername
(
String
s
)
throws
UsernameNotFoundException
{
//远程获取用户
R
result
=
userServiceFeign
.
getUserByUsername
(
s
);
log
.
info
(
JSON
.
toJSONString
(
result
));
if
(!
StrUtil
.
equals
(
"admin"
,
s
))
{
throw
new
UsernameNotFoundException
(
s
);
throw
new
UsernameNotFoundException
(
StrUtil
.
format
(
"{}用户不存在"
,
s
)
);
}
// if(result == null || result.getData() == null){
// throw new UsernameNotFoundException(StrUtil.format("{}用户不存在", s));
// }
// UserEntity userEntity = (UserEntity) result.getData();
Set
<
GrantedAuthority
>
grantedAuthorities
=
new
HashSet
<>();
// 可用性 :true:可用 false:不可用
boolean
enabled
=
true
;
...
...
datax-gateway/src/main/java/cn/datax/gateway/filter/SwaggerHeaderFilter.java
deleted
100644 → 0
View file @
88f36356
package
cn
.
datax
.
gateway
.
filter
;
import
cn.datax.gateway.config.SwaggerProvider
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.cloud.gateway.filter.GatewayFilter
;
import
org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.server.ServerWebExchange
;
@Component
public
class
SwaggerHeaderFilter
extends
AbstractGatewayFilterFactory
{
private
static
final
String
HEADER_NAME
=
"X-Forwarded-Prefix"
;
@Override
public
GatewayFilter
apply
(
Object
config
)
{
return
(
exchange
,
chain
)
->
{
ServerHttpRequest
request
=
exchange
.
getRequest
();
String
path
=
request
.
getURI
().
getPath
();
if
(!
StringUtils
.
endsWithIgnoreCase
(
path
,
SwaggerProvider
.
API_URI
))
{
return
chain
.
filter
(
exchange
);
}
String
basePath
=
path
.
substring
(
0
,
path
.
lastIndexOf
(
SwaggerProvider
.
API_URI
));
ServerHttpRequest
newRequest
=
request
.
mutate
().
header
(
HEADER_NAME
,
basePath
).
build
();
ServerWebExchange
newExchange
=
exchange
.
mutate
().
request
(
newRequest
).
build
();
return
chain
.
filter
(
newExchange
);
};
}
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/UserServiceFeign.java
0 → 100644
View file @
f173a2a5
package
cn
.
datax
.
service
.
system
.
api
.
feign
;
import
cn.datax.common.core.R
;
import
cn.datax.service.system.api.feign.factory.UserServiceFeignFallbackFactory
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
@FeignClient
(
contextId
=
"userServiceFeign"
,
value
=
"datax-service-system"
,
fallbackFactory
=
UserServiceFeignFallbackFactory
.
class
)
public
interface
UserServiceFeign
{
@GetMapping
(
"/users/username/{username}"
)
R
getUserByUsername
(
@PathVariable
(
"username"
)
String
username
);
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/factory/UserServiceFeignFallbackFactory.java
0 → 100644
View file @
f173a2a5
package
cn
.
datax
.
service
.
system
.
api
.
feign
.
factory
;
import
cn.datax.service.system.api.feign.UserServiceFeign
;
import
cn.datax.service.system.api.feign.fallback.UserServiceFeignFallbackImpl
;
import
feign.hystrix.FallbackFactory
;
import
org.springframework.stereotype.Component
;
@Component
public
class
UserServiceFeignFallbackFactory
implements
FallbackFactory
<
UserServiceFeign
>
{
@Override
public
UserServiceFeign
create
(
Throwable
throwable
)
{
UserServiceFeignFallbackImpl
userServiceFeignFallbackImpl
=
new
UserServiceFeignFallbackImpl
();
userServiceFeignFallbackImpl
.
setCause
(
throwable
);
return
userServiceFeignFallbackImpl
;
}
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/fallback/UserServiceFeignFallbackImpl.java
0 → 100644
View file @
f173a2a5
package
cn
.
datax
.
service
.
system
.
api
.
feign
.
fallback
;
import
cn.datax.common.core.R
;
import
cn.datax.service.system.api.feign.UserServiceFeign
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
@Slf4j
@Component
public
class
UserServiceFeignFallbackImpl
implements
UserServiceFeign
{
@Setter
private
Throwable
cause
;
@Override
public
R
getUserByUsername
(
String
username
)
{
log
.
error
(
"feign 获取用户信息失败"
,
cause
);
return
null
;
}
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/DataxSystemApplication.java
View file @
f173a2a5
...
...
@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
@EnableDataAuthExceptionHandler
@EnableDataServerProtect
...
...
@@ -19,6 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableFeignClients
@ComponentScan
({
"cn.datax"
})
@SpringBootApplication
public
class
DataxSystemApplication
{
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/UserController.java
View file @
f173a2a5
...
...
@@ -50,6 +50,15 @@ public class UserController extends BaseController {
return
R
.
ok
().
setData
(
userMapper
.
toVO
(
userEntity
));
}
@ApiOperation
(
value
=
"获取用户详细信息"
,
notes
=
"根据url的username来获取用户详细信息"
)
@ApiImplicitParam
(
name
=
"username"
,
value
=
"用户名"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/username/{username}"
)
public
R
getUserByUsername
(
@PathVariable
String
username
)
{
UserEntity
userEntity
=
userService
.
getOne
(
Wrappers
.<
UserEntity
>
query
()
.
lambda
().
eq
(
UserEntity:
:
getUsername
,
username
));
return
R
.
ok
().
setData
(
userEntity
);
}
@ApiOperation
(
value
=
"用户分页查询"
,
notes
=
""
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNum"
,
value
=
"当前页码"
,
required
=
true
,
dataType
=
"int"
,
example
=
"1"
),
...
...
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