Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
bd6364f5
提交
bd6364f5
编写于
7月 09, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
审计调整
上级
d40d7a52
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
87 行增加
和
97 行删除
+87
-97
%DE%.java.ftl
...ava/%SYS_PKGPATH%/core/%MOD_PKGPATH%/domain/%DE%.java.ftl
+26
-30
Audit.java.ftl
...rc/main/java/%SYS_PKGPATH%/util/annotation/Audit.java.ftl
+1
-4
DEField.java.ftl
.../main/java/%SYS_PKGPATH%/util/annotation/DEField.java.ftl
+18
-0
SimpleAuditService.java.ftl
...va/%SYS_PKGPATH%/util/service/SimpleAuditService.java.ftl
+42
-63
未找到文件。
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/domain/%DE%.java.ftl
浏览文件 @
bd6364f5
...
...
@@ -24,6 +24,7 @@ import ${pub.getPKGCodeName()}.util.enums.DEFieldDefaultValueType;
import
java
.
io
.
Serializable
;
import
lombok
.*;
import
org
.
springframework
.
data
.
annotation
.
Transient
;
import
${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
;
<#
comment
>
SQL
存储
-
Mybatis
</#
comment
>
<#
if
de
.
getStorageMode
()==
1
>
...
...
@@ -86,13 +87,33 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#
if
>
</#
if
>
</#
if
>
<#
comment
>
审计
</#
comment
>
<#
if
defield
.
isEnableAudit
()==
true
&&
de
.
getAuditMode
()
!=0>
<#
if
defieldano
??
&&
defieldano
!=''>
<#
assign
defieldano
=
defieldano
+
" , "
>
<#
assign
defStdType
=
srfjavatype
(
defield
.
stdDataType
)>
<#
if
defield
.
getPSCodeList
??
&&
defield
.
getPSCodeList
()??>
<#
if
((
defield
.
getPredefinedType
())
!'')!='LOGICVALID'>
<#
assign
defieldano
=
defieldano
+
",dict=
\"
"
+
sys
.
codeName
+
"_"
+
defield
.
getPSCodeList
().
codeName
+
"CodeList"
+
"
\"
"
>
//
拼接代码表
</#
if
>
</#
if
>
<#
if
defDataType
==
"DATETIME"
>//
拼接时间
<#
assign
defieldano
=
defieldano
+
",fieldType=
\"
DATETIME
\"
,format=
\"
yyyy-MM-dd HH:mm:ss
\"
"
>//
日期时间型
<#
elseif
defDataType
==
"DATE"
>
<#
assign
defieldano
=
defieldano
+
",fieldType=
\"
DATE
\"
,format=
\"
yyyy-MM-dd
\"
"
>//
日期型
<#
elseif
defDataType
==
"TIME"
>
<#
assign
defieldano
=
defieldano
+
",fieldType=
\"
TIME
\"
,format=
\"
HH:mm
\"
"
>//
时间型
<#
elseif
defDataType
==
'PICKUPDATA'
&&
defStdType
==
'Timestamp'
><#
comment
>
外键值附加数据,数据类型为时间
</#
comment
>
<#
assign
defieldano
=
defieldano
+
",fieldType=
\"
DATETIME
\"
,format=
\"
yyyy-MM-dd HH:mm:ss
\"
"
>//
日期时间型
</#
if
>
</#
if
>
</#
if
>
/**
*
${
defield
.
getLogicName
()}
*/
<#
comment
>
审计注解
</#
comment
>
<#
if
defield
.
isEnableAudit
()==
true
&&
de
.
getAuditMode
()
!=0>
<#
assign
auditExpression
=
getAuditExpression
(
defield
)>
@${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
(${
auditExpression
})
@
Audit
</#
if
>
<#
comment
>
属性默认值
</#
comment
>
<#
if
defieldano
??
&&
defieldano
!='' && defield.isPhisicalDEField()==true>
...
...
@@ -344,8 +365,7 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
</#
if
>
<#
comment
>
审计注解
</#
comment
>
<#
if
defield
.
isEnableAudit
()==
true
&&
de
.
getAuditMode
()
!=0>
<#
assign
auditExpression
=
getAuditExpression
(
defield
)>
@${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
(${
auditExpression
})
@
Audit
</#
if
>
<#
comment
>
属性默认值
</#
comment
>
<#
if
defieldano
??
&&
defieldano
!='' && defield.isPhisicalDEField()==true>
...
...
@@ -513,8 +533,7 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
*/
<#
comment
>
审计注解
</#
comment
>
<#
if
defield
.
isEnableAudit
()==
true
&&
de
.
getAuditMode
()
!=0>
<#
assign
auditExpression
=
getAuditExpression
(
defield
)>
@${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
(${
auditExpression
})
@
Audit
</#
if
>
<#
comment
>
属性默认值
</#
comment
>
<#
if
defieldano
??
&&
defieldano
!='' && defield.isPhisicalDEField()==true>
...
...
@@ -694,8 +713,7 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
*/
<#
comment
>
审计注解
</#
comment
>
<#
if
defield
.
isEnableAudit
()==
true
&&
de
.
getAuditMode
()
!=0>
<#
assign
auditExpression
=
getAuditExpression
(
defield
)>
@${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
(${
auditExpression
})
@
Audit
</#
if
>
<#
comment
>
属性默认值
</#
comment
>
<#
if
defieldano
??
&&
defieldano
!='' && defield.isPhisicalDEField()==true>
...
...
@@ -843,28 +861,6 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
<#
return
unionKeyResult
>
</#
function
>
<#
comment
>
审计注解
</#
comment
>
<#
function
getAuditExpression
defield
>
<#
assign
defDataType
=
(
defield
.
getDataType
())
!"">
<#
assign
defStdType
=
srfjavatype
(
defield
.
stdDataType
)>
<#
assign
expressionCond
=
"fieldLogicName=
\"
"
+
defield
.
getLogicName
()+
"
\"
"
>
//
拼接字段逻辑名
<#
if
defield
.
getPSCodeList
??
&&
defield
.
getPSCodeList
()??>
<#
if
((
defield
.
getPredefinedType
())
!'')!='LOGICVALID'>
<#
assign
expressionCond
=
expressionCond
+
",dictName=
\"
"
+
sys
.
codeName
+
"_"
+
defield
.
getPSCodeList
().
codeName
+
"CodeList"
+
"
\"
"
>
//
拼接代码表
</#
if
>
</#
if
>
<#
if
defDataType
==
"DATETIME"
>//
拼接时间
<#
assign
expressionCond
=
expressionCond
+
",fieldType=
\"
DATETIME
\"
,format=
\"
yyyy-MM-dd HH:mm:ss
\"
"
>//
日期时间型
<#
elseif
defDataType
==
"DATE"
>
<#
assign
expressionCond
=
expressionCond
+
",fieldType=
\"
DATE
\"
,format=
\"
yyyy-MM-dd
\"
"
>//
日期型
<#
elseif
defDataType
==
"TIME"
>
<#
assign
expressionCond
=
expressionCond
+
",fieldType=
\"
TIME
\"
,format=
\"
HH:mm
\"
"
>//
时间型
<#
elseif
defDataType
==
'PICKUPDATA'
&&
defStdType
==
'Timestamp'
><#
comment
>
外键值附加数据,数据类型为时间
</#
comment
>
<#
assign
expressionCond
=
expressionCond
+
",fieldType=
\"
DATETIME
\"
,format=
\"
yyyy-MM-dd HH:mm:ss
\"
"
>//
日期时间型
</#
if
>
<#
return
expressionCond
/>
</#
function
>
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/annotation/Audit.java.ftl
浏览文件 @
bd6364f5
...
...
@@ -12,10 +12,7 @@ import java.lang.annotation.Target;
@
Target
({
ElementType
.
FIELD
})
public
@
interface
Audit
{
String
fieldLogicName
()
default
""
;//
字段逻辑名称
String
dictName
()
default
""
;//
代码表名称
String
fieldType
()
default
""
;//
字段类型
String
format
()
default
""
;//
格式化
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/annotation/DEField.java.ftl
浏览文件 @
bd6364f5
...
...
@@ -30,6 +30,12 @@ public @interface DEField
*/
String
defaultValue
()
default
""
;
/**
*
属性类型
*
@
return
*/
String
fieldType
()
default
""
;
/**
*
默认值类型
*
@
return
...
...
@@ -53,5 +59,17 @@ public @interface DEField
*
@
return
*/
String
logicdelval
()
default
""
;
/**
*
代码表
*
@
return
*/
String
dict
()
default
""
;
/**
*
日期格式化
*
@
return
*/
String
format
()
default
""
;
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/service/SimpleAuditService.java.ftl
浏览文件 @
bd6364f5
...
...
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
lombok
.
SneakyThrows
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
Audit
;
import
${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
DEField
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
EntityBase
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
IBZDataAudit
;
import
${
pub
.
getPKGCodeName
()}.
util
.
helper
.
DEFieldCacheMap
;
import
${
pub
.
getPKGCodeName
()}.
util
.
mapper
.
IBZDataAuditMapper
;
import
${
pub
.
getPKGCodeName
()}.
util
.
security
.
AuthenticationUser
;
import
org
.
springframework
.
expression
.
EvaluationContext
;
...
...
@@ -74,7 +76,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit
.
setOptime
(
new
Timestamp
(
new
Date
().
getTime
()));
if
(
request
!=null)
dataAudit
.
setIpaddress
(
getIpAddress
(
request
,
AuthenticationUser
.
getAuthenticationUser
()));
dataAudit
.
setAuditinfo
(
get
Create
AuditInfo
(
entity
,
auditFields
));
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
dataAudit
.
setIsdatachanged
(
1
);
cacheMap
.
add
(
dataAudit
);
}
...
...
@@ -128,35 +130,37 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit
.
setOptime
(
new
Timestamp
(
new
Date
().
getTime
()));
if
(
request
!=null)
dataAudit
.
setIpaddress
(
getIpAddress
(
request
,
AuthenticationUser
.
getAuthenticationUser
()));
dataAudit
.
setAuditinfo
(
get
Remove
AuditInfo
(
entity
,
auditFields
));
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
dataAudit
.
setIsdatachanged
(
1
);
cacheMap
.
add
(
dataAudit
);
}
/**
*
获取新建审计内容
*
@
param
entity
*
@
param
auditFields
*
@
return
*/
private
String
getCreateAuditInfo
(
EntityBase
entity
,
Map
<
String
,
Audit
>
auditFields
){
JSONArray
auditFieldArray
=
new
JSONArray
();
private
String
getAuditInfo
(
EntityBase
entity
,
Map
<
String
,
Audit
>
auditFields
){
String
auditResult
=
""
;
if
(
auditFields
.
size
()==
0
)
return
""
;
return
auditResult
;
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
entity
.
getClass
());
if
(
deFields
.
size
()==
0
)
return
auditResult
;
JSONArray
auditFieldArray
=
new
JSONArray
();
for
(
Map
.
Entry
<
String
,
Audit
>
auditField
:
auditFields
.
entrySet
())
{
Object
objFieldName
=
auditField
.
getKey
();//
获取注解字段
Audit
auditAnnotation
=
auditField
.
getValue
();//
拿到注解
String
fieldLogicName
=
auditAnnotation
.
fieldLogicName
();
String
fieldName
=
String
.
valueOf
(
objFieldName
);
//
属性名称
Object
value
=
entity
.
get
(
fieldName
);//
老属性值
value
=
dataTransfer
(
value
,
auditAnnotation
.
fieldType
(),
auditAnnotation
.
format
());//
属性值转换
Object
objFieldName
=
auditField
.
getKey
();
String
fieldName
=
String
.
valueOf
(
objFieldName
);
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
)){
deField
=
deFields
.
get
(
fieldName
);
}
if
(
ObjectUtils
.
isEmpty
(
deField
))
continue
;
Object
value
=
dataTransfer
(
entity
.
get
(
fieldName
),
deField
.
fieldType
(),
deField
.
format
());
if
(
!StringUtils.isEmpty(value)){
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
field
Logic
Name
);
auditFieldObj
.
put
(
"field"
,
fieldName
);
auditFieldObj
.
put
(
"value"
,
value
);
if
(
!StringUtils.isEmpty(
auditAnnotation.dictName
())){
auditFieldObj
.
put
(
"dict"
,
auditAnnotation
.
dictName
());
if
(
!StringUtils.isEmpty(
deField.dict
())){
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
auditFieldArray
.
add
(
auditFieldObj
);
}
...
...
@@ -179,56 +183,31 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
JSONArray
auditFieldArray
=
new
JSONArray
();
if
(
auditFields
.
size
()==
0
)
return
auditResult
;
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
oldData
.
getClass
());
if
(
deFields
.
size
()==
0
)
return
auditResult
;
for
(
Map
.
Entry
<
String
,
Audit
>
auditField
:
auditFields
.
entrySet
())
{
Object
objFieldName
=
auditField
.
getKey
();//
获取注解字段
String
fieldName
=
String
.
valueOf
(
objFieldName
);
//
属性名称
Audit
auditAnnotation
=
auditField
.
getValue
();//
拿到注解
String
fieldLogicName
=
auditAnnotation
.
fieldLogicName
();//
获取字段逻辑名称
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
)){
deField
=
deFields
.
get
(
fieldName
);
}
if
(
ObjectUtils
.
isEmpty
(
deField
))
continue
;
Object
oldValue
=
oldData
.
get
(
fieldName
);//
老属性值
Object
newValue
=
newData
.
get
(
fieldName
);//
新属性值
if
(
!compare(oldValue,newValue)){
oldValue
=
dataTransfer
(
oldValue
,
auditAnnotation
.
fieldType
(),
auditAnnotation
.
format
());//
属性值转换
newValue
=
dataTransfer
(
newValue
,
auditAnnotation
.
fieldType
(),
auditAnnotation
.
format
());//
属性值转换
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
fieldLogicName
);
auditFieldObj
.
put
(
"before"
,
oldValue
);
auditFieldObj
.
put
(
"after"
,
newValue
);
if
(
!StringUtils.isEmpty(auditAnnotation.dictName())){
auditFieldObj
.
put
(
"dict"
,
auditAnnotation
.
dictName
());
}
auditFieldArray
.
add
(
auditFieldObj
);
}
}
if
(
auditFieldArray
.
size
()>
0
){
auditResult
=
auditFieldArray
.
toString
();
}
return
auditResult
;
}
/**
*
获取删除审计内容
*
@
param
entity
*
@
param
auditFields
*
@
return
*/
private
String
getRemoveAuditInfo
(
EntityBase
entity
,
Map
<
String
,
Audit
>
auditFields
){
String
auditResult
=
""
;
JSONArray
auditFieldArray
=
new
JSONArray
();
if
(
auditFields
.
size
()==
0
)
return
auditResult
;
for
(
Map
.
Entry
<
String
,
Audit
>
auditField
:
auditFields
.
entrySet
())
{
Object
objFieldName
=
auditField
.
getKey
();//
获取注解字段
Audit
auditAnnotation
=
auditField
.
getValue
();//
拿到注解
String
fieldLogicName
=
auditAnnotation
.
fieldLogicName
();
String
fieldName
=
String
.
valueOf
(
objFieldName
);
//
属性名称
Object
value
=
entity
.
get
(
fieldName
);//
老属性值
value
=
dataTransfer
(
value
,
auditAnnotation
.
fieldType
(),
auditAnnotation
.
format
());//
属性值转换
if
(
!StringUtils.isEmpty(value)){
oldValue
=
dataTransfer
(
oldValue
,
deField
.
fieldType
(),
deField
.
format
());//
属性值转换
newValue
=
dataTransfer
(
newValue
,
deField
.
fieldType
(),
deField
.
format
());//
属性值转换
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
fieldLogicName
);
auditFieldObj
.
put
(
"value"
,
value
);
if
(
!StringUtils.isEmpty(auditAnnotation.dictName())){
auditFieldObj
.
put
(
"dict"
,
auditAnnotation
.
dictName
());
auditFieldObj
.
put
(
"field"
,
fieldName
);
auditFieldObj
.
put
(
"beforevalue"
,
oldValue
);
auditFieldObj
.
put
(
"value"
,
newValue
);
if
(
!StringUtils.isEmpty(deField.dict())){
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
auditFieldArray
.
add
(
auditFieldObj
);
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录