From 6ac527e204fbcf9bc62f280eb925cddab291fe5b Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 25 May 2020 11:01:07 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin
---
src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
index 144a8c0..f7b0c87 100644
--- a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
+++ b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
@@ -1,6 +1,7 @@
package com.xcong.excoin.configurations.interceptor;
import com.xcong.excoin.common.LoginUserUtils;
+import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.system.base.BaseEntity;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import lombok.extern.slf4j.Slf4j;
@@ -11,7 +12,6 @@
import org.apache.ibatis.session.defaults.DefaultSqlSession;
import org.springframework.stereotype.Component;
-import java.lang.reflect.Field;
import java.util.*;
/**
@@ -22,7 +22,7 @@
**/
@Slf4j
@Component
-@Intercepts({ @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
+@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
public class MybatisInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
@@ -78,8 +78,14 @@
MemberEntity member = LoginUserUtils.getAppLoginUser();
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
- baseEntity.setCreateBy(member.getUsername());
- baseEntity.setUpdateBy(member.getUsername());
+ if (member != null) {
+ String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
+ baseEntity.setCreateBy(by);
+ baseEntity.setUpdateBy(by);
+ } else {
+ baseEntity.setCreateBy(AppContants.SYSTEM_USER);
+ baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
+ }
baseEntity.setCreateTime(new Date());
baseEntity.setUpdateTime(new Date());
}
@@ -89,7 +95,12 @@
MemberEntity member = LoginUserUtils.getAppLoginUser();
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
- baseEntity.setUpdateBy(member.getUsername());
+ if (member != null) {
+ String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
+ baseEntity.setUpdateBy(by);
+ } else {
+ baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
+ }
baseEntity.setUpdateTime(new Date());
}
}
--
Gitblit v1.9.1