Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
ab2a1aff
Commit
ab2a1aff
authored
Nov 28, 2023
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi服务增加feign调用请求头传递配置
parent
23cb67b9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
11 deletions
+91
-11
FeignAuthRequestInterceptor.java
.../amos/api/openapi/config/FeignAuthRequestInterceptor.java
+44
-0
FeignConfiguration.java
...m/yeejoin/amos/api/openapi/config/FeignConfiguration.java
+36
-0
SuperviseController.java
...join/amos/api/openapi/controller/SuperviseController.java
+4
-4
EquipmentCategoryController.java
...odule/ymt/biz/controller/EquipmentCategoryController.java
+7
-7
No files found.
amos-boot-data/amos-boot-data-openapi/src/main/java/com/yeejoin/amos/api/openapi/config/FeignAuthRequestInterceptor.java
0 → 100644
View file @
ab2a1aff
package
com
.
yeejoin
.
amos
.
api
.
openapi
.
config
;
import
feign.RequestInterceptor
;
import
feign.RequestTemplate
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @author DELL
*/
public
class
FeignAuthRequestInterceptor
implements
RequestInterceptor
{
public
FeignAuthRequestInterceptor
()
{
}
@Override
public
void
apply
(
RequestTemplate
template
)
{
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
attributes
!=
null
)
{
HttpServletRequest
request
=
attributes
.
getRequest
();
/* Get token from header */
String
authToken
=
StringUtils
.
isEmpty
(
request
.
getHeader
(
"X-Access-Token"
))
?
request
.
getHeader
(
"token"
)
:
request
.
getHeader
(
"X-Access-Token"
);
/* If token not found get it from request parameter */
String
appKey
=
request
.
getHeader
(
"appKey"
);
String
product
=
request
.
getHeader
(
"product"
);
if
(
authToken
==
null
)
{
authToken
=
request
.
getParameter
(
"token"
);
}
if
(
appKey
==
null
)
{
appKey
=
request
.
getParameter
(
"appKey"
);
}
if
(
product
==
null
)
{
product
=
request
.
getParameter
(
"product"
);
}
template
.
header
(
"X-Access-Token"
,
authToken
);
template
.
header
(
"token"
,
authToken
);
template
.
header
(
"appKey"
,
appKey
);
template
.
header
(
"product"
,
product
);
}
}
}
amos-boot-data/amos-boot-data-openapi/src/main/java/com/yeejoin/amos/api/openapi/config/FeignConfiguration.java
0 → 100644
View file @
ab2a1aff
package
com
.
yeejoin
.
amos
.
api
.
openapi
.
config
;
import
feign.codec.Encoder
;
import
feign.form.spring.SpringFormEncoder
;
import
org.springframework.beans.factory.ObjectFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.http.HttpMessageConverters
;
import
org.springframework.cloud.openfeign.support.SpringEncoder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author DELL
*/
@Configuration
public
class
FeignConfiguration
{
/**
* 创建Feign请求拦截器,在发送请求前设置认证的token,各个微服务将token设置到环境变量中来达到通用
* @return
*/
@Bean
public
FeignAuthRequestInterceptor
basicAuthRequestInterceptor
()
{
return
new
FeignAuthRequestInterceptor
();
}
@Autowired
private
ObjectFactory
<
HttpMessageConverters
>
messageConverters
;
@Bean
public
Encoder
feignComFormEncoder
()
{
return
new
SpringFormEncoder
(
new
SpringEncoder
(
messageConverters
));
}
}
amos-boot-data/amos-boot-data-openapi/src/main/java/com/yeejoin/amos/api/openapi/controller/SuperviseController.java
View file @
ab2a1aff
...
...
@@ -251,7 +251,7 @@ public class SuperviseController {
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"赋码"
)
@PostMapping
(
value
=
"/generation/code"
)
@RestEventTrigger
(
value
=
"openapiLogEventHandler"
)
...
...
@@ -259,7 +259,7 @@ public class SuperviseController {
return
ResponseHelper
.
buildResponse
(
createCodeService
.
createCode
(
map
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"数据状态修改"
)
@PostMapping
(
value
=
"/update/dateStatus"
)
@RestEventTrigger
(
value
=
"openapiLogEventHandler"
)
...
...
@@ -267,7 +267,7 @@ public class SuperviseController {
return
ResponseHelper
.
buildResponse
(
createCodeService
.
updateStatus
(
map
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"检验检测信息"
)
@GetMapping
(
value
=
"/inspectionInfo"
)
@RestEventTrigger
(
value
=
"openapiLogEventHandler"
)
...
...
@@ -275,7 +275,7 @@ public class SuperviseController {
return
ResponseHelper
.
buildResponse
(
inspectionInfoService
.
selectInspect
(
superviseCode
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"监管设备信息"
)
@PostMapping
(
value
=
"/equipment/info"
)
@RestEventTrigger
(
value
=
"openapiLogEventHandler"
)
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/controller/EquipmentCategoryController.java
View file @
ab2a1aff
...
...
@@ -229,7 +229,7 @@ public class EquipmentCategoryController extends BaseController {
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/createSupervisorCode"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"生成监管码和96333码"
,
notes
=
"生成监管码和96333码"
)
public
ResponseModel
<
Object
>
createSupervisorCode
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
...
@@ -240,7 +240,7 @@ public class EquipmentCategoryController extends BaseController {
* 修改数据状态是否显示编辑按钮
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/updateOtherInfo"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"修改数据状态"
,
notes
=
"修改数据状态"
)
public
ResponseModel
<
Object
>
updateOtherInfo
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
...
@@ -560,33 +560,33 @@ public class EquipmentCategoryController extends BaseController {
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/saveSupervisoryData"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"监管设备数据保存"
,
notes
=
"监管设备保存"
)
public
ResponseModel
<
Boolean
>
saveSupervisoryData
(
@RequestBody
EquipmentMessageDto
data
)
{
return
ResponseHelper
.
buildResponse
(
equipmentCategoryServiceImpl
.
saveSupervisoryData
(
data
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/saveConstructionInfoData"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"监管设备施工数据保存"
,
notes
=
"监管设备施工数据保存"
)
public
ResponseModel
<
Boolean
>
saveConstructionInfoData
(
@RequestBody
IdxBizJgConstructionInfo
data
)
{
return
ResponseHelper
.
buildResponse
(
equipmentCategoryServiceImpl
.
saveConstructionInfoData
(
data
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/saveMaintenanceRecordInfoData"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"监管设备维保数据保存"
,
notes
=
"监管设备维保数据保存"
)
public
ResponseModel
<
Boolean
>
saveMaintenanceRecordInfoData
(
@RequestBody
IdxBizJgMaintenanceRecordInfo
data
)
{
return
ResponseHelper
.
buildResponse
(
equipmentCategoryServiceImpl
.
saveMaintenanceRecordInfoData
(
data
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/saveDetectionInfoData"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"监管设备检验检测数据保存"
,
notes
=
"监管设备检验检测数据保存"
)
public
ResponseModel
<
Boolean
>
saveDetectionInfoData
(
@RequestBody
IdxBizJgInspectionDetectionInfo
data
)
{
return
ResponseHelper
.
buildResponse
(
equipmentCategoryServiceImpl
.
saveDetectionInfoData
(
data
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/deleteByRecord"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"数据异常回滚"
,
notes
=
"数据异常回滚"
)
public
ResponseModel
<
Boolean
>
saveDetectionInfoData
(
@RequestParam
(
"record"
)
String
record
)
{
...
...
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