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 #线上正式环境