ConvertUtil.java 17.6 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2
package com.tanpu.community.util;

刘基明's avatar
刘基明 committed
3
import com.fasterxml.jackson.core.type.TypeReference;
张辰's avatar
张辰 committed
4 5
import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.community.TopicStatusEnum;
刘基明's avatar
刘基明 committed
6
import com.tanpu.common.exception.BizException;
刘基明's avatar
刘基明 committed
7
import com.tanpu.common.util.JsonUtil;
刘基明's avatar
刘基明 committed
8
import com.tanpu.community.api.beans.qo.*;
刘基明's avatar
刘基明 committed
9
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
刘基明's avatar
刘基明 committed
10
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
刘基明's avatar
刘基明 committed
11 12 13
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
14
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
刘基明's avatar
刘基明 committed
15
import com.tanpu.community.api.enums.DeleteTagEnum;
刘基明's avatar
刘基明 committed
16
import com.tanpu.community.api.enums.NotificationTypeEnum;
刘基明's avatar
刘基明 committed
17
import com.tanpu.community.api.enums.TopicSpecialPermissionEnum;
刘基明's avatar
刘基明 committed
18
import com.tanpu.community.dao.entity.NotificationForwardDO;
刘基明's avatar
刘基明 committed
19
import com.tanpu.community.dao.entity.NotificationLikeDO;
刘基明's avatar
刘基明 committed
20 21
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
刘基明's avatar
刘基明 committed
22
import com.tanpu.community.dao.entity.community.NotificationEntity;
刘基明's avatar
刘基明 committed
23 24 25 26
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.VisitLogEntity;
刘基明's avatar
刘基明 committed
27
import org.apache.commons.collections4.CollectionUtils;
刘基明's avatar
刘基明 committed
28
import org.apache.commons.lang3.StringUtils;
刘基明's avatar
刘基明 committed
29 30
import org.springframework.beans.BeanUtils;

张辰's avatar
张辰 committed
31 32
import java.time.LocalDateTime;
import java.time.ZoneOffset;
刘基明's avatar
刘基明 committed
33
import java.util.ArrayList;
刘基明's avatar
刘基明 committed
34
import java.util.Collections;
刘基明's avatar
刘基明 committed
35
import java.util.List;
刘基明's avatar
刘基明 committed
36
import java.util.Map;
刘基明's avatar
刘基明 committed
37
import java.util.TreeSet;
刘基明's avatar
刘基明 committed
38 39 40 41
import java.util.stream.Collectors;

public class ConvertUtil {

刘基明's avatar
刘基明 committed
42
    public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
刘基明's avatar
刘基明 committed
43
        if (themeEntity == null) {
刘基明's avatar
刘基明 committed
44 45 46 47
            return null;
        }
        ThemeQo themeQO = new ThemeQo();
        BeanUtils.copyProperties(themeEntity, themeQO);
刘基明's avatar
刘基明 committed
48 49 50
        themeQO.setUpdateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getUpdateTime()));
        themeQO.setCreateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getCreateTime()));
        themeQO.setUpToNowTime(TimeUtils.calUpToNowTime(themeEntity.getCreateTime()));
刘基明's avatar
刘基明 committed
51
        themeQO.setFormatTime(TimeUtils.format(themeEntity.getCreateTime()));
刘基明's avatar
刘基明 committed
52

刘基明's avatar
刘基明 committed
53

刘基明's avatar
刘基明 committed
54
        List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
刘基明's avatar
刘基明 committed
55
        });
刘基明's avatar
刘基明 committed
56
        // 屏蔽手机号和邮箱
刘基明's avatar
刘基明 committed
57
        themeContentQos.stream().filter(o -> RelTypeEnum.TEXT.type.equals(o.getType())).forEach(o -> o.setValue(OtherUtil.blockPhoneAndEmail(o.getValue())));
刘基明's avatar
刘基明 committed
58

刘基明's avatar
刘基明 committed
59
        themeQO.setContent(themeContentQos);
