Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
c651553d
Commit
c651553d
authored
Jan 18, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加优惠卷日志提示
parent
513d2852
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
QPServiceImplAspect.java
...ain/java/share/framework/aspectj/QPServiceImplAspect.java
+19
-10
No files found.
share-framework/src/main/java/share/framework/aspectj/QPServiceImplAspect.java
View file @
c651553d
...
...
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.*
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestAttributes
;
...
...
@@ -31,6 +33,7 @@ import java.util.concurrent.CompletableFuture;
@Aspect
@Component
public
class
QPServiceImplAspect
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QPServiceImplAspect
.
class
);
@Autowired
private
CouponLogService
couponLogService
;
...
...
@@ -73,6 +76,7 @@ public class QPServiceImplAspect {
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
// 从获取RequestAttributes中获取HttpServletRequest的信息
HttpServletRequest
request
=
(
HttpServletRequest
)
requestAttributes
.
resolveReference
(
RequestAttributes
.
REFERENCE_REQUEST
);
CouponLog
couponLog
=
new
CouponLog
();
try
{
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
...
...
@@ -80,8 +84,6 @@ public class QPServiceImplAspect {
Method
method
=
signature
.
getMethod
();
//获得方法名
String
methodName
=
method
.
getName
();
// 获取操作
CouponLog
couponLog
=
new
CouponLog
();
// 将入参转换成json // 请求参数
//获得请求参数名称
String
[]
paramNames
=
((
MethodSignature
)
joinPoint
.
getSignature
()).
getParameterNames
();
...
...
@@ -94,18 +96,22 @@ public class QPServiceImplAspect {
couponLog
.
setStatus
(
YesNoEnum
.
yes
.
getDisplay_3
());
couponLog
.
setMessage
(
outParams
);
couponLog
.
setCreateTime
(
new
Date
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"开始异步执行新增正常日志"
);
// 异步执行
CompletableFuture
.
supplyAsync
(()
->
{
int
i
=
couponLogService
.
insertCouponLog
(
couponLog
);
if
(
i
>
0
)
{
boolean
i
=
couponLogService
.
save
(
couponLog
);
if
(
i
)
{
logger
.
info
(
"新增日志成功"
);
return
true
;
}
else
{
logger
.
info
(
"新增日志失败"
);
return
false
;
}
});
// }
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
...
...
@@ -135,13 +141,16 @@ public class QPServiceImplAspect {
couponLog
.
setMessage
(
e
.
getMessage
());
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
finally
{
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"开始异步执行新增错误日志"
);
CompletableFuture
.
supplyAsync
(()
->
{
int
i
=
couponLogService
.
insertCouponLog
(
couponLog
);
if
(
i
>
0
)
{
boolean
i
=
couponLogService
.
save
(
couponLog
);
if
(
i
)
{
logger
.
info
(
"新增日志成功"
);
return
true
;
}
else
{
logger
.
info
(
"新增日志失败"
);
return
false
;
}
});
...
...
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