From 42b7d05dfdf60ee67c876084a3240ff48a3bf3a5 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Wed, 02 Mar 2022 12:08:11 +0800
Subject: [PATCH] 日志添加评论控制

---
 snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java b/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java
index 087b49d..0cf9747 100644
--- a/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java
+++ b/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java
@@ -52,9 +52,26 @@
 
     private static final String UPDATE_TIME = "updateTime";
 
+
+    //自定义
+    private static final String CREATE_DATE = "createDate";
+
+    private static final String UPDATE_DATE = "updateDate";
+
     @Override
     public void insertFill(MetaObject metaObject) {
         try {
+
+            Object updateDate = metaObject.getValue(UPDATE_DATE);
+            if(ObjectUtil.isNull(updateDate)) {
+                setFieldValByName(UPDATE_DATE, new Date(), metaObject);
+            }
+
+            Object createDate = metaObject.getValue(CREATE_DATE);
+            if(ObjectUtil.isNull(createDate)) {
+                setFieldValByName(CREATE_DATE, new Date(), metaObject);
+            }
+
             //为空则设置createUser(BaseEntity)
             Object createUser = metaObject.getValue(CREATE_USER);
             if(ObjectUtil.isNull(createUser)) {
@@ -66,6 +83,7 @@
             if(ObjectUtil.isNull(createTime)) {
                 setFieldValByName(CREATE_TIME, new Date(), metaObject);
             }
+
         } catch (ReflectionException e) {
             log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
         }
@@ -74,10 +92,13 @@
     @Override
     public void updateFill(MetaObject metaObject) {
         try {
+            setFieldValByName(UPDATE_DATE, new Date(), metaObject);
+
             //设置updateUser(BaseEntity)
             setFieldValByName(UPDATE_USER, this.getUserUniqueId(), metaObject);
             //设置updateTime(BaseEntity)
             setFieldValByName(UPDATE_TIME, new Date(), metaObject);
+
         } catch (ReflectionException e) {
             log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
         }

--
Gitblit v1.9.1