刘基明's avatar
刘基明 committed
60 61 62
        return themeQO;
    }

刘基明's avatar
刘基明 committed
63
    public static ThemeAnalysDO themeEntityToAnalysDO(ThemeEntity themeEntity) {
刘基明's avatar
刘基明 committed
64
        if (themeEntity == null) {
刘基明's avatar
刘基明 committed
65 66
            return null;
        }
刘基明's avatar
刘基明 committed
67 68
        ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
        BeanUtils.copyProperties(themeEntity, themeAnalysDO);
69
        themeAnalysDO.setMinutesTillNow(TimeUtils.calMinuteTillNow(themeEntity.getCreateTime()));
刘基明's avatar
刘基明 committed
70
        return themeAnalysDO;
刘基明's avatar
刘基明 committed
71 72
    }

刘基明's avatar
刘基明 committed
73 74
    public static List<ThemeAnalysDO> themeEntityToAnalysDOs(List<ThemeEntity> themeEntities) {
        return themeEntities.stream().map(ConvertUtil::themeEntityToAnalysDO).collect(Collectors.toList());
刘基明's avatar
刘基明 committed
75 76
    }

刘基明's avatar
刘基明 committed
77
    public static List<ThemeQo> themeEntitiesToDTOs(List<ThemeEntity> themeEntities) {
刘基明's avatar
刘基明 committed
78
        return themeEntities.stream().map(ConvertUtil::themeEntityToQo).collect(Collectors.toList());
刘基明's avatar
刘基明 committed
79 80
    }

刘基明's avatar
刘基明 committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94

    // 抽取文本内容
    public static String convertThemeText(String content) {

        List<ThemeContentQo> themeContentQos = JsonUtil.toBean(content, new TypeReference<List<ThemeContentQo>>() {
        });
        StringBuilder sb = new StringBuilder();
        themeContentQos.stream().filter(q -> RelTypeEnum.TEXT.type.equals(q.getType())).forEach(q -> {
            sb.append(q.getValue());
        });

        return sb.toString();
    }

