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
739cd248
Commit
739cd248
authored
Aug 07, 2019
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
渠道配置查询 编辑
parent
0aeda08d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
130 additions
and
7 deletions
+130
-7
ChannelConfController.java
...lowboss/api/channel/controller/ChannelConfController.java
+2
-1
ChannelConfBaseModel.java
...hloanflowboss/api/channel/model/ChannelConfBaseModel.java
+3
-3
ChannelConfUtil.java
...up/cashloanflowboss/api/channel/util/ChannelConfUtil.java
+4
-3
CheckChannelRole.java
...up/cashloanflowboss/core/annotation/CheckChannelRole.java
+18
-0
RoleLoadAspect.java
...antgroup/cashloanflowboss/core/aspect/RoleLoadAspect.java
+93
-0
Result.java
...java/cn/quantgroup/cashloanflowboss/core/base/Result.java
+10
-0
No files found.
src/main/java/cn/quantgroup/cashloanflowboss/api/channel/controller/ChannelConfController.java
View file @
739cd248
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfBaseModel;
import
cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfVo
;
import
cn.quantgroup.cashloanflowboss.core.annotation.ChannelIdInit
;
import
cn.quantgroup.cashloanflowboss.api.channel.service.ChannelConfService
;
import
cn.quantgroup.cashloanflowboss.core.annotation.CheckChannelRole
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
cn.quantgroup.cashloanflowboss.utils.JSONTools
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -41,6 +42,7 @@ public class ChannelConfController {
}
@CheckChannelRole
@GetMapping
(
"/cfg/info"
)
public
Result
getChannelConfInfo
(
Long
channelId
)
{
return
Result
.
buildSuccess
(
channelConfService
.
getChannelConf
(
channelId
),
"success"
);
...
...
@@ -49,7 +51,6 @@ public class ChannelConfController {
@PostMapping
(
"/cfg/info"
)
public
Result
editChannelConfInfo
(
@RequestBody
@Valid
ChannelConfVo
channelConfVo
)
{
return
Result
.
buildSuccess
(
channelConfService
.
editChannelConfInfo
(
channelConfVo
));
}
...
...
src/main/java/cn/quantgroup/cashloanflowboss/api/channel/model/ChannelConfBaseModel.java
View file @
739cd248
...
...
@@ -16,9 +16,9 @@ public class ChannelConfBaseModel {
private
String
channelName
;
private
String
channelCode
;
private
String
env
;
private
String
fundId
;
private
String
p2pFundId
;
private
String
bizType
;
private
Integer
fundId
;
private
Integer
p2pFundId
;
private
Integer
bizType
;
private
String
aesKey
;
private
String
md5Key
;
private
String
authCode
;
...
...
src/main/java/cn/quantgroup/cashloanflowboss/api/channel/util/ChannelConfUtil.java
View file @
739cd248
...
...
@@ -27,6 +27,9 @@ import org.springframework.beans.BeanUtils;
public
class
ChannelConfUtil
{
public
static
final
String
channelRoleName
=
"channel_role"
;
public
static
final
String
channelIdParamName
=
"channelId"
;
public
static
ChannelConfVo
channelConfConvertVOModel
(
ChannelConf
channelConf
)
{
ChannelConfBaseModel
channelConfBaseModel
=
new
ChannelConfBaseModel
();
BeanUtils
.
copyProperties
(
channelConf
,
channelConfBaseModel
);
...
...
@@ -34,8 +37,6 @@ public class ChannelConfUtil {
ChannelConfAddModel
channelConfAddModel
=
new
ChannelConfAddModel
();
BeanUtils
.
copyProperties
(
channelConf
,
channelConfAddModel
);
channelConfAddModel
.
setEnvPath
(
String
.
format
(
"http://qapi-%s.liangkebang.net/"
,
channelConfBaseModel
.
getEnv
()));
ChannelConfVo
channelConfVo
=
new
ChannelConfVo
();
channelConfVo
.
setBasicInfo
(
channelConfBaseModel
);
channelConfVo
.
setAddInfo
(
channelConfAddModel
);
...
...
@@ -49,10 +50,10 @@ public class ChannelConfUtil {
ChannelConfAddModel
channelConfAddModel
=
channelConfVo
.
getAddInfo
();
ChannelConf
channelConf
=
new
ChannelConf
();
BeanUtils
.
copyProperties
(
channelConfBaseModel
,
channelConf
);
channelConf
.
setChannelIp
(
channelConfAddModel
.
getChannelIp
());
channelConf
.
setEnvPath
(
String
.
format
(
"http://qapi-%s.liangkebang.net/"
,
channelConfBaseModel
.
getEnv
()));
channelConf
.
setApproveCallBackUrl
(
channelConfAddModel
.
getApproveCallBackUrl
());
channelConf
.
setOrderStatusCallBackUrl
(
channelConfAddModel
.
getOrderStatusCallBackUrl
());
channelConf
.
setRepayResultCallBackUrl
(
channelConfAddModel
.
getRepayResultCallBackUrl
());
...
...
src/main/java/cn/quantgroup/cashloanflowboss/core/annotation/CheckChannelRole.java
0 → 100644
View file @
739cd248
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
annotation
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.
METHOD
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* function:
* date: 2019/8/6
*
* @author: suntao
*/
@Target
({
METHOD
})
@Retention
(
RUNTIME
)
public
@interface
CheckChannelRole
{
}
src/main/java/cn/quantgroup/cashloanflowboss/core/aspect/Role
Data
LoadAspect.java
→
src/main/java/cn/quantgroup/cashloanflowboss/core/aspect/RoleLoadAspect.java
View file @
739cd248
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
aspect
;
import
cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil
;
import
cn.quantgroup.cashloanflowboss.api.user.model.UserSessionInfo
;
import
cn.quantgroup.cashloanflowboss.api.user.service.UserSessionService
;
import
cn.quantgroup.cashloanflowboss.core.annotation.ChannelIdInit
;
import
cn.quantgroup.cashloanflowboss.core.annotation.CheckChannelRole
;
import
cn.quantgroup.cashloanflowboss.core.base.BossPageImpl
;
import
cn.quantgroup.cashloanflowboss.core.base.Result
;
import
cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
...
...
@@ -29,7 +33,7 @@ import java.lang.reflect.Method;
@Component
@Aspect
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
Role
Data
LoadAspect
{
public
class
RoleLoadAspect
{
@Autowired
private
UserSessionService
userSessionService
;
...
...
@@ -42,23 +46,46 @@ public class RoleDataLoadAspect {
Object
[]
args
=
pjp
.
getArgs
();
MethodSignature
methodSignature
=
(
MethodSignature
)
pjp
.
getSignature
();
Method
method
=
methodSignature
.
getMethod
();
// 如果是渠道用户登陆 默认加载channelId
ChannelIdInit
annotation
=
method
.
getAnnotation
(
ChannelIdInit
.
class
);
UserSessionInfo
userSessionInfo
=
userSessionService
.
findUserSessionInfo
();
// todo channel_role 定义为常量吧
if
(
annotation
!=
null
&&
"channel_role"
.
equals
(
userSessionInfo
.
getRoleInfo
().
getRoleName
()))
{
final
Long
channelIdInSession
=
userSessionInfo
.
getChannelId
();
if
(
annotation
!=
null
&&
ChannelConfUtil
.
channelRoleName
.
equals
(
userSessionInfo
.
getRoleInfo
().
getRoleName
()))
{
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
if
(
ChannelConfUtil
.
channelIdParamName
.
equals
(
paramNames
[
i
]))
{
args
[
i
]
=
channelIdInSession
;
}
}
}
// 如果是渠道用户登陆,参数中channelId 不是登陆用户channelId,返回 拒绝请求
CheckChannelRole
checkChannelRole
=
method
.
getAnnotation
(
CheckChannelRole
.
class
);
if
(
checkChannelRole
!=
null
&&
ChannelConfUtil
.
channelRoleName
.
equals
(
userSessionInfo
.
getRoleInfo
().
getRoleName
()))
{
String
[]
paramNames
=
((
CodeSignature
)
pjp
.
getSignature
()).
getParameterNames
();
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
if
(
"channelId"
.
equals
(
paramNames
[
i
]))
{
args
[
i
]
=
userSessionInfo
.
getChannelId
();
if
(
ChannelConfUtil
.
channelIdParamName
.
equals
(
paramNames
[
i
]))
{
Object
requestChannelIdObj
=
args
[
i
];
if
(
requestChannelIdObj
==
null
)
{
log
.
info
(
"[CheckChannelRole]无channelId数据"
);
return
Result
.
buildFial
(
ApplicationStatus
.
ARGUMENT_VALID_EXCEPTION
);
}
final
Integer
channelIdInteger
=
Integer
.
valueOf
(
String
.
valueOf
(
requestChannelIdObj
));
if
(
channelIdInteger
!=
channelIdInSession
.
intValue
())
{
log
.
info
(
"[CheckChannelRole]渠道用户,登陆channelId与查询channelId不是同一个"
);
return
Result
.
buildFial
(
ApplicationStatus
.
INVALID_AUTHORITY
);
}
}
}
}
try
{
return
pjp
.
proceed
(
args
);
}
catch
(
Throwable
throwable
)
{
log
.
error
(
"
查询渠道列表错误
e={}"
,
ExceptionUtils
.
getStackTrace
(
throwable
));
return
new
BossPageImpl
<>
();
log
.
error
(
"
请求失败,
e={}"
,
ExceptionUtils
.
getStackTrace
(
throwable
));
return
Result
.
buildFial
();
}
}
...
...
src/main/java/cn/quantgroup/cashloanflowboss/core/base/Result.java
View file @
739cd248
...
...
@@ -73,6 +73,16 @@ public class Result<T> {
return
new
Result
(
ApplicationStatus
.
FAILURE
,
null
,
message
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
Result
buildFial
()
{
return
new
Result
(
ApplicationStatus
.
FAILURE
,
null
,
null
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
Result
buildFial
(
ApplicationStatus
applicationStatus
)
{
return
new
Result
(
applicationStatus
,
null
,
null
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
Result
buildFial
(
T
data
,
String
message
)
{
return
new
Result
(
ApplicationStatus
.
FAILURE
,
data
,
message
);
...
...
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