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
49e724e7
Commit
49e724e7
authored
Jul 10, 2019
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志
parent
c38f42ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
41 deletions
+96
-41
StoreBrandApiServiceImpl.java
...com/gic/store/service/outer/StoreBrandApiServiceImpl.java
+43
-40
LogUtils.java
...e-service/src/main/java/com/gic/store/utils/LogUtils.java
+52
-0
TabStoreExtendMapper.xml
...ervice/src/main/resources/mapper/TabStoreExtendMapper.xml
+1
-1
No files found.
gic-store-service/src/main/java/com/gic/store/service/outer/StoreBrandApiServiceImpl.java
View file @
49e724e7
...
...
@@ -5,28 +5,22 @@ import com.gic.api.base.commons.ServiceResponse;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GlobalInfo
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.log.api.dto.SystemSetLogDTO
;
import
com.gic.log.api.service.LogApiService
;
import
com.gic.store.dto.StoreBrandDTO
;
import
com.gic.store.entity.TabStoreBrand
;
import
com.gic.store.service.StoreBrandApiService
;
import
com.gic.store.service.StoreBrandService
;
import
com.gic.store.service.StoreService
;
import
com.gic.store.utils.ErrorCode
;
import
com.gic.store.utils.LogUtils
;
import
com.gic.store.utils.MoveType
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.beans.PropertyDescriptor
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -47,16 +41,15 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
@Autowired
private
StoreService
storeService
;
@Autowired
private
LogApiService
logApiService
;
@Override
public
ServiceResponse
<
Integer
>
saveOrUpdateStoreBrand
(
StoreBrandDTO
storeBrandDTO
)
{
// 日志
SystemSetLogDTO
systemSetLogDTO
=
new
SystemSetLogDTO
();
systemSetLogDTO
.
setEnterpriesId
(
storeBrandDTO
.
getEnterpriseId
()
+
""
);
systemSetLogDTO
.
setLogTime
(
new
Date
());
systemSetLogDTO
.
setInterfaceName
(
"com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand"
);
//
// 日志
//
SystemSetLogDTO systemSetLogDTO = new SystemSetLogDTO();
//
systemSetLogDTO.setEnterpriesId(storeBrandDTO.getEnterpriseId() + "");
//
systemSetLogDTO.setLogTime(new Date());
//
systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand");
Integer
storeBrandId
;
...
...
@@ -71,7 +64,7 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
if
(
storeBrandDTO
.
getStoreBrandId
()
==
null
)
{
// 新增
storeBrandId
=
storeBrandService
.
save
(
storeBrandDTO
);
systemSetLogDTO
.
setContent
(
"新增品牌, 品牌名:"
+
storeBrandDTO
.
getStoreBrandName
());
//
systemSetLogDTO.setContent("新增品牌, 品牌名:" + storeBrandDTO.getStoreBrandName());
}
else
{
// 编辑
storeBrandId
=
storeBrandDTO
.
getStoreBrandId
();
...
...
@@ -84,8 +77,18 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
}
// 写日志
systemSetLogDTO
.
setContent
(
"门店信息变更"
);
logApiService
.
saveSystemSetLog
(
systemSetLogDTO
);
// final BeanWrapper oldDTOBean = new BeanWrapperImpl(storeBrandDTO);
// PropertyDescriptor[] pds = oldDTOBean.getPropertyDescriptors();
// StringBuilder content = new StringBuilder();
// for (PropertyDescriptor pd : pds) {
// Object oldValue = oldDTOBean.getPropertyValue(pd.getName());
// if (oldValue != null) {
// content.append(pd.getName()).append("变更为").append(oldValue).append("<br/>");
// }
// }
// systemSetLogDTO.setContent(content.toString());
// logApiService.saveSystemSetLog(systemSetLogDTO);
LogUtils
.
saveLog
(
storeBrandDTO
);
return
ServiceResponse
.
success
(
storeBrandId
);
}
...
...
@@ -165,28 +168,28 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
return
ServiceResponse
.
success
();
}
public
static
void
main
(
String
[]
args
)
{
// todo 判断修改字段
HashMap
<
String
,
Object
>
propertyMap
=
new
HashMap
<>();
propertyMap
.
put
(
"storeBrandName"
,
"品牌名"
);
propertyMap
.
put
(
"storeBrandCode"
,
"品牌code"
);
StoreBrandDTO
oldDTO
=
new
StoreBrandDTO
();
oldDTO
.
setStoreBrandName
(
"123"
);
oldDTO
.
setStoreBrandCode
(
"444"
);
StoreBrandDTO
newDTO
=
new
StoreBrandDTO
();
newDTO
.
setStoreBrandName
(
"456"
);
newDTO
.
setStoreBrandName
(
"444"
);
final
BeanWrapper
oldDTOBean
=
new
BeanWrapperImpl
(
oldDTO
);
final
BeanWrapper
newDTOBean
=
new
BeanWrapperImpl
(
newDTO
);
PropertyDescriptor
[]
pds
=
oldDTOBean
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
pd
:
pds
)
{
Object
oldValue
=
oldDTOBean
.
getPropertyValue
(
pd
.
getName
());
Object
newValue
=
newDTOBean
.
getPropertyValue
(
pd
.
getName
());
if
(
oldValue
!=
null
&&
newValue
!=
null
&&
!
oldValue
.
equals
(
newValue
))
{
System
.
out
.
println
(
propertyMap
.
get
(
pd
.
getName
())
+
" 从 "
+
oldValue
+
" 修改为 "
+
newValue
);
}
}
}
//
public static void main(String[] args) {
//
// todo 判断修改字段
//
HashMap<String, Object> propertyMap = new HashMap<>();
//
propertyMap.put("storeBrandName", "品牌名");
//
propertyMap.put("storeBrandCode", "品牌code");
//
//
StoreBrandDTO oldDTO = new StoreBrandDTO();
//
oldDTO.setStoreBrandName("123");
//
oldDTO.setStoreBrandCode("444");
//
StoreBrandDTO newDTO = new StoreBrandDTO();
//
newDTO.setStoreBrandName("456");
//
newDTO.setStoreBrandName("444");
//
final BeanWrapper oldDTOBean = new BeanWrapperImpl(oldDTO);
//
final BeanWrapper newDTOBean = new BeanWrapperImpl(newDTO);
//
PropertyDescriptor[] pds = oldDTOBean.getPropertyDescriptors();
//
for (PropertyDescriptor pd : pds) {
//
Object oldValue = oldDTOBean.getPropertyValue(pd.getName());
//
Object newValue = newDTOBean.getPropertyValue(pd.getName());
//
if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
//
System.out.println(propertyMap.get(pd.getName()) + " 从 " + oldValue + " 修改为 " + newValue);
//
}
//
}
//
}
}
gic-store-service/src/main/java/com/gic/store/utils/LogUtils.java
0 → 100644
View file @
49e724e7
package
com
.
gic
.
store
.
utils
;
import
com.gic.log.api.dto.SystemSetLogDTO
;
import
com.gic.log.api.service.LogApiService
;
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
;
@Autowired
public
void
setLogApiService
(
LogApiService
logApiService
)
{
LogUtils
.
logApiService
=
logApiService
;
}
public
static
<
T
>
void
saveLog
(
T
obj
)
{
// 日志
SystemSetLogDTO
systemSetLogDTO
=
new
SystemSetLogDTO
();
// systemSetLogDTO.setEnterpriesId(storeBrandDTO.getEnterpriseId() + "");
systemSetLogDTO
.
setLogTime
(
new
Date
());
// systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand");
final
BeanWrapper
dtoBean
=
new
BeanWrapperImpl
(
obj
);
PropertyDescriptor
[]
pds
=
dtoBean
.
getPropertyDescriptors
();
StringBuilder
content
=
new
StringBuilder
();
for
(
PropertyDescriptor
pd
:
pds
)
{
Object
value
=
dtoBean
.
getPropertyValue
(
pd
.
getName
());
if
(
value
!=
null
)
{
if
(
"enterpriseId"
.
equalsIgnoreCase
(
pd
.
getName
()))
{
systemSetLogDTO
.
setEnterpriesId
(
value
.
toString
());
}
else
{
content
.
append
(
pd
.
getName
()).
append
(
":"
).
append
(
value
).
append
(
"<br/>"
);
}
}
}
systemSetLogDTO
.
setContent
(
content
.
toString
());
logApiService
.
saveSystemSetLog
(
systemSetLogDTO
);
}
}
gic-store-service/src/main/resources/mapper/TabStoreExtendMapper.xml
View file @
49e724e7
...
...
@@ -156,7 +156,7 @@
from tab_store_extend
where store_field_id = #{storeField}
<if
test=
"storeFieldSelectId != null"
>
and
brand_ids
REGEXP '^${storeFieldSelectId}$|^${storeFieldSelectId},.*$|^.*,${storeFieldSelectId},.*$|^.*,${storeFieldSelectId}$'
and
`value`
REGEXP '^${storeFieldSelectId}$|^${storeFieldSelectId},.*$|^.*,${storeFieldSelectId},.*$|^.*,${storeFieldSelectId}$'
</if>
</select>
<select
id=
"countExtendByValue"
resultType=
"java.lang.Integer"
>
...
...
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