张辰's avatar
张辰 committed
95 96 97 98 99
    public static ESThemeQo convert(ThemeEntity entity) {
        ESThemeQo qo = new ESThemeQo();
        BeanUtils.copyProperties(entity, qo);

        // 抽取文本内容
100 101
        List<ThemeContentQo> themeContentQos = JsonUtil.toBean(entity.getContent(), new TypeReference<List<ThemeContentQo>>() {
        });
张辰's avatar
张辰 committed
102
        StringBuilder sb = new StringBuilder();
刘基明's avatar
刘基明 committed
103
        themeContentQos.stream().filter(q -> RelTypeEnum.TEXT.type.equals(q.getType())).forEach(q -> {
张辰's avatar
张辰 committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
            sb.append(q.getValue());
        });
        qo.textContent = sb.toString();

        Long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        if (entity.getCreateTime() == null) {
            qo.setCreateTime(now);
            qo.setUpdateTime(now);
        } else {
            qo.setCreateTime(entity.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
            qo.setUpdateTime(now);
        }

        return qo;
    }

刘基明's avatar
刘基明 committed
120

刘基明's avatar
刘基明 committed
121 122 123
    public static TopicRankQo topicEntityToHotQo(TopicEntity topicEntity) {
        TopicRankQo topicRankQo = new TopicRankQo();
        BeanUtils.copyProperties(topicEntity, topicRankQo);
刘基明's avatar
刘基明 committed
124 125
        // 24小时内发帖,添加新话题标签
        if (TimeUtils.calMinuteTillNow(topicEntity.getCreateTime()) < 60 * 24) {
刘基明's avatar
刘基明 committed
126
            topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
刘基明's avatar
刘基明 committed
127
        }
刘基明's avatar
刘基明 committed
128
        // 根据是否专属设置默认权限
刘基明's avatar
刘基明 committed
129
        if (TopicSpecialPermissionEnum.FALSE.getCode().equals(topicEntity.getSpecialPermission())) {
刘基明's avatar
刘基明 committed
130
            topicRankQo.setHasPermission(true);
刘基明's avatar
刘基明 committed
131
        } else {
刘基明's avatar
刘基明 committed
132 133
            topicRankQo.setHasPermission(false);
        }
134
        topicRankQo.setMinutesTillNow((int) TimeUtils.calMinuteTillNow(topicEntity.getCreateTime()));
刘基明's avatar
刘基明 committed
135
        return topicRankQo;
刘基明's avatar
刘基明 committed
136 137
    }

刘基明's avatar
刘基明 committed
138
    public static List<TopicRankQo> topicEntityToRankQos(List<TopicEntity> topicEntities) {
139
        if (topicEntities == null) {
刘基明's avatar
刘基明 committed
140 141
            return Collections.emptyList();
        }
刘基明's avatar
刘基明 committed
142 143 144
        return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
    }

刘基明's avatar
刘基明 committed
145 146 147 148 149 150 151 152 153 154
    public static List<TopicFollowQo> topicEntityToFollowQos(List<TopicEntity> topicEntities) {
        if (topicEntities == null) {
            return Collections.emptyList();
        }
        return topicEntities.stream().map(ConvertUtil::topicEntityToFollowQo).collect(Collectors.toList());
    }

    private static TopicFollowQo topicEntityToFollowQo(TopicEntity topicEntity) {
        TopicFollowQo topicFollowQo = new TopicFollowQo();
        BeanUtils.copyProperties(topicEntity, topicFollowQo);
刘基明's avatar
刘基明 committed
155
        topicFollowQo.setHasPermission(true);
刘基明's avatar
刘基明 committed
156 157 158
        return topicFollowQo;
    }

刘基明's avatar
刘基明 committed
159

刘基明's avatar
刘基明 committed
160 161 162
    public static CommentQo commentEntity2Qo(CommentEntity entity) {
        CommentQo qo = new CommentQo();
        BeanUtils.copyProperties(entity, qo);
刘基明's avatar
刘基明 committed
163
        qo.setContent(OtherUtil.blockPhoneAndEmail(entity.getContent()));
刘基明's avatar
刘基明 committed
164
        qo.setUpdateTime(TimeUtils.getTimestampOfDateTime(entity.getUpdateTime()));
刘基明's avatar
刘基明 committed
165
        if (StringUtils.isBlank(entity.getReplyUserId())) {
刘基明's avatar
刘基明 committed
166 167
            qo.setReplyUserId(null);
        }
刘基明's avatar
刘基明 committed
168 169 170
        return qo;
    }

刘基明's avatar
刘基明 committed
171
    public static List<CommentQo> commentEntity2Qos(List<CommentEntity> entities) {
刘基明's avatar
刘基明 committed
172 173
        return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList());
    }
张辰's avatar
张辰 committed
174

张辰's avatar
张辰 committed
175 176 177
    /**
     * VISIT_SUMMARY
     */
刘基明's avatar
刘基明 committed
178 179
    public static VisitLogEntity convertFromKafka(KafkaDurationUptMsg msg) {
        VisitLogEntity vs = new VisitLogEntity();
张辰's avatar
张辰 committed
180 181
        vs.setAuthorId(msg.pidUserId);
        vs.setDeleteTag(DeleteTagEnum.NOT_DELETED.ordinal());
张辰's avatar
张辰 committed
182
        vs.setDuration((int) msg.durMillsInc / 1000);
张辰's avatar
张辰 committed
183 184
        vs.setIdent(msg.ident);
        vs.setRefId(msg.refId);
张辰's avatar
张辰 committed
185
        vs.setRefType(msg.pageId);
张辰's avatar
张辰 committed
186 187 188 189
        vs.setVisitorId(msg.visitorId);
        return vs;
    }

