Helius
2020-05-18 648c10dbb4224f7f7a9f5ab01b6957ddd3816658
modify mybatis interceptor
2 files modified
17 ■■■■■ changed files
src/main/java/com/xcong/excoin/common/contants/AppContants.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/common/contants/AppContants.java
@@ -7,6 +7,12 @@
public class AppContants {
    /**
     * 系统用户
     */
    public static final String SYSTEM_USER = "system";
    /**
     * app用户登陆redis前缀
     */
    public static final String APP_LOGIN_PREFIX = "app_";
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.*;
/**
@@ -78,8 +78,13 @@
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        if (o instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) o;
            if (member != null) {
            baseEntity.setCreateBy(member.getUsername());
            baseEntity.setUpdateBy(member.getUsername());
            } else {
                baseEntity.setCreateBy(AppContants.SYSTEM_USER);
                baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
            }
            baseEntity.setCreateTime(new Date());
            baseEntity.setUpdateTime(new Date());
        }
@@ -89,7 +94,11 @@
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        if (o instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) o;
            if (member != null) {
            baseEntity.setUpdateBy(member.getUsername());
            } else {
                baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
            }
            baseEntity.setUpdateTime(new Date());
        }
    }