Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
iClear-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
zelong.shao
2023-10-13 16:38:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
921a7b04f715a546c1f68fc36ecf156734b2efb5
921a7b04
1 parent
047824d7
api获取appid改成查数据库改回缓存
2023年10月13日16:38:07 szl
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
21 deletions
src/main/java/com/erry/iclear/dateInterface/interceptor/HsCodeInterceptor.java
src/main/java/com/erry/iclear/dateInterface/interceptor/SignInterceptor.java
src/main/java/com/erry/iclear/dateInterface/interceptor/HsCodeInterceptor.java
View file @
921a7b0
package
com
.
erry
.
iclear
.
dateInterface
.
interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.erry.iclear.dateInterface.api.response.ResultHsCode
;
import
com.erry.iclear.dateInterface.entity.AppInfo
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.repository.AppInfoRepository
;
import
com.erry.iclear.dateInterface.api.response.ResultHsCode
;
import
com.erry.iclear.dateInterface.common.Constant
;
import
com.erry.iclear.dateInterface.util.SHA256Util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
...
...
@@ -17,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.HashMap
;
/**
* @author Administrator
...
...
@@ -24,8 +23,6 @@ import java.io.PrintWriter;
@Component
@Slf4j
public
class
HsCodeInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
AppInfoRepository
appInfoRepository
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
o
)
throws
Exception
{
...
...
@@ -57,14 +54,13 @@ public class HsCodeInterceptor extends HandlerInterceptorAdapter {
return
false
;
}
// HashMap<String,String> secretMap = Constant.appIdSecurityCache.get(appId);
AppInfo
oneEnableAppInfo
=
appInfoRepository
.
getOneEnableAppInfo
(
appId
);
if
(
oneEnableAppInfo
==
null
){
HashMap
<
String
,
String
>
secretMap
=
Constant
.
appIdSecurityCache
.
get
(
appId
);
if
(
secretMap
==
null
){
this
.
returnJson
(
response
,
false
,
ErrorCodeEnum
.
ERROR_10001
.
getCode
(),
ErrorCodeEnum
.
ERROR_10001
.
getName
());
return
false
;
}
String
secretInSys
=
oneEnableAppInfo
.
getSecurity
(
);
String
secretInSys
=
secretMap
.
get
(
appkey
);
if
(
StringUtils
.
isBlank
(
secretInSys
))
{
this
.
returnJson
(
response
,
false
,
ErrorCodeEnum
.
ERROR_10002
.
getCode
(),
ErrorCodeEnum
.
ERROR_10002
.
getName
());
return
false
;
...
...
src/main/java/com/erry/iclear/dateInterface/interceptor/SignInterceptor.java
View file @
921a7b0
package
com
.
erry
.
iclear
.
dateInterface
.
interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.erry.iclear.dateInterface.api.response.ResultRS
;
import
com.erry.iclear.dateInterface.entity.AppInfo
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.repository.AppInfoRepository
;
import
com.erry.iclear.dateInterface.api.response.ResultRS
;
import
com.erry.iclear.dateInterface.common.Constant
;
import
com.erry.iclear.dateInterface.util.SHA256Util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
...
...
@@ -17,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.HashMap
;
/**
* @author Administrator
...
...
@@ -24,8 +23,7 @@ import java.io.PrintWriter;
@Component
@Slf4j
public
class
SignInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
AppInfoRepository
appInfoRepository
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
o
)
throws
Exception
{
String
appId
=
(
String
)
request
.
getHeader
(
"Appid"
);
...
...
@@ -57,15 +55,13 @@ public class SignInterceptor extends HandlerInterceptorAdapter {
return
false
;
}
// HashMap<String,String> secretMap = Constant.appIdSecurityCache.get(appId);
AppInfo
oneEnableAppInfo
=
appInfoRepository
.
getOneEnableAppInfo
(
appId
);
if
(
oneEnableAppInfo
==
null
){
HashMap
<
String
,
String
>
secretMap
=
Constant
.
appIdSecurityCache
.
get
(
appId
);
if
(
secretMap
==
null
){
this
.
returnJson
(
response
,
false
,
ErrorCodeEnum
.
ERROR_10001
.
getCode
(),
ErrorCodeEnum
.
ERROR_10001
.
getName
());
return
false
;
}
String
secretInSys
=
oneEnableAppInfo
.
getSecurity
(
);
String
secretInSys
=
secretMap
.
get
(
appkey
);
if
(
StringUtils
.
isBlank
(
secretInSys
))
{
this
.
returnJson
(
response
,
false
,
ErrorCodeEnum
.
ERROR_10002
.
getCode
(),
ErrorCodeEnum
.
ERROR_10002
.
getName
());
return
false
;
...
...
Please
register
or
login
to post a comment