From 73260a50749d5782c18771b98ab4e72499e31eda Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期二, 03 六月 2025 13:15:13 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/zd-after
---
basic-server/src/main/resources/db/migration/postgresql/V20250603102701__create_table_coal_info.sql | 4 ++--
ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java | 37 ++++++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/basic-server/src/main/resources/db/migration/postgresql/V20250603102701__create_table_coal_info.sql b/basic-server/src/main/resources/db/migration/postgresql/V20250603102701__create_table_coal_info.sql
index d0d60c5..e1274a7 100644
--- a/basic-server/src/main/resources/db/migration/postgresql/V20250603102701__create_table_coal_info.sql
+++ b/basic-server/src/main/resources/db/migration/postgresql/V20250603102701__create_table_coal_info.sql
@@ -9,9 +9,9 @@
-- 鏂板瀛楁
deleted int4 NOT NULL DEFAULT 0, -- 鏄惁鍒犻櫎锛堣蒋鍒犻櫎鏍囧織锛�
create_by VARCHAR(255), -- 鍒涘缓浜�
- create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 鍒涘缓鏃堕棿锛岄粯璁ゅ綋鍓嶆椂闂�
+ create_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, -- 鍒涘缓鏃堕棿锛岄粯璁ゅ綋鍓嶆椂闂�
update_by VARCHAR(255), -- 鏈�鍚庢洿鏂颁汉
- update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP -- 鏈�鍚庢洿鏂版椂闂达紝榛樿褰撳墠鏃堕棿
+ update_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP -- 鏈�鍚庢洿鏂版椂闂达紝榛樿褰撳墠鏃堕棿
);
-- 涓鸿〃娣诲姞娉ㄩ噴
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java b/ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java
index 3ae24ea..f77a7a9 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java
@@ -7,23 +7,38 @@
import java.time.LocalDateTime;
-/**
- * @Author: zhangxy
- * @Date: 2020-08-05 14:40
- */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
+
@Override
public void insertFill(MetaObject metaObject) {
- Long userId = SecurityUtils.getLoginUser().getUserId();
- this.strictInsertFill(metaObject, "createBy", Long.class, userId);
- this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
+ // 鍒ゆ柇瀛楁鏄惁瀛樺湪锛屽瓨鍦ㄦ墠濉厖
+ if (metaObject.hasSetter("createBy")) {
+ Long userId = 0L;
+ try {
+ if (SecurityUtils.getLoginUser() != null) {
+ userId = SecurityUtils.getLoginUser().getUserId();
+ this.strictInsertFill(metaObject, "createBy", Long.class, userId);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ if (metaObject.hasSetter("createTime")) {
+ this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
+ }
}
@Override
public void updateFill(MetaObject metaObject) {
- Long userId = SecurityUtils.getLoginUser().getUserId();
- this.strictInsertFill(metaObject, "updateBy", Long.class, userId);
- this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
+ // 鍒ゆ柇瀛楁鏄惁瀛樺湪锛屽瓨鍦ㄦ墠濉厖
+ if (metaObject.hasSetter("updateBy")) {
+ Long userId = SecurityUtils.getLoginUser().getUserId();
+ this.strictUpdateFill(metaObject, "updateBy", Long.class, userId);
+ }
+
+ if (metaObject.hasSetter("updateTime")) {
+ this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
+ }
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3