Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
db04d4d6
Commit
db04d4d6
authored
Feb 14, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改根据业务查询部门逻辑
parent
69855c6f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
159 additions
and
38 deletions
+159
-38
base-manager/src/main/java/com/mortals/xhx/module/dept/dao/DeptDao.java
...rc/main/java/com/mortals/xhx/module/dept/dao/DeptDao.java
+9
-0
base-manager/src/main/java/com/mortals/xhx/module/dept/dao/ibatis/DeptDaoImpl.java
...a/com/mortals/xhx/module/dept/dao/ibatis/DeptDaoImpl.java
+15
-3
base-manager/src/main/java/com/mortals/xhx/module/dept/model/vo/DeptVo.java
...ain/java/com/mortals/xhx/module/dept/model/vo/DeptVo.java
+23
-0
base-manager/src/main/java/com/mortals/xhx/module/dept/service/DeptService.java
...java/com/mortals/xhx/module/dept/service/DeptService.java
+17
-10
base-manager/src/main/java/com/mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
...mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
+21
-6
base-manager/src/main/java/com/mortals/xhx/module/dept/web/DeptController.java
.../java/com/mortals/xhx/module/dept/web/DeptController.java
+27
-0
base-manager/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
...r/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
+36
-0
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/AccessLogFilter.java
...om/mortals/xhx/base/framework/filter/AccessLogFilter.java
+11
-12
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
...tals/xhx/base/framework/filter/GatewayResponseFilter.java
+0
-7
No files found.
base-manager/src/main/java/com/mortals/xhx/module/dept/dao/DeptDao.java
View file @
db04d4d6
package
com.mortals.xhx.module.dept.dao
;
package
com.mortals.xhx.module.dept.dao
;
import
com.mortals.framework.dao.ICRUDDao
;
import
com.mortals.framework.dao.ICRUDDao
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.vo.DeptVo
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 部门Dao
* 部门Dao
...
@@ -12,5 +18,8 @@ import java.util.List;
...
@@ -12,5 +18,8 @@ import java.util.List;
*/
*/
public
interface
DeptDao
extends
ICRUDDao
<
DeptEntity
,
Long
>{
public
interface
DeptDao
extends
ICRUDDao
<
DeptEntity
,
Long
>{
String
GET_DEPT_LIST_BY_BUSINESS
=
"getDeptListByBusiness"
;
List
<
DeptVo
>
getDeptListByBusiness
(
DeptQuery
deptQuery
);
}
}
base-manager/src/main/java/com/mortals/xhx/module/dept/dao/ibatis/DeptDaoImpl.java
View file @
db04d4d6
package
com.mortals.xhx.module.dept.dao.ibatis
;
package
com.mortals.xhx.module.dept.dao.ibatis
;
import
com.mortals.framework.model.ParamDto
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.vo.DeptVo
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
com.mortals.xhx.module.dept.dao.DeptDao
;
import
com.mortals.xhx.module.dept.dao.DeptDao
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
...
@@ -15,7 +20,14 @@ import java.util.List;
...
@@ -15,7 +20,14 @@ import java.util.List;
*/
*/
@Repository
(
"deptDao"
)
@Repository
(
"deptDao"
)
public
class
DeptDaoImpl
extends
BaseCRUDDaoMybatis
<
DeptEntity
,
Long
>
implements
DeptDao
{
public
class
DeptDaoImpl
extends
BaseCRUDDaoMybatis
<
DeptEntity
,
Long
>
implements
DeptDao
{
/**
* @param deptQuery
* @return
*/
@Override
public
List
<
DeptVo
>
getDeptListByBusiness
(
DeptQuery
deptQuery
)
{
ParamDto
paramDto
=
this
.
getQueryParam
(
deptQuery
);
List
list
=
this
.
getSqlSession
().
selectList
(
this
.
getSqlId
(
GET_DEPT_LIST_BY_BUSINESS
),
paramDto
);
return
list
;
}
}
}
base-manager/src/main/java/com/mortals/xhx/module/dept/model/vo/DeptVo.java
View file @
db04d4d6
package
com.mortals.xhx.module.dept.model.vo
;
package
com.mortals.xhx.module.dept.model.vo
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -13,5 +14,27 @@ import java.util.List;
...
@@ -13,5 +14,27 @@ import java.util.List;
*/
*/
@Data
@Data
public
class
DeptVo
extends
BaseEntityLong
{
public
class
DeptVo
extends
BaseEntityLong
{
/**
* 部门名称
*/
private
String
name
;
/**
* 部门编号
*/
private
String
deptNumber
;
/**
* 站点业务ID
*/
private
Long
siteBusinessId
;
/**
* 业务名称
*/
private
String
businessName
;
/** 站点业务ID列表 */
private
List
<
Long
>
siteBusinessIdList
;
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/dept/service/DeptService.java
View file @
db04d4d6
package
com.mortals.xhx.module.dept.service
;
package
com.mortals.xhx.module.dept.service
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDCacheService
;
import
com.mortals.framework.service.ICRUDCacheService
;
...
@@ -6,37 +7,43 @@ import com.mortals.framework.service.ICRUDService;
...
@@ -6,37 +7,43 @@ import com.mortals.framework.service.ICRUDService;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.vo.DeptVo
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* DeptService
* DeptService
*
* <p>
* 部门 service接口
* 部门 service接口
*
*
* @author zxfei
* @author zxfei
* @date 2022-01-12
* @date 2022-01-12
*/
*/
public
interface
DeptService
extends
ICRUDCacheService
<
DeptEntity
,
Long
>
{
public
interface
DeptService
extends
ICRUDCacheService
<
DeptEntity
,
Long
>
{
/**
/**
* 同步政务网部门数据
* 同步政务网部门数据
*
* @param context
* @param context
*/
*/
void
syncDept
(
String
areaCode
,
Context
context
);
void
syncDept
(
String
areaCode
,
Context
context
);
/**
/**
* 同步政务网部门数据
* 同步政务网部门数据
*
* @param context
* @param context
*/
*/
Rest
<
String
>
syncDeptBySiteId
(
SiteEntity
siteEntity
,
Context
context
);
Rest
<
String
>
syncDeptBySiteId
(
SiteEntity
siteEntity
,
Context
context
);
Rest
<
List
<
BusinessEntity
>>
getBusinessByDept
(
DeptQuery
deptQuery
,
Context
context
);
Rest
<
List
<
BusinessEntity
>>
getBusinessByDept
(
DeptQuery
deptQuery
,
Context
context
);
void
deleteGovBySiteId
(
Long
siteId
,
Context
context
);
void
deleteGovBySiteId
(
Long
siteId
,
Context
context
);
Rest
<
Map
<
Long
,
List
<
DeptVo
>>>
getDeptListByBusiness
(
DeptQuery
deptQuery
,
Context
context
);
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/dept/service/impl/DeptServiceImpl.java
View file @
db04d4d6
...
@@ -15,6 +15,7 @@ import com.mortals.xhx.module.business.service.BusinessService;
...
@@ -15,6 +15,7 @@ import com.mortals.xhx.module.business.service.BusinessService;
import
com.mortals.xhx.module.dept.dao.DeptDao
;
import
com.mortals.xhx.module.dept.dao.DeptDao
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.vo.DeptVo
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.matters.model.MattersDeptEntity
;
import
com.mortals.xhx.module.matters.model.MattersDeptEntity
;
import
com.mortals.xhx.module.matters.model.MattersDeptQuery
;
import
com.mortals.xhx.module.matters.model.MattersDeptQuery
;
...
@@ -63,7 +64,6 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
...
@@ -63,7 +64,6 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
private
WindowBusinessService
windowBusinessService
;
private
WindowBusinessService
windowBusinessService
;
@Override
@Override
protected
String
getExtKey
(
DeptEntity
data
)
{
protected
String
getExtKey
(
DeptEntity
data
)
{
return
data
.
getDeptNumber
();
return
data
.
getDeptNumber
();
...
@@ -137,7 +137,7 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
...
@@ -137,7 +137,7 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
//查询窗口业务
//查询窗口业务
WindowBusinessQuery
windowBusinessQuery
=
new
WindowBusinessQuery
();
WindowBusinessQuery
windowBusinessQuery
=
new
WindowBusinessQuery
();
List
<
Long
>
windowList
=
windowEntities
.
stream
().
map
(
WindowEntity:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
windowList
=
windowEntities
.
stream
().
map
(
WindowEntity:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
ObjectUtils
.
isEmpty
(
windowList
))
{
if
(
ObjectUtils
.
isEmpty
(
windowList
))
{
return
Rest
.
ok
(
"窗口查询结果为空"
,
Collections
.
EMPTY_LIST
);
return
Rest
.
ok
(
"窗口查询结果为空"
,
Collections
.
EMPTY_LIST
);
}
}
windowBusinessQuery
.
setWindowIdList
(
windowList
);
windowBusinessQuery
.
setWindowIdList
(
windowList
);
...
@@ -145,14 +145,14 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
...
@@ -145,14 +145,14 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
SiteBusinessQuery
siteBusinessQuery
=
new
SiteBusinessQuery
();
SiteBusinessQuery
siteBusinessQuery
=
new
SiteBusinessQuery
();
List
<
Long
>
siteBusinessList
=
windowBusinessEntities
.
stream
().
map
(
WindowBusinessEntity:
:
getSiteBusinessId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
siteBusinessList
=
windowBusinessEntities
.
stream
().
map
(
WindowBusinessEntity:
:
getSiteBusinessId
).
collect
(
Collectors
.
toList
());
if
(
ObjectUtils
.
isEmpty
(
siteBusinessList
))
{
if
(
ObjectUtils
.
isEmpty
(
siteBusinessList
))
{
return
Rest
.
ok
(
"站点业务查询结果为空"
,
Collections
.
EMPTY_LIST
);
return
Rest
.
ok
(
"站点业务查询结果为空"
,
Collections
.
EMPTY_LIST
);
}
}
siteBusinessQuery
.
setBusinessIdList
(
siteBusinessList
);
siteBusinessQuery
.
setBusinessIdList
(
siteBusinessList
);
List
<
SiteBusinessEntity
>
siteBusinessEntities
=
siteBusinessService
.
find
(
siteBusinessQuery
);
List
<
SiteBusinessEntity
>
siteBusinessEntities
=
siteBusinessService
.
find
(
siteBusinessQuery
);
BusinessQuery
businessQuery
=
new
BusinessQuery
();
BusinessQuery
businessQuery
=
new
BusinessQuery
();
List
<
Long
>
businessList
=
siteBusinessEntities
.
stream
().
map
(
SiteBusinessEntity:
:
getBusinessId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
businessList
=
siteBusinessEntities
.
stream
().
map
(
SiteBusinessEntity:
:
getBusinessId
).
collect
(
Collectors
.
toList
());
if
(
ObjectUtils
.
isEmpty
(
businessList
))
{
if
(
ObjectUtils
.
isEmpty
(
businessList
))
{
return
Rest
.
ok
(
"业务查询结果为空"
,
Collections
.
EMPTY_LIST
);
return
Rest
.
ok
(
"业务查询结果为空"
,
Collections
.
EMPTY_LIST
);
}
}
businessQuery
.
setIdList
(
businessList
);
businessQuery
.
setIdList
(
businessList
);
...
@@ -168,6 +168,21 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
...
@@ -168,6 +168,21 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
this
.
dao
.
delete
(
condition
);
this
.
dao
.
delete
(
condition
);
}
}
/**
* @param deptQuery
* @param context
* @return
*/
@Override
public
Rest
<
Map
<
Long
,
List
<
DeptVo
>>>
getDeptListByBusiness
(
DeptQuery
deptQuery
,
Context
context
)
{
List
<
DeptVo
>
deptListByBusiness
=
this
.
dao
.
getDeptListByBusiness
(
deptQuery
);
Map
<
Long
,
List
<
DeptVo
>>
collect
=
deptListByBusiness
.
parallelStream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getSiteBusinessId
()));
return
Rest
.
ok
(
collect
);
}
/**
/**
* @param entity
* @param entity
...
@@ -177,10 +192,10 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
...
@@ -177,10 +192,10 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
@Override
@Override
protected
void
updateAfter
(
DeptEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
updateAfter
(
DeptEntity
entity
,
Context
context
)
throws
AppException
{
List
<
WindowEntity
>
windowEntityList
=
windowService
.
find
(
new
WindowQuery
().
deptId
(
entity
.
getId
()));
List
<
WindowEntity
>
windowEntityList
=
windowService
.
find
(
new
WindowQuery
().
deptId
(
entity
.
getId
()));
windowEntityList
.
forEach
(
item
->
{
windowEntityList
.
forEach
(
item
->
{
item
.
setDeptName
(
entity
.
getName
());
item
.
setDeptName
(
entity
.
getName
());
});
});
windowService
.
update
(
windowEntityList
,
context
);
windowService
.
update
(
windowEntityList
,
context
);
super
.
updateAfter
(
entity
,
context
);
super
.
updateAfter
(
entity
,
context
);
}
}
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/dept/web/DeptController.java
View file @
db04d4d6
...
@@ -12,6 +12,7 @@ import com.mortals.xhx.base.system.param.service.ParamService;
...
@@ -12,6 +12,7 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.business.model.BusinessEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.model.vo.DeptVo
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
...
@@ -123,4 +124,30 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic
...
@@ -123,4 +124,30 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic
}
}
/**
* 根据部门查询业务
*/
@PostMapping
(
value
=
"getDeptListByBusiness"
)
@UnAuth
public
String
getDeptListByBusiness
(
@RequestBody
DeptQuery
deptQuery
)
{
JSONObject
jsonObject
=
new
JSONObject
();
String
busiDesc
=
"根据业务查询部门列表"
+
this
.
getModuleDesc
();
try
{
if
(
ObjectUtils
.
isEmpty
(
deptQuery
.
getSiteBusinessIdList
()))
{
throw
new
AppException
(
"业务id不能为空!"
);
}
Rest
<
Map
<
Long
,
List
<
DeptVo
>>>
rest
=
this
.
service
.
getDeptListByBusiness
(
deptQuery
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
rest
.
getData
());
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
busiDesc
+
"成功!"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取异常"
,
e
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
jsonObject
.
toJSONString
();
}
}
}
\ No newline at end of file
base-manager/src/main/resources/sqlmap/module/dept/DeptMapperExt.xml
0 → 100644
View file @
db04d4d6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper
namespace=
"com.mortals.xhx.module.dept.dao.ibatis.DeptDaoImpl"
>
<!-- 字段和属性映射 -->
<resultMap
type=
"com.mortals.xhx.module.dept.model.vo.DeptVo"
id=
"DeptVo-Map"
>
<id
property=
"id"
column=
"id"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"deptNumber"
column=
"deptNumber"
/>
<result
property=
"siteBusinessId"
column=
"siteBusinessId"
/>
<result
property=
"businessName"
column=
"businessName"
/>
</resultMap>
<!-- 根据业务ids获取部门列表 -->
<select
id=
"getDeptListByBusiness"
parameterType=
"paramDto"
resultMap=
"DeptVo-Map"
>
SELECT
d.id,d.`name`,d.deptNumber,wb.siteBusinessId,wb.businessName
FROM
mortals_sys_dept d
LEFT JOIN mortals_sys_window w ON d.id = w.deptId
LEFT JOIN mortals_sys_window_business wb ON w.id = wb.windowId
<trim
suffixOverrides=
"where"
suffix=
""
>
where 1=1 and
<trim
prefixOverrides=
"and"
prefix=
""
>
<if
test=
"conditionParamRef.containsKey('siteBusinessIdList')"
>
${_conditionType_} siteBusinessId in
<foreach
collection=
"conditionParamRef.siteBusinessIdList"
open=
"("
close=
")"
index=
"index"
item=
"item"
separator=
","
>
#{item}
</foreach>
</if>
</trim>
</trim>
</select>
</mapper>
\ No newline at end of file
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/AccessLogFilter.java
View file @
db04d4d6
...
@@ -3,6 +3,8 @@ package com.mortals.xhx.base.framework.filter;
...
@@ -3,6 +3,8 @@ package com.mortals.xhx.base.framework.filter;
import
cn.hutool.core.net.NetUtil
;
import
cn.hutool.core.net.NetUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.AccessLogPdu
;
import
com.mortals.framework.model.AccessLogPdu
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.common.utils.IpUtils
;
import
com.mortals.xhx.common.utils.IpUtils
;
...
@@ -53,9 +55,6 @@ import java.util.Map;
...
@@ -53,9 +55,6 @@ import java.util.Map;
@Slf4j
@Slf4j
@Component
@Component
public
class
AccessLogFilter
implements
GlobalFilter
,
Ordered
{
public
class
AccessLogFilter
implements
GlobalFilter
,
Ordered
{
// @Autowired
// private AccessLogService accessLogService;
@Value
(
"${spring.application.name:gateway}"
)
@Value
(
"${spring.application.name:gateway}"
)
private
String
appName
;
private
String
appName
;
@Autowired
@Autowired
...
@@ -174,7 +173,6 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
...
@@ -174,7 +173,6 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
ServerHttpRequest
decoratedRequest
=
requestDecorate
(
exchange
,
headers
,
outputMessage
);
ServerHttpRequest
decoratedRequest
=
requestDecorate
(
exchange
,
headers
,
outputMessage
);
// 记录响应日志
// 记录响应日志
ServerHttpResponseDecorator
decoratedResponse
=
recordResponseLog
(
exchange
,
accessLogPdu
);
ServerHttpResponseDecorator
decoratedResponse
=
recordResponseLog
(
exchange
,
accessLogPdu
);
// 记录普通的
// 记录普通的
return
chain
.
filter
(
exchange
.
mutate
().
request
(
decoratedRequest
).
response
(
decoratedResponse
).
build
())
return
chain
.
filter
(
exchange
.
mutate
().
request
(
decoratedRequest
).
response
(
decoratedResponse
).
build
())
.
then
(
Mono
.
fromRunnable
(()
->
{
.
then
(
Mono
.
fromRunnable
(()
->
{
...
@@ -250,23 +248,24 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
...
@@ -250,23 +248,24 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
// 获取响应类型,如果是 json 就打印
// 获取响应类型,如果是 json 就打印
String
originalResponseContentType
=
exchange
.
getAttribute
(
ServerWebExchangeUtils
.
ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR
);
String
originalResponseContentType
=
exchange
.
getAttribute
(
ServerWebExchangeUtils
.
ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR
);
if
(
ObjectUtil
.
equal
(
this
.
getStatusCode
(),
HttpStatus
.
OK
)
if
(
ObjectUtil
.
equal
(
this
.
getStatusCode
(),
HttpStatus
.
OK
)
&&
StringUtils
.
isNotBlank
(
originalResponseContentType
)
&&
StringUtils
.
isNotBlank
(
originalResponseContentType
))
{
&&
originalResponseContentType
.
contains
(
"application/json"
))
{
accessLogPdu
.
setRequestData
(
JSON
.
toJSONString
(
Rest
.
ok
()));
/* Flux<? extends DataBuffer> fluxBody = Flux.from(body);
Flux
<?
extends
DataBuffer
>
fluxBody
=
Flux
.
from
(
body
);
return super.writeWith(fluxBody.buffer().map(dataBuffers -> {
return super.writeWith(fluxBody.buffer().map(dataBuffers -> {
// 合并多个流集合,解决返回体分段传输
// 合并多个流集合,解决返回体分段传输
DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
DataBuffer join = dataBufferFactory.join(dataBuffers);
DataBuffer join = dataBufferFactory.join(dataBuffers);
byte[] content = new byte[join.readableByteCount()];
byte[] content = new byte[join.readableByteCount()];
join.read(content);
join.read(content);
// 释放掉内存
// 释放掉内存
DataBufferUtils.release(join);
DataBufferUtils.release(join);
String
responseResult
=
new
String
(
content
,
StandardCharsets
.
UTF_8
);
accessLogPdu.setRequestData(JSON.toJSONString(Rest.ok()));
accessLogPdu
.
setResponseData
(
StrUtil
.
maxLength
(
responseResult
,
3000
));
//String responseResult = new String(content, StandardCharsets.UTF_8);
//accessLogPdu.setResponseData(StrUtil.maxLength(responseResult,3000));
return bufferFactory.wrap(content);
return bufferFactory.wrap(content);
}));
}));*/
}
else
{
accessLogPdu
.
setRequestData
(
JSON
.
toJSONString
(
Rest
.
fail
()));
}
}
}
}
// if body is not a flux. never got there.
// if body is not a flux. never got there.
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
View file @
db04d4d6
...
@@ -63,13 +63,6 @@ public class GatewayResponseFilter implements GlobalFilter, Ordered {
...
@@ -63,13 +63,6 @@ public class GatewayResponseFilter implements GlobalFilter, Ordered {
join
.
read
(
content
);
join
.
read
(
content
);
DataBufferUtils
.
release
(
join
);
DataBufferUtils
.
release
(
join
);
String
responseData
=
new
String
(
content
,
Charsets
.
UTF_8
);
String
responseData
=
new
String
(
content
,
Charsets
.
UTF_8
);
// List<String> strings = exchange.getResponse().getHeaders()..get(TRACE_ID);
// responseData = beforeBodyWriteInternal(responseData, exchange.getRequest());
// responseData = "\"" + beforeBodyWriteInternal(responseData, exchange.getRequest()) + "\"";
byte
[]
uppedContent
=
new
String
(
responseData
.
getBytes
(),
Charset
.
forName
(
"UTF-8"
)).
getBytes
();
byte
[]
uppedContent
=
new
String
(
responseData
.
getBytes
(),
Charset
.
forName
(
"UTF-8"
)).
getBytes
();
// originalResponse.getHeaders().setContentLength(uppedContent.length);
// originalResponse.getHeaders().setContentLength(uppedContent.length);
// // 设置加密头标识
// // 设置加密头标识
...
...
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