From 6dcbe7acb99561d1d008546c5724b0a5fb62a0f2 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 17 Dec 2025 17:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AD=97=E6=AE=B5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/sys/query/AppPageStartQryExe.java | 71 ++++++++++++++++++- .../dto/clientobject/sys/AppStartPageCO.java | 27 +++++++ 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/AppPageStartQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/AppPageStartQryExe.java index 71355126..7f536677 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/AppPageStartQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/AppPageStartQryExe.java @@ -3,10 +3,19 @@ package com.red.circle.other.app.command.sys.query; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.other.app.convertor.sys.SysConfigAppConvertor; import com.red.circle.other.app.dto.clientobject.sys.AppStartPageCO; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.model.user.UserProfile; +import com.red.circle.other.infra.database.rds.entity.sys.StartPageUser; import com.red.circle.other.infra.database.rds.service.sys.StartPagePlanService; import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import com.red.circle.other.infra.database.rds.service.sys.StartPageUserService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; /** * app 启动页. @@ -19,10 +28,68 @@ public class AppPageStartQryExe { private final SysConfigAppConvertor sysConfigAppConvertor; private final StartPagePlanService startPagePlanService; + private final StartPageUserService startPageUserService; + private final UserProfileGateway userProfileGateway; public List execute(AppExtCommand cmd) { - return sysConfigAppConvertor.toListAppStartPageCO(startPagePlanService - .listBySysOrigin(cmd.requireReqSysOrigin())); + String sysOrigin = cmd.requireReqSysOrigin(); + + // 查询启动页计划 + List result = sysConfigAppConvertor.toListAppStartPageCO( + startPagePlanService.listBySysOrigin(sysOrigin)); + + if (CollectionUtils.isEmpty(result)) { + return result; + } + + // 收集所有 type + Set types = result.stream() + .map(AppStartPageCO::getType) + .collect(Collectors.toSet()); + + // 根据 type 分组查询用户 + Map> typeUserMap = startPageUserService.mapGroupType(sysOrigin, types); + + if (CollectionUtils.isEmpty(typeUserMap)) { + return result; + } + + // 收集所有 userId + Set userIds = typeUserMap.values().stream() + .flatMap(List::stream) + .map(StartPageUser::getUserId) + .collect(Collectors.toSet()); + + if (CollectionUtils.isEmpty(userIds)) { + return result; + } + + // 批量查询用户信息 + Map userInfoMap = userProfileGateway.mapByUserIds(userIds); + + // 组装结果 + result.forEach(co -> { + List users = typeUserMap.get(co.getType()); + if (!CollectionUtils.isEmpty(users)) { + List userList = users.stream() + .map(user -> { + UserProfile userInfo = userInfoMap.get(user.getUserId()); + if (userInfo != null) { + AppStartPageCO.UserInfo info = new AppStartPageCO.UserInfo(); + info.setAccount(userInfo.getAccount()); + info.setNickName(userInfo.getUserNickname()); + info.setAvatar(userInfo.getUserAvatar()); + return info; + } + return null; + }) + .filter(java.util.Objects::nonNull) + .collect(Collectors.toList()); + co.setUser(userList); + } + }); + + return result; } } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/sys/AppStartPageCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/sys/AppStartPageCO.java index 8683f532..f5a78e25 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/sys/AppStartPageCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/sys/AppStartPageCO.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.red.circle.framework.dto.ClientObject; import java.sql.Timestamp; +import java.util.List; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -46,4 +47,30 @@ public class AppStartPageCO extends ClientObject { */ private Timestamp expireTime; + /** + * 用户列表. + */ + private List user; + + /** + * 用户信息. + */ + @Data + public static class UserInfo { + /** + * 账号. + */ + private String account; + + /** + * 昵称. + */ + private String nickName; + + /** + * 头像. + */ + private String avatar; + } + }