刘基明's avatar
刘基明 committed
190 191
    /**
     * 解析 List<ThemeContentReq>为Attachment列表
刘基明's avatar
刘基明 committed
192
     *
刘基明's avatar
刘基明 committed
193 194 195 196
     * @param req
     * @param themeId
     * @return
     */
刘基明's avatar
刘基明 committed
197
    public static List<ThemeAttachmentEntity> themeReqToAttachmentList(CreateThemeReq req, String themeId) {
刘基明's avatar
刘基明 committed
198 199
        List<ThemeContentReq> contents = req.getContent();

刘基明's avatar
刘基明 committed
200
        List<ThemeAttachmentEntity> list = new ArrayList<>();
刘基明's avatar
刘基明 committed
201
        for (ThemeContentReq content : contents) {
刘基明's avatar
刘基明 committed
202
            if (!RelTypeEnum.TEXT.type.equals(content.getType())) {
刘基明's avatar
刘基明 committed
203
                //讨论-多图类型,拆开解析到attachment表中
刘基明's avatar
刘基明 committed
204
                if ((content.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type))) {
刘基明's avatar
刘基明 committed
205 206 207 208 209 210 211 212
                    List<ImagesDTO> imgList = content.getImgList();
                    for (ImagesDTO imagesDTO : imgList) {
                        list.add(ThemeAttachmentEntity.builder()
                                .attachType(Integer.valueOf(RelTypeEnum.SINGLE_IMG.type))
                                .attachId(imagesDTO.getRelId())
                                .themeId(themeId)
                                .build());
                    }
刘基明's avatar
刘基明 committed
213
                } else if ((content.getType().equals(RelTypeEnum.SINGLE_IMG.type))) {
214
                    if (StringUtils.isEmpty(content.getValue())) {
刘基明's avatar
刘基明 committed
215 216 217 218 219
                        list.add(ThemeAttachmentEntity.builder()
                                .attachType(Integer.valueOf(content.getType()))
                                .attachId(content.getValue())
                                .themeId(themeId)
                                .build());
220
                    } else {
刘基明's avatar
刘基明 committed
221 222 223 224 225 226 227 228 229 230
                        List<ImagesDTO> imgList = content.getImgList();
                        for (ImagesDTO imagesDTO : imgList) {
                            list.add(ThemeAttachmentEntity.builder()
                                    .attachType(Integer.valueOf(RelTypeEnum.SINGLE_IMG.type))
                                    .attachId(imagesDTO.getRelId())
                                    .themeId(themeId)
                                    .build());
                        }
                    }

231
                } else {
刘基明's avatar
刘基明 committed
232 233 234 235 236
                    list.add(ThemeAttachmentEntity.builder()
                            .attachType(Integer.valueOf(content.getType()))
                            .attachId(content.getValue())
                            .themeId(themeId)
                            .build());
刘基明's avatar
刘基明 committed
237
                }
刘基明's avatar
刘基明 committed
238 239
            }
        }
刘基明's avatar
刘基明 committed
240 241 242 243
        return list;
    }


244
    public static FollowQo userInfoNew2FollowQo(UserInfoResp entity) {
刘基明's avatar
刘基明 committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
        if (entity == null) {
            return null;
        }
        return FollowQo.builder().userId(entity.getUserId())
                .nickName(entity.getNickName())
                .headImg(entity.getHeadImageUrl())
                .introduction(entity.getIntroduction())
                .userType(entity.getUserType())
                .levelGrade(entity.getLevelGrade())
                .userInvestorType(entity.getUserInvestorType())
                .belongUserOrgId(entity.getBelongUserOrgId())
                .belongUserOrgName(entity.getBelongUserOrgName())
                .build();
    }

