Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
8403ad2b
Commit
8403ad2b
authored
Aug 08, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网关日志限制修改
parent
fb71804a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
113 deletions
+128
-113
AccessGatewayFilter.java
...hub/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
+104
-108
ResponseRecordFilter.java
...ub/wxiaoqi/security/gate/filter/ResponseRecordFilter.java
+1
-2
SmsTemplateDTO.java
.../java/com/xxfc/platform/universal/dto/SmsTemplateDTO.java
+4
-0
CCPRestSmsBiz.java
...n/java/com/xxfc/platform/universal/biz/CCPRestSmsBiz.java
+11
-0
VehicleActiveService.java
...a/com/xxfc/platform/vehicle/biz/VehicleActiveService.java
+8
-3
No files found.
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
View file @
8403ad2b
...
...
@@ -2,8 +2,6 @@ package com.github.wxiaoqi.security.gate.filter;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.log.LogInfo
;
import
com.github.wxiaoqi.security.auth.client.config.ServiceAuthConfig
;
...
...
@@ -27,25 +25,23 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.cloud.gateway.support.DefaultServerRequest
;
import
org.springframework.cloud.gateway.support.ServerWebExchangeUtils
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.reactive.function.server.ServerRequest
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
java.net.URI
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.function.Predicate
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
...
...
@@ -99,7 +95,7 @@ public class AccessGatewayFilter implements GlobalFilter {
log
.
info
(
"check token and user permission...."
);
LinkedHashSet
requiredAttribute
=
serverWebExchange
.
getRequiredAttribute
(
ServerWebExchangeUtils
.
GATEWAY_ORIGINAL_REQUEST_URL_ATTR
);
ServerHttpRequest
request
=
serverWebExchange
.
getRequest
();
setLogService
(
serverWebExchange
,
gatewayFilterChain
);
//
setLogService(serverWebExchange, gatewayFilterChain);
String
requestUri
=
request
.
getPath
().
pathWithinApplication
().
value
();
if
(
requiredAttribute
!=
null
)
{
Iterator
<
URI
>
iterator
=
requiredAttribute
.
iterator
();
...
...
@@ -287,105 +283,105 @@ public class AccessGatewayFilter implements GlobalFilter {
}
public
void
setLogService
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
MediaType
mediaType
=
exchange
.
getRequest
().
getHeaders
().
getContentType
();
ServerRequest
serverRequest
=
new
DefaultServerRequest
(
exchange
);
// 如果是json格式,将body内容转化为object or map 都可
if
(
MediaType
.
APPLICATION_JSON
.
isCompatibleWith
(
mediaType
))
{
Mono
<
Object
>
modifiedBody
=
serverRequest
.
bodyToMono
(
Object
.
class
)
.
flatMap
(
body
->
{
recordLog
(
exchange
.
getRequest
(),
body
);
return
Mono
.
just
(
body
);
});
}
// 如果是表单请求
else
if
(
MediaType
.
APPLICATION_FORM_URLENCODED
.
isCompatibleWith
(
mediaType
))
{
Mono
<
String
>
modifiedBody
=
serverRequest
.
bodyToMono
(
String
.
class
)
// .log("modify_request_mono", Level.INFO)
.
flatMap
(
body
->
{
recordLog
(
exchange
.
getRequest
(),
body
);
return
Mono
.
just
(
body
);
});
}
// TODO 这里未来还可以限制一些格式
// 无法兼容的请求,则不读取body,像Get请求这种
recordLog
(
exchange
.
getRequest
(),
""
);
}
private
void
recordLog
(
ServerHttpRequest
request
,
Object
body
)
{
// 记录要访问的url
if
(!
getNotLogUri
().
contains
(
request
.
getURI
().
getRawPath
()))
{
StringBuilder
builder
=
new
StringBuilder
();
log
.
info
(
"=================请求uri:"
+
request
.
getURI
().
getRawPath
());
// 记录访问的方法
HttpMethod
method
=
request
.
getMethod
();
if
(
null
!=
method
)
{
log
.
info
(
"=================请求方法:"
+
method
.
name
());
}
request
.
getHeaders
().
add
(
"uuid"
,
UUID
.
randomUUID
().
toString
());
// 记录头部信息
builder
.
append
(
", header { "
);
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
request
.
getHeaders
().
entrySet
())
{
builder
.
append
(
entry
.
getKey
()).
append
(
":"
).
append
(
StringUtils
.
join
(
entry
.
getValue
(),
","
)).
append
(
","
);
if
(
"uuid"
.
equals
(
entry
.
getKey
()))
{
if
(
entry
.
getValue
()
!=
null
&&
entry
.
getValue
().
size
()
>
0
)
{
log
.
info
(
"=================请求方法uuid:"
+
entry
.
getValue
().
get
(
0
));
}
}
if
(
"Authorization"
.
equals
(
entry
.
getKey
()))
{
if
(
entry
.
getValue
()
!=
null
&&
entry
.
getValue
().
size
()
>
0
)
{
getAdminUserInfo
(
entry
.
getValue
().
get
(
0
));
}
}
}
log
.
info
(
"=================请求头header:"
+
builder
.
toString
());
// 记录参数
builder
=
new
StringBuilder
();
// 处理get的请求
if
(
null
!=
method
&&
HttpMethod
.
GET
.
matches
(
method
.
name
()))
{
// 记录请求的参数信息 针对GET 请求
MultiValueMap
<
String
,
String
>
queryParams
=
request
.
getQueryParams
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
queryParams
.
entrySet
())
{
builder
.
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
StringUtils
.
join
(
entry
.
getValue
(),
","
)).
append
(
","
);
}
}
else
{
// 从body中读取参数
builder
.
append
(
body
);
}
log
.
info
(
"=================请求参数:"
+
builder
.
toString
());
}
}
private
void
getAdminUserInfo
(
String
token
)
{
if
(
token
!=
null
)
{
UserDTO
userDTO
=
userFeign
.
userinfoByToken
(
token
).
getData
();
if
(
userDTO
!=
null
)
{
log
.
info
(
"=================后台用户名:username = {}"
,
userDTO
.
getUsername
());
log
.
info
(
"=================后台姓名: name = {}"
,
userDTO
.
getName
());
}
else
{
AppUserDTO
appUserDTO
=
userFeign
.
userDetailByToken
(
token
).
getData
();
if
(
appUserDTO
!=
null
)
{
log
.
info
(
"=================APP用户名:userId = {}"
,
appUserDTO
.
getUserid
());
log
.
info
(
"=================APP姓名: name = {}"
,
appUserDTO
.
getRealname
());
log
.
info
(
"=================APP手机号: phone = {}"
,
appUserDTO
.
getUsername
());
}
}
}
}
@Value
(
"${logback.ignore-log-path}"
)
String
[]
path
;
public
List
<
String
>
getNotLogUri
()
{
return
Arrays
.
asList
(
path
);
}
//
public void setLogService(ServerWebExchange exchange, GatewayFilterChain chain) {
//
MediaType mediaType = exchange.getRequest().getHeaders().getContentType();
//
ServerRequest serverRequest = new DefaultServerRequest(exchange);
//
//
// 如果是json格式,将body内容转化为object or map 都可
//
if (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType)) {
//
Mono<Object> modifiedBody = serverRequest.bodyToMono(Object.class)
//
.flatMap(body -> {
//
recordLog(exchange.getRequest(), body);
//
return Mono.just(body);
//
});
//
//
}
//
// 如果是表单请求
//
else if (MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)) {
//
Mono<String> modifiedBody = serverRequest.bodyToMono(String.class)
//
// .log("modify_request_mono", Level.INFO)
//
.flatMap(body -> {
//
recordLog(exchange.getRequest(), body);
//
//
return Mono.just(body);
//
});
//
//
}
//
// TODO 这里未来还可以限制一些格式
//
//
// 无法兼容的请求,则不读取body,像Get请求这种
//
recordLog(exchange.getRequest(), "");
//
}
//
//
private void recordLog(ServerHttpRequest request, Object body) {
//
// 记录要访问的url
//
if (!getNotLogUri().contains(request.getURI().getRawPath())) {
//
//
//
StringBuilder builder = new StringBuilder();
//
log.info("=================请求uri:" + request.getURI().getRawPath());
//
// 记录访问的方法
//
HttpMethod method = request.getMethod();
//
if (null != method) {
//
log.info("=================请求方法:" + method.name());
//
}
//
request.getHeaders().add("uuid", UUID.randomUUID().toString());
//
// 记录头部信息
//
builder.append(", header { ");
//
for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
//
builder.append(entry.getKey()).append(":").append(StringUtils.join(entry.getValue(), ",")).append(",");
//
if("uuid".equals(entry.getKey())) {
//
if(entry.getValue() != null && entry.getValue().size() > 0) {
//
log.info("=================请求方法uuid:" + entry.getValue().get(0));
//
}
//
}
//
if("Authorization".equals(entry.getKey())) {
//
if(entry.getValue() != null && entry.getValue().size() > 0) {
//
getAdminUserInfo(entry.getValue().get(0));
//
}
//
//
}
//
}
//
log.info("=================请求头header:" + builder.toString());
//
// 记录参数
//
builder = new StringBuilder();
//
// 处理get的请求
//
if (null != method && HttpMethod.GET.matches(method.name())) {
//
// 记录请求的参数信息 针对GET 请求
//
MultiValueMap<String, String> queryParams = request.getQueryParams();
//
for (Map.Entry<String, List<String>> entry : queryParams.entrySet()) {
//
builder.append(entry.getKey()).append("=").append(StringUtils.join(entry.getValue(), ",")).append(",");
//
}
//
} else {
//
// 从body中读取参数
//
builder.append(body);
//
}
//
log.info("=================请求参数:" + builder.toString());
//
}
//
}
//
//
private void getAdminUserInfo(String token) {
//
if(token !=null) {
//
UserDTO userDTO = userFeign.userinfoByToken(token).getData();
//
if(userDTO != null) {
//
log.info("=================后台用户名:username = {}", userDTO.getUsername());
//
log.info("=================后台姓名: name = {}", userDTO.getName());
//
} else {
//
AppUserDTO appUserDTO = userFeign.userDetailByToken(token).getData();
//
if(appUserDTO != null) {
//
log.info("=================APP用户名:userId = {}", appUserDTO.getUserid());
//
log.info("=================APP姓名: name = {}", appUserDTO.getRealname());
//
log.info("=================APP手机号: phone = {}", appUserDTO.getUsername());
//
}
//
}
//
}
//
}
//
//
@Value("${logback.ignore-log-path}")
//
String[] path;
//
public List<String> getNotLogUri() {
//
return Arrays.asList(path);
//
}
}
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/filter/ResponseRecordFilter.java
View file @
8403ad2b
...
...
@@ -19,7 +19,6 @@ import org.springframework.http.codec.ClientCodecConfigurer;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonEncoder
;
import
org.springframework.http.server.reactive.ServerHttpResponseDecorator
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.reactive.function.BodyInserter
;
import
org.springframework.web.reactive.function.BodyInserters
;
...
...
@@ -31,7 +30,7 @@ import reactor.core.publisher.Mono;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
@Component
//
@Component
@Slf4j
public
class
ResponseRecordFilter
implements
GlobalFilter
,
Ordered
{
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/dto/SmsTemplateDTO.java
View file @
8403ad2b
...
...
@@ -62,6 +62,10 @@ public class SmsTemplateDTO {
public
static
final
int
REFUND_A
=
22
;
//违章押金退还
public
static
final
int
REFUND_B
=
23
;
//旅游内部通知(客服)
public
static
final
int
PAY_H
=
24
;
//取消旅游订单(客服)
public
static
final
int
CANCEL_F
=
25
;
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/CCPRestSmsBiz.java
View file @
8403ad2b
...
...
@@ -58,6 +58,11 @@ public class CCPRestSmsBiz{
//违章押金退还 23
public
static
final
String
TEMPLATE_ID_FINISH_B
=
"460773"
;
//旅游内部通知(客服)24
public
static
final
String
TEMPLATE_ID_PAY_H
=
"461421"
;
//取消旅游订单(客服)25
public
static
final
String
TEMPLATE_ID_CANCEL_F
=
"461424"
;
...
...
@@ -131,6 +136,12 @@ public class CCPRestSmsBiz{
case
23
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_FINISH_B
);
break
;
case
24
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_PAY_H
);
break
;
case
25
:
CCPRestSmsUtils
.
sendTemplateSMS
(
phoneNumbers
,
params
,
TEMPLATE_ID_CANCEL_F
);
break
;
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleActiveService.java
View file @
8403ad2b
...
...
@@ -82,7 +82,7 @@ public class VehicleActiveService {
}
//修改预约记录状态
if
(
departureVo
.
getBookRecordId
()
!=
null
)
{
updateBookRecordStatus
(
departureVo
.
getBookRecordId
());
updateBookRecordStatus
(
departureVo
.
getBookRecordId
()
,
1
);
}
VehicleDepartureLogVo
vehicleDepartureLogVo
=
vehicleDepartureLogMapper
.
selectByBookRecordId
(
departureVo
.
getBookRecordId
());
if
(
vehicleDepartureLogVo
!=
null
)
{
...
...
@@ -154,7 +154,7 @@ public class VehicleActiveService {
}
if
(
arrivalVo
.
getBookRecordId
()
!=
null
)
{
updateBookRecordStatus
(
arrivalVo
.
getBookRecordId
());
updateBookRecordStatus
(
arrivalVo
.
getBookRecordId
()
,
2
);
}
...
...
@@ -192,10 +192,15 @@ public class VehicleActiveService {
}
}
public
void
updateBookRecordStatus
(
Integer
bookRecordId
)
{
public
void
updateBookRecordStatus
(
Integer
bookRecordId
,
Integer
type
)
{
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
if
(
vehicleBookRecord
!=
null
)
{
vehicleBookRecord
.
setStatus
(
VehicleBookRecordStatus
.
LIFTED
.
getCode
());
if
(
type
==
1
)
{
vehicleBookRecord
.
setActualStartDate
(
new
Date
());
}
else
{
vehicleBookRecord
.
setActualEndDate
(
new
Date
());
}
vehicleBookRecordBiz
.
updateSelectiveByIdRe
(
vehicleBookRecord
);
}
else
{
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getDesc
(),
...
...
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