From 2ddbd99aa5b2e396f96c6daba60fe1ac2573d9fb Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Sat, 18 May 2024 11:53:54 +0800
Subject: [PATCH] 新增RSS 订阅链接

---
 snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/core/mybatis/fieldfill/CustomMetaObjectHandler.java |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 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 0cf9747..9e366e4 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
@@ -63,29 +63,43 @@
         try {
 
             Object updateDate = metaObject.getValue(UPDATE_DATE);
-            if(ObjectUtil.isNull(updateDate)) {
+            if (ObjectUtil.isNull(updateDate)) {
                 setFieldValByName(UPDATE_DATE, new Date(), metaObject);
             }
 
             Object createDate = metaObject.getValue(CREATE_DATE);
-            if(ObjectUtil.isNull(createDate)) {
+            if (ObjectUtil.isNull(createDate)) {
                 setFieldValByName(CREATE_DATE, new Date(), metaObject);
             }
 
             //为空则设置createUser(BaseEntity)
             Object createUser = metaObject.getValue(CREATE_USER);
-            if(ObjectUtil.isNull(createUser)) {
+            if (ObjectUtil.isNull(createUser)) {
                 setFieldValByName(CREATE_USER, this.getUserUniqueId(), metaObject);
             }
 
             //为空则设置createTime(BaseEntity)
             Object createTime = metaObject.getValue(CREATE_TIME);
-            if(ObjectUtil.isNull(createTime)) {
+            if (ObjectUtil.isNull(createTime)) {
                 setFieldValByName(CREATE_TIME, new Date(), metaObject);
             }
 
         } catch (ReflectionException e) {
-            log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
+            //二次设置
+            try {
+                //为空则设置createTime(BaseEntity)
+                Object createTime = metaObject.getValue(CREATE_TIME);
+                if (ObjectUtil.isNull(createTime)) {
+                    setFieldValByName(CREATE_TIME, new Date(), metaObject);
+                }
+                //为空则设置createUser(BaseEntity)
+                Object createUser = metaObject.getValue(CREATE_USER);
+                if (ObjectUtil.isNull(createUser)) {
+                    setFieldValByName(CREATE_USER, this.getUserUniqueId(), metaObject);
+                }
+            } catch (ReflectionException ex) {
+                log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
+            }
         }
     }
 
@@ -110,7 +124,7 @@
     private Long getUserUniqueId() {
         try {
             SysLoginUser sysLoginUser = LoginContextHolder.me().getSysLoginUserWithoutException();
-            if(ObjectUtil.isNotNull(sysLoginUser)) {
+            if (ObjectUtil.isNotNull(sysLoginUser)) {
                 return sysLoginUser.getId();
             } else {
                 return -1L;

--
Gitblit v1.9.1