Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
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
base_platform_enterprise
gic-store
Commits
1ee230c0
Commit
1ee230c0
authored
Apr 13, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店保存修改
parent
a7cc018a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
157 deletions
+0
-157
LogUtils.java
...e-service/src/main/java/com/gic/store/utils/LogUtils.java
+0
-88
LogAspect.java
...vice/src/main/java/com/gic/store/utils/log/LogAspect.java
+0
-69
No files found.
gic-store-service/src/main/java/com/gic/store/utils/LogUtils.java
deleted
100644 → 0
View file @
a7cc018a
package
com
.
gic
.
store
.
utils
;
import
com.gic.log.api.dto.SystemSetLogDTO
;
import
com.gic.log.api.service.LogApiService
;
import
com.gic.store.dto.StoreInfoDTO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.beans.PropertyDescriptor
;
import
java.util.Date
;
/**
* @author zhiwj
* @date 2019/7/10
*/
@Component
public
class
LogUtils
{
private
static
LogApiService
logApiService
;
public
static
<
T
>
void
saveAddLog
(
T
obj
)
{
saveLog
(
obj
,
1
);
}
public
static
<
T
>
void
saveUpdateLog
(
T
obj
)
{
saveLog
(
obj
,
2
);
}
@Autowired
public
void
setLogApiService
(
LogApiService
logApiService
)
{
LogUtils
.
logApiService
=
logApiService
;
}
public
static
<
T
>
void
saveLog
(
T
obj
,
Integer
type
)
{
// 日志
SystemSetLogDTO
systemSetLogDTO
=
new
SystemSetLogDTO
();
// systemSetLogDTO.setEnterpriesId(storeBrandDTO.getEnterpriseId() + "");
systemSetLogDTO
.
setLogTime
(
new
Date
());
// systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand");
StringBuilder
content
=
new
StringBuilder
();
getContent
(
obj
,
type
,
content
,
systemSetLogDTO
);
systemSetLogDTO
.
setContent
(
content
.
toString
());
if
(
StringUtils
.
isNotBlank
(
systemSetLogDTO
.
getContent
()))
{
logApiService
.
saveSystemSetLog
(
systemSetLogDTO
);
}
}
private
static
<
T
>
void
getContent
(
T
obj
,
Integer
type
,
StringBuilder
content
,
SystemSetLogDTO
systemSetLogDTO
)
{
if
(
obj
instanceof
Iterable
)
{
for
(
Object
o
:
(
Iterable
)
obj
)
{
getContent
(
o
,
type
,
content
,
systemSetLogDTO
);
}
}
final
BeanWrapper
dtoBean
=
new
BeanWrapperImpl
(
obj
);
PropertyDescriptor
[]
pds
=
dtoBean
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
pd
:
pds
)
{
if
(
"storeId"
.
equals
(
pd
.
getName
())
&&
obj
instanceof
StoreInfoDTO
)
{
Object
storeId
=
dtoBean
.
getPropertyValue
(
pd
.
getName
());
if
(
storeId
!=
null
)
{
systemSetLogDTO
.
setRelationId
(
Long
.
valueOf
(
storeId
.
toString
()));
}
}
else
{
String
name
=
PropertyNameMap
.
get
(
pd
.
getName
());
if
(
StringUtils
.
isNotBlank
(
name
))
{
Object
value
=
dtoBean
.
getPropertyValue
(
pd
.
getName
());
if
(
value
!=
null
)
{
if
(
value
instanceof
Iterable
)
{
for
(
Object
o
:
(
Iterable
)
value
)
{
getContent
(
o
,
type
,
content
,
systemSetLogDTO
);
}
}
else
{
content
.
append
(
name
).
append
(
" : "
).
append
(
value
).
append
(
"<br/>"
);
// if (type == 1) {
// content.append(name).append(" 新增 ").append(value).append("<br/>");
// } else if (type == 2) {
// content.append(name).append(" 修改为 ").append(value).append("<br/>");
// }
}
}
}
}
}
}
}
gic-store-service/src/main/java/com/gic/store/utils/log/LogAspect.java
deleted
100644 → 0
View file @
a7cc018a
package
com
.
gic
.
store
.
utils
.
log
;
import
com.gic.store.utils.LogUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 日志aop
* @ClassName: LogAspect
* @Description:
* @author guojuxing
* @date 2019/7/31 1:52 PM
*/
@Aspect
public
class
LogAspect
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LogAspect
.
class
);
@Pointcut
(
"execution(* com.gic.store.service.outer.*.save*(..))"
)
public
void
saveCell
()
{
}
@Pointcut
(
"execution(public * com.gic.store.service.outer.*.update*(..))"
)
public
void
updateCell
()
{
}
@Pointcut
(
"execution(* com.gic.store.service.outer.*.delete*(..))"
)
public
void
deleteCell
()
{
}
@AfterReturning
(
value
=
"saveCell()"
,
argNames
=
"joinPoint,object"
,
returning
=
"object"
)
public
void
saveLog
(
JoinPoint
joinPoint
,
Object
object
)
{
if
(
joinPoint
.
getArgs
()
==
null
)
{
return
;
}
String
methodName
=
joinPoint
.
getSignature
().
getName
();
String
operContent
=
""
;
logger
.
info
(
"aspectLog:{}"
,
joinPoint
.
getArgs
());
LogUtils
.
saveAddLog
(
arrToList
(
joinPoint
.
getArgs
()));
}
@AfterReturning
(
value
=
"updateCell()"
,
argNames
=
"joinPoint,object"
,
returning
=
"object"
)
public
void
updateLog
(
JoinPoint
joinPoint
,
Object
object
)
{
if
(
joinPoint
.
getArgs
()
==
null
)
{
return
;
}
String
methodName
=
joinPoint
.
getSignature
().
getName
();
String
operContent
=
""
;
logger
.
info
(
"aspectLog:{}"
,
joinPoint
.
getArgs
());
LogUtils
.
saveUpdateLog
(
arrToList
(
joinPoint
.
getArgs
()));
}
private
List
<
Object
>
arrToList
(
Object
[]
args
)
{
List
<
Object
>
resultList
=
new
ArrayList
<>(
args
.
length
);
for
(
Object
obj
:
args
)
{
resultList
.
add
(
obj
);
}
return
resultList
;
}
}
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