Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
isc-core
Overview
Overview
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
isc-v3.1-tmp
isc-core
Commits
e90a37fe
Commit
e90a37fe
authored
Nov 04, 2024
by
hulei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
汇款多实体适配
parent
f6bf1d74
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
53 deletions
+98
-53
CustomParameterInterceptor.java
...pport/mybatis/interceptor/CustomParameterInterceptor.java
+10
-52
ParameterProcessor.java
...e/mda/support/mybatis/interceptor/ParameterProcessor.java
+30
-0
MyBatisConfig.java
...c/main/java/com/brilliance/isc/support/MyBatisConfig.java
+49
-1
AccountCustomizedApi.java
...m/brilliance/isc/customized/api/AccountCustomizedApi.java
+9
-0
No files found.
isc-common-
service/src/main/java/com/brilliance/isc/support/Custom
Interceptor.java
→
isc-common-
core/src/main/java/com/brilliance/mda/support/mybatis/interceptor/CustomParameter
Interceptor.java
View file @
e90a37fe
package
com
.
brilliance
.
isc
.
support
;
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
interceptor
;
import
cn.hutool.core.util.StrUtil
;
import
com.brilliance.isc.bo.Etg
;
import
com.brilliance.isc.bo.Ety
;
import
com.brilliance.isc.common.context.SettleContext
;
import
com.brilliance.isc.common.context.SettleSession
;
import
com.github.pagehelper.util.ExecutorUtil
;
import
com.github.pagehelper.util.ExecutorUtil
;
import
com.github.pagehelper.util.MetaObjectUtil
;
import
com.github.pagehelper.util.MetaObjectUtil
;
import
org.apache.ibatis.builder.annotation.ProviderSqlSource
;
import
org.apache.ibatis.builder.annotation.ProviderSqlSource
;
...
@@ -38,12 +33,17 @@ import java.util.Map;
...
@@ -38,12 +33,17 @@ import java.util.Map;
@Signature
(
type
=
Executor
.
class
,
method
=
"query"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
,
RowBounds
.
class
,
ResultHandler
.
class
}),
@Signature
(
type
=
Executor
.
class
,
method
=
"query"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
,
RowBounds
.
class
,
ResultHandler
.
class
}),
@Signature
(
type
=
Executor
.
class
,
method
=
"query"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
,
RowBounds
.
class
,
ResultHandler
.
class
,
CacheKey
.
class
,
BoundSql
.
class
}),
@Signature
(
type
=
Executor
.
class
,
method
=
"query"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
,
RowBounds
.
class
,
ResultHandler
.
class
,
CacheKey
.
class
,
BoundSql
.
class
}),
})
})
public
class
CustomInterceptor
implements
Interceptor
{
public
class
Custom
Parameter
Interceptor
implements
Interceptor
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CustomInterceptor
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Custom
Parameter
Interceptor
.
class
);
private
ParameterProcessor
parameterProcessor
;
public
CustomParameterInterceptor
(
ParameterProcessor
parameterProcessor
){
this
.
parameterProcessor
=
parameterProcessor
;
}
@Override
@Override
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
if
(!
checkSession
()){
if
(!
parameterProcessor
.
checkParameter
()){
return
invocation
.
proceed
();
return
invocation
.
proceed
();
}
}
...
@@ -111,48 +111,6 @@ public class CustomInterceptor implements Interceptor {
...
@@ -111,48 +111,6 @@ public class CustomInterceptor implements Interceptor {
}
}
}
}
}
}
return
processEtyEtgParameter
(
ms
,
paramMap
,
boundSql
,
pageKey
);
return
parameterProcessor
.
processCustomizedParameter
(
ms
,
paramMap
,
boundSql
,
pageKey
);
}
// public void processAnnotation(MappedStatement ms){
// int lastDotIdx = ms.getId().lastIndexOf(".");
// String mapperName = ms.getId().substring(0,lastDotIdx);
// String methodName = ms.getId().substring(lastDotIdx+1);
// }
public
static
final
String
_ETY_PARAMETER_KEY
=
"_etyextkey"
;
public
static
final
String
_ETG_PARAMETER_KEY
=
"_etgextkey"
;
public
Object
processEtyEtgParameter
(
MappedStatement
ms
,
Map
<
String
,
Object
>
paramMap
,
BoundSql
boundSql
,
CacheKey
pageKey
)
{
SettleSession
session
=
SettleContext
.
getUserSession
();
Ety
ety
=
session
.
getEty
();
Etg
etg
=
session
.
getEtg
();
paramMap
.
put
(
_ETY_PARAMETER_KEY
,
ety
.
getExtkey
());
paramMap
.
put
(
_ETG_PARAMETER_KEY
,
etg
.
getExtkey
());
//处理pageKey
pageKey
.
update
(
ety
);
pageKey
.
update
(
etg
);
return
paramMap
;
}
/**
* 检查SettleSession中是否有对应的ETY,ETG信息
* @return
*/
public
boolean
checkSession
(){
SettleSession
session
=
SettleContext
.
getUserSession
();
if
(
session
==
null
){
return
false
;
}
if
(
session
.
getEty
()
==
null
&&
session
.
getEtg
()
==
null
){
return
false
;
}
if
(
StrUtil
.
isEmpty
(
session
.
getEty
().
getExtkey
())
&&
StrUtil
.
isEmpty
(
session
.
getEtg
().
getExtkey
())){
return
false
;
}
return
true
;
}
}
}
}
isc-common-core/src/main/java/com/brilliance/mda/support/mybatis/interceptor/ParameterProcessor.java
0 → 100644
View file @
e90a37fe
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
interceptor
;
import
org.apache.ibatis.cache.CacheKey
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
java.util.Map
;
public
interface
ParameterProcessor
{
/**
* 已拦截到Mybatis的ParamMpa并转化为Map类型,如需要添加额外的参数,可
* @param ms
* @param paramMap
* @param boundSql
* @param pageKey
* @return
*/
Object
processCustomizedParameter
(
MappedStatement
ms
,
Map
<
String
,
Object
>
paramMap
,
BoundSql
boundSql
,
CacheKey
pageKey
)
;
/**
* 提前检查是否需要拦截并对SQL 参数进行处理。
* @return
*/
default
boolean
checkParameter
(){
return
true
;
}
}
isc-common-service/src/main/java/com/brilliance/isc/support/MyBatisConfig.java
View file @
e90a37fe
package
com
.
brilliance
.
isc
.
support
;
package
com
.
brilliance
.
isc
.
support
;
import
cn.hutool.core.util.StrUtil
;
import
com.brilliance.isc.bo.Etg
;
import
com.brilliance.isc.bo.Ety
;
import
com.brilliance.isc.common.context.SettleContext
;
import
com.brilliance.isc.common.context.SettleSession
;
import
com.brilliance.mda.support.mybatis.interceptor.CustomParameterInterceptor
;
import
com.brilliance.mda.support.mybatis.interceptor.ParameterProcessor
;
import
org.apache.ibatis.cache.CacheKey
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.plugin.Interceptor
;
import
org.apache.ibatis.plugin.Interceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.Map
;
@Configuration
@Configuration
public
class
MyBatisConfig
{
public
class
MyBatisConfig
{
@Bean
@Bean
public
Interceptor
customInterceptor
()
{
public
Interceptor
customInterceptor
()
{
return
new
CustomInterceptor
();
return
new
CustomParameterInterceptor
(
new
ParameterProcessor
()
{
public
static
final
String
_ETY_PARAMETER_KEY
=
"_etyextkey"
;
public
static
final
String
_ETG_PARAMETER_KEY
=
"_etgextkey"
;
@Override
public
Object
processCustomizedParameter
(
MappedStatement
ms
,
Map
<
String
,
Object
>
paramMap
,
BoundSql
boundSql
,
CacheKey
pageKey
)
{
SettleSession
session
=
SettleContext
.
getUserSession
();
Ety
ety
=
session
.
getEty
();
Etg
etg
=
session
.
getEtg
();
paramMap
.
put
(
_ETY_PARAMETER_KEY
,
ety
.
getExtkey
());
paramMap
.
put
(
_ETG_PARAMETER_KEY
,
etg
.
getExtkey
());
//处理pageKey
pageKey
.
update
(
ety
);
pageKey
.
update
(
etg
);
return
paramMap
;
}
/**
* 检查SettleSession中是否有对应的ETY,ETG信息
* @return
*/
@Override
public
boolean
checkParameter
()
{
SettleSession
session
=
SettleContext
.
getUserSession
();
if
(
session
==
null
){
return
false
;
}
if
(
session
.
getEty
()
==
null
&&
session
.
getEtg
()
==
null
){
return
false
;
}
if
(
StrUtil
.
isEmpty
(
session
.
getEty
().
getExtkey
())
&&
StrUtil
.
isEmpty
(
session
.
getEtg
().
getExtkey
())){
return
false
;
}
return
true
;
}
});
}
}
}
}
isc-customized/src/main/java/com/brilliance/isc/customized/api/AccountCustomizedApi.java
View file @
e90a37fe
...
@@ -10,5 +10,14 @@ public interface AccountCustomizedApi {
...
@@ -10,5 +10,14 @@ public interface AccountCustomizedApi {
*/
*/
boolean
checkAccount
(
String
account
,
Argument
<
String
>
errMsg
);
boolean
checkAccount
(
String
account
,
Argument
<
String
>
errMsg
);
/**
* 校验账号比重
* @param cur
* @param errMsg
* @return
*/
boolean
checkCur
(
String
cur
,
Argument
<
String
>
errMsg
);
boolean
checkCur
(
String
cur
,
Argument
<
String
>
errMsg
);
}
}
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