Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
4a36c309
Commit
4a36c309
authored
Aug 20, 2019
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跨域问题
parent
4c1df48c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
7 deletions
+43
-7
RoleLoadAspect.java
...antgroup/cashloanflowboss/core/aspect/RoleLoadAspect.java
+19
-7
CorsConfiguration.java
...ashloanflowboss/core/configuration/CorsConfiguration.java
+24
-0
No files found.
src/main/java/cn/quantgroup/cashloanflowboss/core/aspect/RoleLoadAspect.java
View file @
4a36c309
...
@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.core.aspect;
...
@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.core.aspect;
import
cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfVo
;
import
cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfVo
;
import
cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil
;
import
cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil
;
import
cn.quantgroup.cashloanflowboss.api.log.model.Principal
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
cn.quantgroup.cashloanflowboss.core.annotation.ChannelIdInit
;
import
cn.quantgroup.cashloanflowboss.core.annotation.ChannelIdInit
;
import
cn.quantgroup.cashloanflowboss.core.annotation.CheckChannelRole
;
import
cn.quantgroup.cashloanflowboss.core.annotation.CheckChannelRole
;
...
@@ -57,20 +58,31 @@ public class RoleLoadAspect {
...
@@ -57,20 +58,31 @@ public class RoleLoadAspect {
MethodSignature
methodSignature
=
(
MethodSignature
)
pjp
.
getSignature
();
MethodSignature
methodSignature
=
(
MethodSignature
)
pjp
.
getSignature
();
Method
method
=
methodSignature
.
getMethod
();
Method
method
=
methodSignature
.
getMethod
();
Principal
principal
=
Application
.
getPrincipal
();
if
(
principal
==
null
)
{
try
{
// 没有登录 登录检查控制
return
pjp
.
proceed
(
args
);
}
catch
(
Throwable
throwable
)
{
log
.
error
(
"请求失败,e={}"
,
ExceptionUtils
.
getStackTrace
(
throwable
));
return
Result
.
buildFial
();
}
}
// 如果是渠道用户登陆 默认加载channelId
// 如果是渠道用户登陆 默认加载channelId
ChannelIdInit
annotation
=
method
.
getAnnotation
(
ChannelIdInit
.
class
);
ChannelIdInit
annotation
=
method
.
getAnnotation
(
ChannelIdInit
.
class
);
if
(
annotation
!=
null
&&
Application
.
getPrincipal
()
.
isChannel
())
{
if
(
annotation
!=
null
&&
principal
.
isChannel
())
{
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
if
(
ChannelConfUtil
.
channelIdParamName
.
equals
(
paramNames
[
i
]))
{
if
(
ChannelConfUtil
.
channelIdParamName
.
equals
(
paramNames
[
i
]))
{
args
[
i
]
=
Application
.
getPrincipal
()
.
getChannelId
();
args
[
i
]
=
principal
.
getChannelId
();
}
}
}
}
}
}
// 如果是渠道用户登陆,参数中channelId 不是登陆用户channelId,返回 拒绝请求
// 如果是渠道用户登陆,参数中channelId 不是登陆用户channelId,返回 拒绝请求
CheckChannelRole
checkChannelRole
=
method
.
getAnnotation
(
CheckChannelRole
.
class
);
CheckChannelRole
checkChannelRole
=
method
.
getAnnotation
(
CheckChannelRole
.
class
);
if
(
checkChannelRole
!=
null
&&
Application
.
getPrincipal
()
.
isChannel
())
{
if
(
checkChannelRole
!=
null
&&
principal
.
isChannel
())
{
Long
requestChannelId
=
-
1L
;
Long
requestChannelId
=
-
1L
;
if
(!
checkChannelRole
.
isObjParam
())
{
if
(!
checkChannelRole
.
isObjParam
())
{
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
...
@@ -84,7 +96,7 @@ public class RoleLoadAspect {
...
@@ -84,7 +96,7 @@ public class RoleLoadAspect {
return
Result
.
buildFial
(
ApplicationStatus
.
ARGUMENT_VALID_EXCEPTION
);
return
Result
.
buildFial
(
ApplicationStatus
.
ARGUMENT_VALID_EXCEPTION
);
}
}
requestChannelId
=
Long
.
valueOf
(
String
.
valueOf
(
requestChannelIdObj
));
requestChannelId
=
Long
.
valueOf
(
String
.
valueOf
(
requestChannelIdObj
));
if
(!
Application
.
getPrincipal
()
.
isSameChannel
(
requestChannelId
))
{
if
(!
principal
.
isSameChannel
(
requestChannelId
))
{
log
.
info
(
"[CheckChannelRole]渠道用户,登陆channelId与查询channelId不是同一个"
);
log
.
info
(
"[CheckChannelRole]渠道用户,登陆channelId与查询channelId不是同一个"
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
}
}
...
@@ -102,7 +114,7 @@ public class RoleLoadAspect {
...
@@ -102,7 +114,7 @@ public class RoleLoadAspect {
requestChannelId
=
channelIdTemp
;
requestChannelId
=
channelIdTemp
;
}
}
}
}
if
(!
Application
.
getPrincipal
()
.
isSameChannel
(
requestChannelId
))
{
if
(!
principal
.
isSameChannel
(
requestChannelId
))
{
log
.
info
(
"[CheckChannelRole]渠道用户,登陆channelId与查询channelId不是同一个"
);
log
.
info
(
"[CheckChannelRole]渠道用户,登陆channelId与查询channelId不是同一个"
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
}
}
...
@@ -111,7 +123,7 @@ public class RoleLoadAspect {
...
@@ -111,7 +123,7 @@ public class RoleLoadAspect {
// 如果是渠道用户登陆,参数中channelOrderNumber 不是登陆用户channelOrderNumber,返回 拒绝请求
// 如果是渠道用户登陆,参数中channelOrderNumber 不是登陆用户channelOrderNumber,返回 拒绝请求
CheckChannelRoleByChannelOrderNumber
checkChannelRoleByChannelOrderNumber
=
method
.
getAnnotation
(
CheckChannelRoleByChannelOrderNumber
.
class
);
CheckChannelRoleByChannelOrderNumber
checkChannelRoleByChannelOrderNumber
=
method
.
getAnnotation
(
CheckChannelRoleByChannelOrderNumber
.
class
);
if
(
checkChannelRoleByChannelOrderNumber
!=
null
&&
Application
.
getPrincipal
()
.
isChannel
())
{
if
(
checkChannelRoleByChannelOrderNumber
!=
null
&&
principal
.
isChannel
())
{
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
String
channelOrderNumber
=
""
;
String
channelOrderNumber
=
""
;
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
...
@@ -128,7 +140,7 @@ public class RoleLoadAspect {
...
@@ -128,7 +140,7 @@ public class RoleLoadAspect {
log
.
info
(
"[CheckChannelRoleByChannelOrderNumber]无channelOrderNumber数据,channelOrderNumber={}"
,
channelOrderNumber
);
log
.
info
(
"[CheckChannelRoleByChannelOrderNumber]无channelOrderNumber数据,channelOrderNumber={}"
,
channelOrderNumber
);
return
Result
.
buildFial
(
ApplicationStatus
.
ARGUMENT_VALID_EXCEPTION
,
"未找到该订单"
);
return
Result
.
buildFial
(
ApplicationStatus
.
ARGUMENT_VALID_EXCEPTION
,
"未找到该订单"
);
}
}
if
(!
clfOrderMapping
.
getRegisteredFrom
().
equals
(
Application
.
getPrincipal
()
.
getChannelId
()))
{
if
(!
clfOrderMapping
.
getRegisteredFrom
().
equals
(
principal
.
getChannelId
()))
{
log
.
info
(
"[CheckChannelRoleByChannelOrderNumber]不是该渠道的订单,channelOrderNumber={}"
,
channelOrderNumber
);
log
.
info
(
"[CheckChannelRoleByChannelOrderNumber]不是该渠道的订单,channelOrderNumber={}"
,
channelOrderNumber
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
}
}
...
...
src/main/java/cn/quantgroup/cashloanflowboss/core/configuration/CorsConfiguration.java
0 → 100644
View file @
4a36c309
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
/**
* function:
* date: 2019/8/20
*
* @author: suntao
*/
//@Configuration
public
class
CorsConfiguration
{
//extends WebMvcConfigurerAdapter{
//@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedMethods
(
"*"
)
.
allowedOrigins
(
"*"
)
.
allowedHeaders
(
"*"
);
//super.addCorsMappings(registry);
}
}
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