刘基明's avatar
刘基明 committed
260 261 262 263
    public static FormerThemeQo themeQo2FormerThemeQo(ThemeQo formerTheme) {
        if (formerTheme == null) {
            return null;
        }
刘基明's avatar
刘基明 committed
264 265
        return FormerThemeQo.builder().themeId(formerTheme.getThemeId())
                .content(formerTheme.getContent())
刘基明's avatar
刘基明 committed
266 267 268 269 270 271 272 273 274 275
                .userImg(formerTheme.getUserImg())
                .nickName(formerTheme.getNickName())
                .title(formerTheme.getTitle())
                .topicId(formerTheme.getTopicId())
                .topicTitle(formerTheme.getTopicTitle())
                .authorId(formerTheme.getAuthorId())
                .themeType(formerTheme.getThemeType())
                .build();
    }

276
    public static FileUploadResp fileRecordEntity2Resp(FileRecordEntity entity) {
刘基明's avatar
刘基明 committed
277
        FileUploadResp resp = new FileUploadResp();
278
        BeanUtils.copyProperties(entity, resp);
刘基明's avatar
刘基明 committed
279 280 281 282 283 284 285 286 287
        String extInfo = entity.getExtInfo();
        if (!StringUtils.isEmpty(extInfo)) {
            Map<String, Object> extMap = JsonUtil.toMap(extInfo);
            resp.setImgHeight((Integer) extMap.get("height"));
            resp.setImgWidth((Integer) extMap.get("width"));
        }
        return resp;
    }

刘基明's avatar
刘基明 committed
288 289 290 291 292
    public static ThemeNotifyQo notificationEntitiy2ThemeQo(NotificationEntity entity) {
        ThemeNotifyQo themeNotifyQo = new ThemeNotifyQo();
        BeanUtils.copyProperties(entity, themeNotifyQo);
        // 操作者
        themeNotifyQo.setAuthorId(entity.getOperatorId());
刘基明's avatar
刘基明 committed
293 294
        themeNotifyQo.setUpToNowTime(TimeUtils.calUpToNowTime(entity.getUpdateTime()));
        themeNotifyQo.setFormatTime(TimeUtils.format(entity.getUpdateTime()));
刘基明's avatar
刘基明 committed
295 296 297 298 299 300 301
        // 转、评、赞 有原贴
        if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode()) ||
                entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode()) ||
                entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode())
        ) {
            themeNotifyQo.setFormerThemeId(entity.getTargetId());
        }
302 303
        // 评、点赞评论 评论Id
        if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode()) ||
刘基明's avatar
刘基明 committed
304 305
                entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode()) ||
                entity.getMessageType().equals(NotificationTypeEnum.COMMENT_REPLY.getCode())
306 307 308
        ) {
            themeNotifyQo.setCommentId(entity.getTargetId());
        }
刘基明's avatar
刘基明 committed
309 310 311 312 313
        // 主题加入退出
        if (NotificationTypeEnum.TOPIC_IN.getCode().equals(entity.getMessageType()) ||
                NotificationTypeEnum.TOPIC_OUT.getCode().equals(entity.getMessageType())) {
            themeNotifyQo.setTopicId(entity.getTargetId());
        }
刘基明's avatar
刘基明 committed
314 315 316
        // 转发有话题信息
        if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode())) {
            themeNotifyQo.setFormerThemeId(entity.getTargetId());
刘基明's avatar
刘基明 committed
317
            themeNotifyQo.setFormerUserName(entity.getNotifiedUserId());
刘基明's avatar
刘基明 committed
318
            if (!StringUtils.isEmpty(entity.getContent())) {
刘基明's avatar
刘基明 committed
319
                try {
刘基明's avatar
刘基明 committed
320 321 322
                    NotificationForwardDO forwardDO = JsonUtil.toBean(entity.getContent(), NotificationForwardDO.class);
                    themeNotifyQo.setContent(forwardDO.getContent());
                    themeNotifyQo.setTopicId(forwardDO.getTopicId());
323
                    themeNotifyQo.setForwardThemeId(forwardDO.getThemeId());
刘基明's avatar
刘基明 committed
324 325
                } catch (Exception e) {
                    throw new BizException("消息通知-转发类型-反序列化异常:" + entity.getContent());
刘基明's avatar
刘基明 committed
326
                }
刘基明's avatar
刘基明 committed
327 328 329
            }
        }
        // 点赞需要聚合头像和人数
