Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c479784a
authored
Aug 09, 2021
by
danmo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复回调方法报错问题
1 parent
75083e5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/InsertAndUpdateAspect.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/InsertAndUpdateAspect.java
View file @
c479784
...
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.aspectj;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
...
...
@@ -50,8 +51,9 @@ public class InsertAndUpdateAspect {
private
void
isInsertBaseEntity
(
Object
arg
)
{
if
(
arg
instanceof
BaseEntity
)
{
BaseEntity
next1
=
(
BaseEntity
)
arg
;
next1
.
setCreateBy
(
SecurityUtils
.
getUsername
());
next1
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
String
userName
=
getUserName
();
next1
.
setCreateBy
(
userName
);
next1
.
setUpdateBy
(
userName
);
Date
date
=
new
Date
();
if
(
next1
.
getCreateTime
()
==
null
)
{
next1
.
setCreateTime
(
date
);
...
...
@@ -62,6 +64,16 @@ public class InsertAndUpdateAspect {
}
}
private
String
getUserName
()
{
String
userName
;
try
{
userName
=
SecurityUtils
.
getUsername
();
}
catch
(
CustomException
e
){
userName
=
"admin"
;
}
return
userName
;
}
@Before
(
value
=
"executeUpdate()"
)
public
void
updateHandle
(
JoinPoint
joinPoint
)
{
Object
[]
args
=
joinPoint
.
getArgs
();
...
...
@@ -73,7 +85,7 @@ public class InsertAndUpdateAspect {
for
(
Object
next
:
collection
)
{
if
(
next
instanceof
BaseEntity
)
{
BaseEntity
next1
=
(
BaseEntity
)
next
;
next1
.
setUpdateBy
(
SecurityUtils
.
getUsern
ame
());
next1
.
setUpdateBy
(
getUserN
ame
());
Date
date
=
new
Date
();
if
(
next1
.
getUpdateTime
()
==
null
)
{
next1
.
setUpdateTime
(
date
);
...
...
@@ -82,7 +94,7 @@ public class InsertAndUpdateAspect {
}
}
else
if
(
arg
instanceof
BaseEntity
)
{
BaseEntity
arg1
=
(
BaseEntity
)
arg
;
arg1
.
setUpdateBy
(
SecurityUtils
.
getUsern
ame
());
arg1
.
setUpdateBy
(
getUserN
ame
());
Date
date
=
new
Date
();
if
(
arg1
.
getUpdateTime
()
==
null
)
{
arg1
.
setUpdateTime
(
date
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment