From 1a461f7d3dab6a7b6dcaaf8287a366f158d68d52 Mon Sep 17 00:00:00 2001 From: AprilWind <2100166581@qq.com> Date: Mon, 15 Dec 2025 03:10:49 +0000 Subject: [PATCH] =?UTF-8?q?!804=20update=20=E4=BC=98=E5=8C=96=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8F=90=E7=A4=BA=E8=AF=AD=20*=20update=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=99=BB=E5=BD=95=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/AuthController.java | 7 +++--- .../dromara/common/core/utils/DateUtils.java | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index 89b9ab63c..c448a60d3 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.*; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -106,7 +107,7 @@ public class AuthController { Long userId = LoginHelper.getUserId(); scheduledExecutorService.schedule(() -> { SseMessageDto dto = new SseMessageDto(); - dto.setMessage("欢迎登录RuoYi-Vue-Plus后台管理系统"); + dto.setMessage(DateUtils.getTodayHour(new Date()) + "好,欢迎登录 RuoYi-Vue-Plus 后台管理系统"); dto.setUserIds(List.of(userId)); SseMessageUtils.publishMessage(dto); }, 5, TimeUnit.SECONDS); @@ -147,8 +148,8 @@ public class AuthController { StpUtil.checkLogin(); // 获取第三方登录信息 AuthResponse response = SocialUtils.loginAuth( - loginBody.getSource(), loginBody.getSocialCode(), - loginBody.getSocialState(), socialProperties); + loginBody.getSource(), loginBody.getSocialCode(), + loginBody.getSocialState(), socialProperties); AuthUser authUserData = response.getData(); // 判断授权响应是否成功 if (!response.ok()) { diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java index b4d146242..1970f063e 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java @@ -1,5 +1,6 @@ package org.dromara.common.core.utils; +import cn.hutool.core.date.DateUtil; import org.apache.commons.lang3.time.DateFormatUtils; import org.dromara.common.core.enums.FormatsType; import org.dromara.common.core.exception.ServiceException; @@ -297,4 +298,25 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { } } + /** + * 根据指定日期时间获取时间段(凌晨 / 上午 / 中午 / 下午 / 晚上) + * + * @param date 日期时间 + * @return 时间段描述 + */ + public static String getTodayHour(Date date) { + int hour = DateUtil.hour(date, true); + if (hour <= 6) { + return "凌晨"; + } else if (hour < 12) { + return "上午"; + } else if (hour == 12) { + return "中午"; + } else if (hour <= 18) { + return "下午"; + } else { + return "晚上"; + } + } + }