330 331
        if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode()) ||
                entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode())) {
刘基明's avatar
刘基明 committed
332 333 334 335 336 337

            if (!StringUtils.isEmpty(entity.getContent())) {
                try {
                    NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class);
                    themeNotifyQo.setLikeUserCount(notificationLikeDO.getCount());
                    ArrayList<UserBriefInfoQO> likeUsers = new ArrayList<>();
刘基明's avatar
刘基明 committed
338
                    notificationLikeDO.getSet().stream().forEach(o -> likeUsers.add(UserBriefInfoQO.builder().userId(o).build()));
刘基明's avatar
刘基明 committed
339
                    themeNotifyQo.setLikeUsers(likeUsers);
刘基明's avatar
刘基明 committed
340 341
                } catch (Exception e) {
                    throw new BizException("消息通知-点赞类型-反序列化异常:" + entity.getContent());
刘基明's avatar
刘基明 committed
342
                }
刘基明's avatar
刘基明 committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
            }
        }
        return themeNotifyQo;
    }

    public static List<ThemeNotifyQo> notificationEntitiy2ThemeQos(List<NotificationEntity> entities) {
        return entities.stream().map(ConvertUtil::notificationEntitiy2ThemeQo).collect(Collectors.toList());
    }

    public static void main(String[] args) {
        NotificationLikeDO notificationLikeDO = new NotificationLikeDO();
        notificationLikeDO.setCount(1);
        TreeSet<String> set = new TreeSet<>();
        set.add("aaa");
        set.add("bbb");
        set.add("ccc");

        set.pollFirst();
        set.add("ddd");
        notificationLikeDO.setSet(set);

        String x = JsonUtil.toJson(notificationLikeDO);
        System.out.println(x);
        NotificationLikeDO notificationLikeDO1 = JsonUtil.toBean(x, NotificationLikeDO.class);
        System.out.println(notificationLikeDO1);
    }

刘基明's avatar
刘基明 committed
370

刘基明's avatar
刘基明 committed
371 372 373 374 375 376 377 378 379 380
    public static List<CommentSimpleQo> comment2Simple(List<CommentEntity> comments, Map<String, String> nameMap) {
        if (CollectionUtils.isEmpty(comments)) return null;
        return comments.stream().map(o -> {
            CommentSimpleQo commentSimpleQo = new CommentSimpleQo();
            BeanUtils.copyProperties(o, commentSimpleQo);
            commentSimpleQo.setNickName(nameMap.getOrDefault(commentSimpleQo.getAuthorId(), "探普用户"));
            return commentSimpleQo;
        }).collect(Collectors.toList());

    }
刘基明's avatar
刘基明 committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400

    public static List<ThemeSimpleQo> themeEntity2Discussion(List<ThemeEntity> themeEntities, Map<String, UserInfoResp> nameMap) {
        if (CollectionUtils.isEmpty(themeEntities)) return Collections.emptyList();
        return themeEntities.stream().map(o->{
            ThemeQo themeQo = themeEntityToQo(o);
            ThemeSimpleQo themeSimpleQo = new ThemeSimpleQo();
            BeanUtils.copyProperties(themeQo,themeSimpleQo);
            String authorId = themeSimpleQo.getAuthorId();
            if (nameMap.containsKey(authorId)) {
                UserInfoResp userInfo = nameMap.get(authorId);
                themeSimpleQo.setNickName(userInfo.getNickName());
                themeSimpleQo.setUserImg(userInfo.getHeadImageUrl());
            }
            themeSimpleQo.setFormatTime(TimeUtils.calUpToNowTime(o.getUpdateTime()));
            themeSimpleQo.setContent(themeQo.getContent().get(0).getValue());
            return themeSimpleQo;

        }).collect(Collectors.toList());

    }
刘基明's avatar
刘基明 committed
401
}