Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
think-tank
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
张京坤
think-tank
Commits
0f5782d5
提交
0f5782d5
authored
8月 06, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
测试bug修改
上级
d4a0d3b8
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
310 行增加
和
57 行删除
+310
-57
MybatisInterceptor.java
...in/java/com/zzsn/thinktank/config/MybatisInterceptor.java
+111
-0
InfoSourceGroupMapServiceImpl.java
...thinktank/service/impl/InfoSourceGroupMapServiceImpl.java
+42
-42
BindVO.java
src/main/java/com/zzsn/thinktank/vo/BindVO.java
+1
-1
InfoSourceMapper.xml
src/main/resources/mapper/InfoSourceMapper.xml
+156
-14
没有找到文件。
src/main/java/com/zzsn/thinktank/config/MybatisInterceptor.java
0 → 100644
浏览文件 @
0f5782d5
package
com
.
zzsn
.
thinktank
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.binding.MapperMethod.ParamMap
;
import
org.apache.ibatis.executor.Executor
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.mapping.SqlCommandType
;
import
org.apache.ibatis.plugin.*
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Field
;
import
java.util.*
;
/**
* mybatis拦截器,自动注入创建人、创建时间、修改人、修改时间
*
* @Author scott
* @Date 2019-01-19
*/
@Slf4j
@Component
@Intercepts
({
@Signature
(
type
=
Executor
.
class
,
method
=
"update"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
})})
public
class
MybatisInterceptor
implements
Interceptor
{
@Override
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
MappedStatement
mappedStatement
=
(
MappedStatement
)
invocation
.
getArgs
()[
0
];
String
sqlId
=
mappedStatement
.
getId
();
log
.
debug
(
"------sqlId------"
+
sqlId
);
SqlCommandType
sqlCommandType
=
mappedStatement
.
getSqlCommandType
();
Object
parameter
=
invocation
.
getArgs
()[
1
];
log
.
debug
(
"------sqlCommandType------"
+
sqlCommandType
);
if
(
parameter
==
null
)
{
return
invocation
.
proceed
();
}
Date
date
=
new
Date
();
if
(
SqlCommandType
.
INSERT
==
sqlCommandType
)
{
Field
[]
fields
=
getAllFields
(
parameter
);
for
(
Field
field
:
fields
)
{
String
fieldName
=
field
.
getName
();
// 注入创建时间
if
(
"createTime"
.
equals
(
fieldName
))
{
field
.
setAccessible
(
true
);
Object
localCreateDate
=
field
.
get
(
parameter
);
field
.
setAccessible
(
false
);
if
(
localCreateDate
==
null
||
localCreateDate
.
equals
(
""
))
{
changeData
(
field
,
parameter
,
date
);
}
}
}
}
if
(
SqlCommandType
.
UPDATE
==
sqlCommandType
)
{
Field
[]
fields
;
if
(
parameter
instanceof
ParamMap
)
{
ParamMap
<?>
p
=
(
ParamMap
<?>)
parameter
;
if
(
p
.
containsKey
(
"et"
))
{
parameter
=
p
.
get
(
"et"
);
}
else
{
parameter
=
p
.
get
(
"param1"
);
}
if
(
parameter
==
null
)
{
return
invocation
.
proceed
();
}
fields
=
getAllFields
(
parameter
);
}
else
{
fields
=
getAllFields
(
parameter
);
}
for
(
Field
field
:
fields
)
{
String
fieldName
=
field
.
getName
();
log
.
debug
(
"------field.name------"
+
fieldName
);
if
(
"updateTime"
.
equals
(
fieldName
))
{
changeData
(
field
,
parameter
,
date
);
}
}
}
return
invocation
.
proceed
();
}
@Override
public
Object
plugin
(
Object
target
)
{
return
Plugin
.
wrap
(
target
,
this
);
}
@Override
public
void
setProperties
(
Properties
properties
)
{
}
//修改对应字段的值
private
void
changeData
(
Field
field
,
Object
parameter
,
Object
data
){
try
{
field
.
setAccessible
(
true
);
field
.
set
(
parameter
,
data
);
field
.
setAccessible
(
false
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
}
private
Field
[]
getAllFields
(
Object
object
)
{
Class
<?>
clazz
=
object
.
getClass
();
List
<
Field
>
fieldList
=
new
ArrayList
<>();
while
(
clazz
!=
null
)
{
fieldList
.
addAll
(
new
ArrayList
<>(
Arrays
.
asList
(
clazz
.
getDeclaredFields
())));
clazz
=
clazz
.
getSuperclass
();
}
Field
[]
fields
=
new
Field
[
fieldList
.
size
()];
fieldList
.
toArray
(
fields
);
return
fields
;
}
}
src/main/java/com/zzsn/thinktank/service/impl/InfoSourceGroupMapServiceImpl.java
浏览文件 @
0f5782d5
...
...
@@ -143,12 +143,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//解绑通用信息源组
//解绑通用信息源
栏目
组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
INFO_SOURCE_GROUP
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向信息源
组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE_GROUP
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽信息源栏目
组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE_GROUP
.
getvalue
());
}
}
private
void
unBindInfoSourceColumn
(
BindVO
bindVO
)
{
...
...
@@ -158,12 +158,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//解绑通用信息源
组
//解绑通用信息源
栏目
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
INFO_SOURCE
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向信息源组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽信息源栏目
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE
.
getvalue
());
}
}
...
...
@@ -177,9 +177,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//解绑通用信息源组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
INFO_MAIN_SOURCE_GROUP
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向
信息源组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_MAIN_INFO_SOURCE_GROUP
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽
信息源组
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_MAIN_INFO_SOURCE_GROUP
.
getvalue
());
}
}
private
void
unBindInfoSource
(
BindVO
bindVO
)
{
...
...
@@ -192,9 +192,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//解绑通用信息源
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
INFO_MAIN_SOURCE
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向
信息源
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_MAIN_INFO_SOURCE
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽
信息源
unBindInfoSource
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_MAIN_INFO_SOURCE
.
getvalue
());
}
}
...
...
@@ -205,12 +205,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//解绑通用标签
//解绑通用
信息源栏目
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
INFO_SOURCE_LABEL
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE_LABEL
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽信息源栏目
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE_LABEL
.
getvalue
());
}
}
private
void
unBindInfoSourceLabels
(
BindVO
bindVO
)
{
...
...
@@ -220,12 +220,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//解绑通用标签
//解绑通用
信息源
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
INFO_SOURCE_MAIN_LABEL
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//解绑
定向
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
DIRECTIONA
_INFO_MAIN_SOURCE_LABEL
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//解绑
屏蔽信息源
标签
unBindLabel
(
bindVO
,
BindTypeEnum
.
EXCLUDE
_INFO_MAIN_SOURCE_LABEL
.
getvalue
());
}
}
...
...
@@ -239,9 +239,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
INFO_SOURCE_GROUP
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE_GROUP
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE_GROUP
.
getvalue
());
}
}
...
...
@@ -255,9 +255,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
INFO_SOURCE
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE
.
getvalue
());
}
}
...
...
@@ -269,12 +269,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//绑定通用
标签信息源
//绑定通用
信息源栏目标签
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
INFO_SOURCE_LABEL
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向标签信息源
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
DIRECTIONA
_INFO_SOURCE_LABEL
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽信息源栏目标签
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
EXCLUDE
_INFO_SOURCE_LABEL
.
getvalue
());
}
}
...
...
@@ -286,12 +286,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return
;
}
if
(
sourceBindType
==
1
)
{
//绑定通用
标签信息源
//绑定通用
信息源标签
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
INFO_SOURCE_MAIN_LABEL
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向标签信息源
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
DIRECTIONA
_INFO_MAIN_SOURCE_LABEL
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽信息源标签
bindLabels
(
thinkTankId
,
bindLabels
,
BindTypeEnum
.
EXCLUDE
_INFO_MAIN_SOURCE_LABEL
.
getvalue
());
}
}
...
...
@@ -305,9 +305,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
INFO_MAIN_SOURCE_GROUP
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
DIRECTIONA
_MAIN_INFO_SOURCE_GROUP
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
EXCLUDE
_MAIN_INFO_SOURCE_GROUP
.
getvalue
());
}
}
...
...
@@ -321,9 +321,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
INFO_MAIN_SOURCE
.
getvalue
());
}
if
(
sourceBindType
==
2
)
{
//绑定
定向
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
DIRECTIONA
_MAIN_INFO_SOURCE
.
getvalue
());
if
(
sourceBindType
==
3
)
{
//绑定
屏蔽
信息源组
bindInfoSource
(
bindVO
,
idList
,
BindTypeEnum
.
EXCLUDE
_MAIN_INFO_SOURCE
.
getvalue
());
}
}
...
...
src/main/java/com/zzsn/thinktank/vo/BindVO.java
浏览文件 @
0f5782d5
...
...
@@ -19,7 +19,7 @@ public class BindVO {
private
List
<
String
>
bindIds
;
//信息源标签
private
List
<
BindLabelVo
>
bindLabels
;
//绑定类型类型(1:通用 2:定向)
//绑定类型类型(1:通用 2:定向
3:屏蔽
)
private
Integer
sourceBindType
;
//信息源类型(1:信息源栏目组 2:信息源栏目 3:信息源栏目标签 4:信息源组 5:信息源 6:信息源标签)
private
Integer
sourceType
;
...
...
src/main/resources/mapper/InfoSourceMapper.xml
浏览文件 @
0f5782d5
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论