From d2990a4b5084ad83920307ec5b01ac0bd3a96a5f Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 03 九月 2026 11:53:39 +0800
Subject: [PATCH] fix: 时区错误
---
src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java | 4 +-
src/main/resources/mapper/monitor/SysOperLogMapper.xml | 18 ++++----
src/main/java/com/ruoyi/framework/config/ApplicationConfig.java | 5 ++
src/main/java/com/ruoyi/project/system/domain/SysUser.java | 66 +++++++++++++++++----------------
4 files changed, 49 insertions(+), 44 deletions(-)
diff --git a/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
index 2cc50ba..ecca849 100644
--- a/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
+++ b/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
@@ -16,6 +16,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
+import java.text.SimpleDateFormat;
import java.util.TimeZone;
/**
@@ -34,7 +35,7 @@
*/
@Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
- return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
+ return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getTimeZone("GMT+8"));
}
@Bean
@@ -59,6 +60,8 @@
new LocalDateSerializer(dateFormatter));
mapper.registerModule(module);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
+ mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
return mapper;
}
}
diff --git a/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java b/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
index 8874722..3fefc07 100644
--- a/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
+++ b/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java
@@ -28,14 +28,14 @@
private String createBy;
/** 鍒涘缓鏃堕棿 */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 鏇存柊鑰� */
private String updateBy;
/** 鏇存柊鏃堕棿 */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/** 澶囨敞 */
diff --git a/src/main/java/com/ruoyi/project/system/domain/SysUser.java b/src/main/java/com/ruoyi/project/system/domain/SysUser.java
index 515210e..d316086 100644
--- a/src/main/java/com/ruoyi/project/system/domain/SysUser.java
+++ b/src/main/java/com/ruoyi/project/system/domain/SysUser.java
@@ -1,8 +1,9 @@
package com.ruoyi.project.system.domain;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.ruoyi.common.xss.Xss;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.ruoyi.common.xss.Xss;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type;
@@ -60,19 +61,20 @@
@Excel(name = "璐﹀彿鐘舵��", readConverterExp = "0=姝e父,1=鍋滅敤")
private String status;
- /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */
- private String delFlag;
-
- /** 鏄惁寮�閫欰I鍔熻兘锛�0鍚� 1鏄級 */
- @JsonIgnore
- private Integer aiEnabled;
-
+ /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */
+ private String delFlag;
+
+ /** 鏄惁寮�閫欰I鍔熻兘锛�0鍚� 1鏄級 */
+ @JsonIgnore
+ private Integer aiEnabled;
+
/** 鏈�鍚庣櫥褰旾P */
@Excel(name = "鏈�鍚庣櫥褰旾P", type = Type.EXPORT)
private String loginIp;
/** 鏈�鍚庣櫥褰曟椂闂� */
@Excel(name = "鏈�鍚庣櫥褰曟椂闂�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date loginDate;
/** 閮ㄩ棬瀵硅薄 */
@@ -255,25 +257,25 @@
this.status = status;
}
- public String getDelFlag()
- {
- return delFlag;
- }
+ public String getDelFlag()
+ {
+ return delFlag;
+ }
- public void setDelFlag(String delFlag)
- {
- this.delFlag = delFlag;
- }
-
- public Integer getAiEnabled()
- {
- return aiEnabled;
- }
-
- public void setAiEnabled(Integer aiEnabled)
- {
- this.aiEnabled = aiEnabled;
- }
+ public void setDelFlag(String delFlag)
+ {
+ this.delFlag = delFlag;
+ }
+
+ public Integer getAiEnabled()
+ {
+ return aiEnabled;
+ }
+
+ public void setAiEnabled(Integer aiEnabled)
+ {
+ this.aiEnabled = aiEnabled;
+ }
public String getLoginIp()
{
@@ -388,10 +390,10 @@
.append("sex", getSex())
.append("avatar", getAvatar())
.append("password", getPassword())
- .append("status", getStatus())
- .append("delFlag", getDelFlag())
- .append("aiEnabled", getAiEnabled())
- .append("loginIp", getLoginIp())
+ .append("status", getStatus())
+ .append("delFlag", getDelFlag())
+ .append("aiEnabled", getAiEnabled())
+ .append("loginIp", getLoginIp())
.append("loginDate", getLoginDate())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
diff --git a/src/main/resources/mapper/monitor/SysOperLogMapper.xml b/src/main/resources/mapper/monitor/SysOperLogMapper.xml
index 6bb7e8f..4c504a3 100644
--- a/src/main/resources/mapper/monitor/SysOperLogMapper.xml
+++ b/src/main/resources/mapper/monitor/SysOperLogMapper.xml
@@ -28,12 +28,12 @@
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time
from sys_oper_log
</sql>
-
+
<insert id="insertOperlog" parameterType="com.ruoyi.project.monitor.domain.SysOperLog">
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate())
</insert>
-
+
<select id="selectOperLogList" parameterType="com.ruoyi.project.monitor.domain.SysOperLog" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
<where>
@@ -50,7 +50,7 @@
AND business_type in
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
#{businessType}
- </foreach>
+ </foreach>
</if>
<if test="status != null">
AND status = #{status}
@@ -65,23 +65,23 @@
AND oper_time <= #{params.endTime}
</if>
</where>
- order by oper_id desc
+ order by oper_time desc
</select>
-
+
<delete id="deleteOperLogByIds" parameterType="Long">
delete from sys_oper_log where oper_id in
<foreach collection="array" item="operId" open="(" separator="," close=")">
#{operId}
- </foreach>
+ </foreach>
</delete>
-
+
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>
-
+
<update id="cleanOperLog">
truncate table sys_oper_log
</update>
-</mapper>
\ No newline at end of file
+</mapper>
--
Gitblit v1.9.3