Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
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
黄营
datax-cloud
Commits
58db346b
Commit
58db346b
authored
Jan 21, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
464ae021
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
59 deletions
+7
-59
DataMetaObjectHandler.java
...cn/datax/common/mybatis/config/DataMetaObjectHandler.java
+7
-59
No files found.
datax-common/datax-common-mybatis/src/main/java/cn/datax/common/mybatis/config/DataMetaObjectHandler.java
View file @
58db346b
package
cn
.
datax
.
common
.
mybatis
.
config
;
package
cn
.
datax
.
common
.
mybatis
.
config
;
import
cn.datax.common.utils.SecurityUtil
;
import
cn.datax.common.utils.SecurityUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.apache.ibatis.reflection.MetaObject
;
...
@@ -11,70 +10,19 @@ public class DataMetaObjectHandler implements MetaObjectHandler {
...
@@ -11,70 +10,19 @@ public class DataMetaObjectHandler implements MetaObjectHandler {
@Override
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
public
void
insertFill
(
MetaObject
metaObject
)
{
boolean
bolCreateTime
=
metaObject
.
hasSetter
(
"createTime"
);
this
.
strictInsertFill
(
metaObject
,
"createTime"
,
LocalDateTime
.
class
,
LocalDateTime
.
now
());
Object
createdTime
=
getFieldValByName
(
"createdTime"
,
metaObject
);
this
.
strictInsertFill
(
metaObject
,
"updateTime"
,
LocalDateTime
.
class
,
LocalDateTime
.
now
());
if
(
bolCreateTime
){
this
.
strictInsertFill
(
metaObject
,
"status"
,
Integer
.
class
,
1
);
if
(
null
==
createdTime
)
{
this
.
setInsertFieldValByName
(
"createTime"
,
LocalDateTime
.
now
(),
metaObject
);
}
}
boolean
bolUpdateTime
=
metaObject
.
hasSetter
(
"updateTime"
);
Object
updateTime
=
getFieldValByName
(
"updateTime"
,
metaObject
);
if
(
bolUpdateTime
){
if
(
null
==
updateTime
)
{
this
.
setInsertFieldValByName
(
"updateTime"
,
LocalDateTime
.
now
(),
metaObject
);
}
}
boolean
bolStatus
=
metaObject
.
hasSetter
(
"status"
);
Object
status
=
getFieldValByName
(
"status"
,
metaObject
);
if
(
bolStatus
){
if
(
null
==
status
)
{
this
.
setInsertFieldValByName
(
"status"
,
1
,
metaObject
);
}
}
String
userId
=
getUserId
();
String
userId
=
getUserId
();
if
(
StrUtil
.
isNotBlank
(
userId
)){
this
.
strictInsertFill
(
metaObject
,
"createBy"
,
String
.
class
,
userId
);
boolean
bolCreateBy
=
metaObject
.
hasSetter
(
"createBy"
);
this
.
strictInsertFill
(
metaObject
,
"updateBy"
,
String
.
class
,
userId
);
Object
createBy
=
getFieldValByName
(
"createBy"
,
metaObject
);
if
(
bolCreateBy
)
{
if
(
null
==
createBy
)
{
this
.
setInsertFieldValByName
(
"createBy"
,
userId
,
metaObject
);
}
}
boolean
bolUpdateBy
=
metaObject
.
hasSetter
(
"updateBy"
);
Object
updateBy
=
getFieldValByName
(
"updateBy"
,
metaObject
);
if
(
bolUpdateBy
)
{
if
(
null
==
updateBy
)
{
this
.
setInsertFieldValByName
(
"updateBy"
,
userId
,
metaObject
);
}
}
}
}
}
@Override
@Override
public
void
updateFill
(
MetaObject
metaObject
)
{
public
void
updateFill
(
MetaObject
metaObject
)
{
boolean
bolUpdateTime
=
metaObject
.
hasSetter
(
"updateTime"
);
this
.
strictUpdateFill
(
metaObject
,
"updateTime"
,
LocalDateTime
.
class
,
LocalDateTime
.
now
());
Object
updateTime
=
getFieldValByName
(
"updateTime"
,
metaObject
);
if
(
bolUpdateTime
){
if
(
null
==
updateTime
)
{
this
.
setUpdateFieldValByName
(
"updateTime"
,
LocalDateTime
.
now
(),
metaObject
);
}
}
String
userId
=
getUserId
();
String
userId
=
getUserId
();
if
(
StrUtil
.
isNotBlank
(
userId
)){
this
.
strictInsertFill
(
metaObject
,
"updateBy"
,
String
.
class
,
userId
);
boolean
bolUpdateBy
=
metaObject
.
hasSetter
(
"updateBy"
);
Object
updateBy
=
getFieldValByName
(
"updateBy"
,
metaObject
);
if
(
bolUpdateBy
)
{
if
(
null
==
updateBy
)
{
this
.
setUpdateFieldValByName
(
"updateBy"
,
userId
,
metaObject
);
}
}
}
}
}
private
String
getUserId
()
{
private
String
getUserId
()
{
...
...
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