From bfffc6bbf1b6d6eebee2d9832af4d76c50391495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Wed, 2 Sep 2026 20:46:31 +0800 Subject: [PATCH] =?UTF-8?q?App=E6=B8=B8=E5=AE=A2=E6=97=B6=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=B1=95=E7=A4=BA=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageManageApplicationService.java | 24 ++++++++++++++++++- .../src/main/resources/bootstrap.yml | 8 +++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/MessageManageApplicationService.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/MessageManageApplicationService.java index afa11d0ef..62703d4b2 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/MessageManageApplicationService.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/MessageManageApplicationService.java @@ -461,7 +461,8 @@ public class MessageManageApplicationService //获取当前登录人 LoginUser loginUser = SecurityUtils.getLoginUser(); if(null == loginUser){ - throw new ServiceException("获取登录人失败"); + //未登录(游客):返回空消息中心结构,保证小程序界面正常展示而不报错 + return buildEmptyAppNoticeList(); } noticeMessageLoggingDo.setUserId(loginUser.getUserid()); //获取每种类型的最新一条 @@ -522,6 +523,27 @@ public class MessageManageApplicationService return result; } + /** + * 未登录(游客)时返回空的消息中心结构,避免前端页面因无登录上下文而报错 + * @return NoticeMessageLoggingAppListPo + */ + private NoticeMessageLoggingAppListPo buildEmptyAppNoticeList() { + NoticeMessageLoggingAppListPo result = new NoticeMessageLoggingAppListPo(); + NoticeMessageLoggingAppListPo.CommonNotice serviceNotice = new NoticeMessageLoggingAppListPo.CommonNotice(); + serviceNotice.setUnreadNum("0"); + NoticeMessageLoggingAppListPo.CommonNotice activityNotice = new NoticeMessageLoggingAppListPo.CommonNotice(); + activityNotice.setUnreadNum("0"); + NoticeMessageLoggingAppListPo.CommonNotice logisticsNotice = new NoticeMessageLoggingAppListPo.CommonNotice(); + logisticsNotice.setUnreadNum("0"); + NoticeMessageLoggingAppListPo.CommonNotice systemNotice = new NoticeMessageLoggingAppListPo.CommonNotice(); + systemNotice.setUnreadNum("0"); + result.setServiceNotice(serviceNotice); + result.setActivityNotice(activityNotice); + result.setLogisticsNotice(logisticsNotice); + result.setSystemNotice(systemNotice); + return result; + } + /** * APP根据类型获取消息通知 * @param noticeMessageLoggingDo diff --git a/mhd-modules/mhd-system/src/main/resources/bootstrap.yml b/mhd-modules/mhd-system/src/main/resources/bootstrap.yml index dc450c4ce..b1b1ca982 100644 --- a/mhd-modules/mhd-system/src/main/resources/bootstrap.yml +++ b/mhd-modules/mhd-system/src/main/resources/bootstrap.yml @@ -13,17 +13,17 @@ spring: cloud: nacos: discovery: - server-addr: 127.0.0.1:8848 +# server-addr: 127.0.0.1:8848 # server-addr: 10.33.0.129:6010 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 # server-addr: 10.102.192.105:6848 config: - server-addr: 127.0.0.1:8848 +# server-addr: 127.0.0.1:8848 # server-addr: 10.33.0.129:6010 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境