启动页新增用户字段数据

This commit is contained in:
tianfeng 2025-12-17 17:02:52 +08:00
parent 8e4802b231
commit 6dcbe7acb9
2 changed files with 96 additions and 2 deletions

View File

@ -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<AppStartPageCO> execute(AppExtCommand cmd) {
return sysConfigAppConvertor.toListAppStartPageCO(startPagePlanService
.listBySysOrigin(cmd.requireReqSysOrigin()));
String sysOrigin = cmd.requireReqSysOrigin();
// 查询启动页计划
List<AppStartPageCO> result = sysConfigAppConvertor.toListAppStartPageCO(
startPagePlanService.listBySysOrigin(sysOrigin));
if (CollectionUtils.isEmpty(result)) {
return result;
}
// 收集所有 type
Set<String> types = result.stream()
.map(AppStartPageCO::getType)
.collect(Collectors.toSet());
// 根据 type 分组查询用户
Map<String, List<StartPageUser>> typeUserMap = startPageUserService.mapGroupType(sysOrigin, types);
if (CollectionUtils.isEmpty(typeUserMap)) {
return result;
}
// 收集所有 userId
Set<Long> userIds = typeUserMap.values().stream()
.flatMap(List::stream)
.map(StartPageUser::getUserId)
.collect(Collectors.toSet());
if (CollectionUtils.isEmpty(userIds)) {
return result;
}
// 批量查询用户信息
Map<Long, UserProfile> userInfoMap = userProfileGateway.mapByUserIds(userIds);
// 组装结果
result.forEach(co -> {
List<StartPageUser> users = typeUserMap.get(co.getType());
if (!CollectionUtils.isEmpty(users)) {
List<AppStartPageCO.UserInfo> 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;
}
}

View File

@ -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<UserInfo> user;
/**
* 用户信息.
*/
@Data
public static class UserInfo {
/**
* 账号.
*/
private String account;
/**
* 昵称.
*/
private String nickName;
/**
* 头像.
*/
private String avatar;
}
}