BatchFeignCallService.java 23.2 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3
package com.tanpu.community.service;

import com.google.common.collect.Maps;
刘基明's avatar
刘基明 committed
4
import com.google.common.collect.Sets;
刘基明's avatar
刘基明 committed
5 6
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.enums.fund.ProductTypeEnum;
刘基明's avatar
刘基明 committed
7
import com.tanpu.common.util.JsonUtil;
刘基明's avatar
刘基明 committed
8 9 10
import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
刘基明's avatar
刘基明 committed
11 12 13
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
刘基明's avatar
刘基明 committed
14
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
刘基明's avatar
刘基明 committed
15 16 17
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
刘基明's avatar
刘基明 committed
18 19
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
20
import com.tanpu.community.dao.entity.community.TopicEntity;
刘基明's avatar
刘基明 committed
21
import com.tanpu.community.feign.course.FeignClientForCourse;
刘基明's avatar
刘基明 committed
22 23 24 25 26 27 28 29 30
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.product.FeignForFund;
import com.tanpu.community.feign.product.FeignForPublicFund;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
31
import org.springframework.util.StringUtils;
刘基明's avatar
刘基明 committed
32 33

import javax.annotation.Resource;
刘基明's avatar
刘基明 committed
34
import java.util.*;
刘基明's avatar
刘基明 committed
35 36
import java.util.stream.Collectors;

刘基明's avatar
刘基明 committed
37 38 39
/**
 * 批量调用Feign查询接口
 */
刘基明's avatar
刘基明 committed
40
@Service
刘基明's avatar
刘基明 committed
41
public class BatchFeignCallService {
刘基明's avatar
刘基明 committed
42 43 44 45 46 47 48 49 50 51 52


    @Resource
    private FeignClientForTanpuroom feignClientForTanpuroom;

    @Resource
    private FeignClientForZhibo feignClientForZhibo;

    @Resource
    private FeignClientForProducts feignForProduct;

刘基明's avatar
刘基明 committed
53 54 55
    @Resource
    private FeignClientForCourse feignForCourse;

刘基明's avatar
刘基明 committed
56 57 58 59 60 61 62 63 64 65

    @Resource
    private FeignForFund feignForFund;

    @Resource
    private FeignForPublicFund feignForPublicFund;

    @Resource
    private FeignClientForFatools feignClientForFatools;

66
    @Resource
刘基明's avatar
刘基明 committed
67 68
    private OSSFileService ossFileService;

69 70 71
    @Resource
    private TopicService topicService;

刘基明's avatar
刘基明 committed
72 73 74
    @Resource
    private UserInfoService userInfoService;

刘基明's avatar
刘基明 committed
75

刘基明's avatar
刘基明 committed
76
    public void getAttachDetail(ThemeQo themeQo) {
刘基明's avatar
刘基明 committed
77 78
        ArrayList<ThemeQo> themeQos = new ArrayList<>();
        themeQos.add(themeQo);
刘基明's avatar
刘基明 committed
79
        getAttachDetailByBatch(themeQos);
刘基明's avatar
刘基明 committed
80 81 82
    }


刘基明's avatar
刘基明 committed
83
    public void getAttachDetailByBatch(List<ThemeQo> themeQos) {
刘基明's avatar
刘基明 committed
84 85 86 87
        // 短视频信息
        Map<String, ShortVideoBaseInfoResp> shortVideoMap = Maps.newHashMap();
        // 课程信息
        Map<String, ShortVideoBaseInfoResp> curriculumMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
88 89
        // 新课程信息
        Map<String, CourseSimpleResp> courseMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
90 91 92 93 94
        // 直播信息
        Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
        // 设置产品信息
        Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
        // 图片信息
刘基明's avatar
刘基明 committed
95
        Map<String, FileRecordEntity> imgMap = Maps.newHashMap();
96 97
        // 话题标题
        Map<String, String> topicMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
98
        // 图片信息
刘基明's avatar
刘基明 committed
99
        Map<String, UserInfoNew> userMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
100
        // 批量查询资源信息
刘基明's avatar
刘基明 committed
101
        this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
刘基明's avatar
刘基明 committed
102
        //逐个装入
刘基明's avatar
刘基明 committed
103
        setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, userMap, topicMap);
刘基明's avatar
刘基明 committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117

    }


    /**
     * 获取资源信息
     *
     * @param shortVideoMap
     * @param curriculumMap
     * @param zhiboMap
     * @param fundMap
     */
    private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
                            Map<String, ShortVideoBaseInfoResp> curriculumMap,
刘基明's avatar
刘基明 committed
118
                            Map<String, CourseSimpleResp> courseMap,
刘基明's avatar
刘基明 committed
119 120
                            Map<String, ZhiboListResp> zhiboMap,
                            Map<String, FundInfoBaseResp> fundMap,
刘基明's avatar
刘基明 committed
121
                            Map<String, FileRecordEntity> imgMap,
122
                            Map<String, String> topicMap,
刘基明's avatar
刘基明 committed
123
                            Map<String, UserInfoNew> userMap,
刘基明's avatar
刘基明 committed
124
                            List<ThemeQo> themeQos
125
    ) {
刘基明's avatar
刘基明 committed
126
        // 白名单基金id
刘基明's avatar
刘基明 committed
127
        HashSet<String> tanpuFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
128
        // 私募基金id
刘基明's avatar
刘基明 committed
129
        HashSet<String> fundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
130
        // 理财师导入
刘基明's avatar
刘基明 committed
131
        HashSet<String> ifaFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
132
        // 公募基金id
刘基明's avatar
刘基明 committed
133
        HashSet<String> publicFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
134
        // 无净值产品id
刘基明's avatar
刘基明 committed
135
        HashSet<String> notNetFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
136
        // 短视频id
刘基明's avatar
刘基明 committed
137
        HashSet<String> shortVideoIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
138
        // 直播id
刘基明's avatar
刘基明 committed
139
        HashSet<String> zhiboIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
140
        // 课程id
刘基明's avatar
刘基明 committed
141
        HashSet<String> curriculumIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
142
        // 新课程id
刘基明's avatar
刘基明 committed
143
        HashSet<String> courseIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
144
        // 图片id
刘基明's avatar
刘基明 committed
145
        HashSet<String> imageIds = Sets.newHashSet();
146
        // 话题id
刘基明's avatar
刘基明 committed
147
        HashSet<String> topicIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
148
        // 用户id
刘基明's avatar
刘基明 committed
149
        HashSet<String> userIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
150 151
        // 获取关联资源id
        if (themeQos != null) {
刘基明's avatar
刘基明 committed
152
            themeQos.forEach(o -> {
刘基明's avatar
刘基明 committed
153
                userIds.add(o.getAuthorId());
154 155 156 157
                if (o.getTopicId() != null) {
                    topicIds.add(o.getTopicId());
                }
            });
刘基明's avatar
刘基明 committed
158 159

            themeQos.forEach(o -> o.getContent().forEach(c -> {
刘基明's avatar
刘基明 committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
                        if (c.getType().equals(RelTypeEnum.LIVE.type)) {
                            zhiboIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
                            shortVideoIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.FUND.type)) {
                            if (c.getProductType() == ProductTypeEnum.PUBLIC.type) {
                                publicFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.PRIVATE.type) {
                                fundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.TAMP.type) {
                                tanpuFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type) {
                                ifaFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type) {
                                notNetFundIds.add(c.getValue());
                            }

                        } else if (c.getType().equals(RelTypeEnum.VIDEO.type) || c.getType().equals(RelTypeEnum.AUDIO.type)) {
                            curriculumIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
                            imageIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
                                c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
                            courseIds.add(c.getValue());
刘基明's avatar
刘基明 committed
184
                        }
刘基明's avatar
刘基明 committed
185
                    })
刘基明's avatar
刘基明 committed
186
            );
刘基明's avatar
刘基明 committed
187

刘基明's avatar
刘基明 committed
188 189 190
        }
        if (!CollectionUtils.isEmpty(shortVideoIds)) {
            // 短视频列表
刘基明's avatar
刘基明 committed
191 192
            CommonResp<List<ShortVideoBaseInfoResp>> commonResp =
                    feignClientForTanpuroom.getShortVideoBaseInfo(setToList(shortVideoIds));
刘基明's avatar
刘基明 committed
193
            if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
刘基明's avatar
刘基明 committed
194 195
                shortVideoMap.putAll(commonResp.getData().stream()
                        .collect(Collectors.toMap(ShortVideoBaseInfoResp::getSourceId, item -> item)));
刘基明's avatar
刘基明 committed
196 197 198 199
            }
        }
        if (!CollectionUtils.isEmpty(curriculumIds)) {
            // 课程列表
刘基明's avatar
刘基明 committed
200 201
            List<ShortVideoBaseInfoResp> commonResp =
                    feignClientForFatools.getCurriculumByColumnRelId(setToList(curriculumIds));
刘基明's avatar
刘基明 committed
202
            if (commonResp != null && !CollectionUtils.isEmpty(commonResp)) {
刘基明's avatar
刘基明 committed
203 204
                curriculumMap.putAll(commonResp.stream()
                        .collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item)));
刘基明's avatar
刘基明 committed
205 206
            }
        }
刘基明's avatar
刘基明 committed
207 208
        if (!CollectionUtils.isEmpty(courseIds)) {
            // 新版课程列表
刘基明's avatar
刘基明 committed
209 210
            CommonResp<List<CourseSimpleResp>> commonResp =
                    feignForCourse.getCourseSimpleList(setToList(courseIds));
刘基明's avatar
刘基明 committed
211 212 213 214
            if (commonResp.isSuccess() & !CollectionUtils.isEmpty(commonResp.getData())) {
                courseMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(CourseSimpleResp::getCourseId, item -> item)));
            }
        }
刘基明's avatar
刘基明 committed
215 216
        if (!CollectionUtils.isEmpty(zhiboIds)) {
            // 直播列表
刘基明's avatar
刘基明 committed
217 218
            CommonResp<List<ZhiboListResp>> commonResp =
                    feignClientForZhibo.simpleList(setToList(zhiboIds));
刘基明's avatar
刘基明 committed
219 220 221 222 223
            if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
                zhiboMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item)));
            }
        }
        if (!CollectionUtils.isEmpty(imageIds)) {
刘基明's avatar
刘基明 committed
224
            // 查询图片
刘基明's avatar
刘基明 committed
225 226
            List<FileRecordEntity> fileRecordEntities =
                    ossFileService.queryByIds(setToList(imageIds));
刘基明's avatar
刘基明 committed
227 228
            if (!CollectionUtils.isEmpty(fileRecordEntities)) {
                imgMap.putAll(fileRecordEntities.stream().collect(Collectors
刘基明's avatar
刘基明 committed
229
                        .toMap(FileRecordEntity::getFileId, o -> o)));
刘基明's avatar
刘基明 committed
230
            }
刘基明's avatar
刘基明 committed
231

刘基明's avatar
刘基明 committed
232
        }
233 234
        if (!CollectionUtils.isEmpty(topicIds)) {
            // 查询话题标题
刘基明's avatar
刘基明 committed
235 236
            List<TopicEntity> topicEntities =
                    topicService.queryByIds(setToList(topicIds));
237 238 239 240 241
            if (!CollectionUtils.isEmpty(topicEntities)) {
                topicMap.putAll(topicEntities.stream().collect(Collectors
                        .toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle)));
            }
        }
刘基明's avatar
刘基明 committed
242 243
        if (!CollectionUtils.isEmpty(userIds)) {
            // 查询用户信息
刘基明's avatar
刘基明 committed
244
            List<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUserListNew(setToList(userIds));
刘基明's avatar
刘基明 committed
245
            if (!CollectionUtils.isEmpty(userIds)) {
刘基明's avatar
刘基明 committed
246 247
                userMap.putAll(queryUsersListNew.stream().collect(Collectors
                        .toMap(UserInfoNew::getUserId, o -> o)));
刘基明's avatar
刘基明 committed
248
            }
刘基明's avatar
刘基明 committed
249

刘基明's avatar
刘基明 committed
250
        }
刘基明's avatar
刘基明 committed
251 252 253 254 255 256 257 258 259 260 261
        this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
    }

    /**
     * 设置产品信息
     *
     * @param tanpuFundIds
     * @param fundIds
     * @param publicFundIds
     * @param fundMap
     */
刘基明's avatar
刘基明 committed
262 263 264 265 266
    private void getFundInfo(Set<String> tanpuFundIds,
                             Set<String> fundIds,
                             Set<String> publicFundIds,
                             Set<String> ifaFundIds,
                             Set<String> notNetFundIds,
刘基明's avatar
刘基明 committed
267 268 269 270 271 272 273 274 275 276 277
                             Map<String, FundInfoBaseResp> fundMap) {
        Map<String, FundInfoBaseResp> tampFundMap = null;
        Map<String, FundInfoBaseResp> privateFundMap = null;
        Map<String, FundInfoBaseResp> publicFundMap = null;
        Map<String, FundInfoBaseResp> ifaFundMap = null;
        Map<String, FundInfoBaseResp> notNetFundMap = null;
        if (!CollectionUtils.isEmpty(tanpuFundIds)) {
//            ProductListReq productListReq = ProductListReq.builder()
//                    .fundIds(Lists.newArrayList(tanpuFundIds))
//                    .build();
            // 探普产品
刘基明's avatar
刘基明 committed
278 279
            CommonResp<List<ProductInfoVO>> commonResp =
                    feignForProduct.getProductInfoByIds(setToList(tanpuFundIds));
刘基明's avatar
刘基明 committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
            if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = commonResp.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                tampFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }

            if (tampFundMap != null && tampFundMap.size() > 0) {
                fundMap.putAll(tampFundMap);
            }
        }
        // 私募产品
        if (!CollectionUtils.isEmpty(fundIds)) {
            // 私募产品
刘基明's avatar
刘基明 committed
296 297
            CommonResp<List<ProductInfoVO>> fundResult =
                    feignForFund.getProductList(setToList(fundIds));
刘基明's avatar
刘基明 committed
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
            if (fundResult.isSuccess() && !CollectionUtils.isEmpty(fundResult.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = fundResult.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                privateFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }

            if (privateFundMap != null && privateFundMap.size() > 0) {
                fundMap.putAll(privateFundMap);
            }
        }

        // 理财师导入产品
        if (!CollectionUtils.isEmpty(ifaFundIds)) {
刘基明's avatar
刘基明 committed
314 315
            CommonResp<List<ProductInfoVO>> ifaFundResult =
                    feignForFund.getPrivateFundList(setToList(ifaFundIds));
刘基明's avatar
刘基明 committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
            if (ifaFundResult.isSuccess() && !CollectionUtils.isEmpty(ifaFundResult.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = ifaFundResult.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                ifaFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }

            if (ifaFundMap != null && ifaFundMap.size() > 0) {
                fundMap.putAll(ifaFundMap);
            }
        }

        if (!CollectionUtils.isEmpty(publicFundIds)) {
            // 公募产品
刘基明's avatar
刘基明 committed
332 333
            CommonResp<List<ProductInfoVO>> publicFundResult =
                    feignForPublicFund.getProductList(setToList(publicFundIds));
刘基明's avatar
刘基明 committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
            if (publicFundResult.isSuccess() && !CollectionUtils.isEmpty(publicFundResult.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = publicFundResult.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                publicFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }
            if (publicFundMap != null && publicFundMap.size() > 0) {
                fundMap.putAll(publicFundMap);
            }
        }

        if (!CollectionUtils.isEmpty(notNetFundIds)) {
            // 无净值产品
刘基明's avatar
刘基明 committed
349 350
            CommonResp<List<ProductInfoVO>> notNetInfoResult =
                    feignForFund.getProductListNotNetInfo(setToList(notNetFundIds));
刘基明's avatar
刘基明 committed
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
            if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                notNetFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }
            if (notNetFundMap != null && notNetFundMap.size() > 0) {
                fundMap.putAll(notNetFundMap);
            }
        }
    }

    /**
     * 设置资源信息
     */
    private void setResInfo(List<ThemeQo> themeQos,
                            Map<String, ShortVideoBaseInfoResp> shortVideoMap,
                            Map<String, ShortVideoBaseInfoResp> curriculumMap,
刘基明's avatar
刘基明 committed
371
                            Map<String, CourseSimpleResp> courseMap,
刘基明's avatar
刘基明 committed
372 373
                            Map<String, ZhiboListResp> zhiboMap,
                            Map<String, FundInfoBaseResp> fundMap,
刘基明's avatar
刘基明 committed
374
                            Map<String, FileRecordEntity> imgUrlMap,
刘基明's avatar
刘基明 committed
375
                            Map<String, UserInfoNew> userMap,
刘基明's avatar
刘基明 committed
376
                            Map<String, String> topicMap) {
刘基明's avatar
刘基明 committed
377
        for (ThemeQo themeQo : themeQos) {
刘基明's avatar
刘基明 committed
378
            if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
刘基明's avatar
刘基明 committed
379
                //话题标题
380 381
                themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
            }
刘基明's avatar
刘基明 committed
382
            if (!StringUtils.isEmpty(themeQo.getAuthorId()) && userMap.containsKey(themeQo.getAuthorId())) {
刘基明's avatar
刘基明 committed
383
                //用户信息
刘基明's avatar
刘基明 committed
384
                UserInfoNew userInfo = userMap.get(themeQo.getAuthorId());
刘基明's avatar
刘基明 committed
385
                //昵称头像简介
刘基明's avatar
刘基明 committed
386 387 388
                themeQo.setNickName(userInfo.getNickName());
                themeQo.setUserImg(userInfo.getHeadImageUrl());
                themeQo.setUserIntroduction(userInfo.getIntroduction());
刘基明's avatar
刘基明 committed
389
                //认证标签相关
刘基明's avatar
刘基明 committed
390 391 392 393 394
                themeQo.setUserType(userInfo.getUserType());
                themeQo.setLevelGrade(userInfo.getLevelGrade());
                themeQo.setUserInvestorType(userInfo.getUserInvestorType());
                themeQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
                themeQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
刘基明's avatar
刘基明 committed
395
            }
刘基明's avatar
刘基明 committed
396
            if (themeQo.getContent() == null) {
刘基明's avatar
刘基明 committed
397 398
                continue;
            }
刘基明's avatar
刘基明 committed
399 400 401
            for (ThemeContentQo themeContent : themeQo.getContent()) {
                if (themeContent.getType().equals(RelTypeEnum.LIVE.type)) {
                    if (zhiboMap.containsKey(themeContent.getValue())) {
刘基明's avatar
刘基明 committed
402
                        ZhiboListResp zhibo = zhiboMap.get(themeContent.getValue());
刘基明's avatar
刘基明 committed
403 404 405 406 407 408 409 410 411 412 413 414 415
                        themeContent.setDetail(AttachmentDetailVo.builder().zhibo(zhibo).build());
                    }
                } else if (themeContent.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
                    if (shortVideoMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .shortVideo(shortVideoMap.get(themeContent.getValue())).build());
                    }
                } else if (themeContent.getType().equals(RelTypeEnum.VIDEO.type) ||
                        themeContent.getType().equals(RelTypeEnum.AUDIO.type)) {
                    if (curriculumMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .curriculum(curriculumMap.get(themeContent.getValue())).build());
                    }
刘基明's avatar
刘基明 committed
416 417 418 419 420 421
                } else if (themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type) ||
                        themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type)) {
                    if (courseMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .course(courseMap.get(themeContent.getValue())).build());
                    }
刘基明's avatar
刘基明 committed
422 423 424 425 426 427 428 429 430 431
                } else if (themeContent.getType().equals(RelTypeEnum.FUND.type)) {
                    if (fundMap.containsKey(themeContent.getValue())) {
                        FundInfoBaseResp product = fundMap.get(themeContent.getValue());
                        // 推荐语
                        product.setRemark(themeContent.getRemark());
                        // 产品类型
                        product.setProductType(themeContent.getProductType());
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .product(product).build());
                    }
刘基明's avatar
刘基明 committed
432
                } else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
刘基明's avatar
刘基明 committed
433
                    //单图封装到imglist列表中
434
                    if (imgUrlMap.containsKey(themeContent.getValue())) {
刘基明's avatar
刘基明 committed
435 436
                        FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue());
                        String extInfo = imgEntity.getExtInfo();
刘基明's avatar
刘基明 committed
437
                        if (!StringUtils.isEmpty(extInfo)) {
刘基明's avatar
刘基明 committed
438 439 440
                            Map<String, Object> extMap = JsonUtil.toMap(extInfo);
                            ImagesDTO imagesDTO = ImagesDTO.builder().imgHeight((Integer) extMap.get("height"))
                                    .imgWidth((Integer) extMap.get("width"))
刘基明's avatar
刘基明 committed
441 442
                                    .remark(imgEntity.getUrl())
                                    .relId(imgEntity.getFileId())
刘基明's avatar
刘基明 committed
443 444 445
                                    .build();
                            themeContent.setImgList(Collections.singletonList(imagesDTO));
                        }
446
                    }
刘基明's avatar
刘基明 committed
447
                } else if (themeContent.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
刘基明's avatar
刘基明 committed
448 449 450 451 452 453 454 455 456 457 458 459 460 461
                    //多图写入图片宽高
                    List<ImagesDTO> imgList = themeContent.getImgList();
                    for (ImagesDTO imagesDTO : imgList) {
                        if (imgUrlMap.containsKey(imagesDTO.getRelId())) {
                            FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue());
                            String extInfo = imgEntity.getExtInfo();
                            if (!StringUtils.isEmpty(extInfo)) {
                                Map<String, Object> extMap = JsonUtil.toMap(extInfo);
                                imagesDTO.setImgHeight((Integer) extMap.get("height"));
                                imagesDTO.setImgWidth((Integer) extMap.get("width"));
                            }
                        }
                    }

刘基明's avatar
刘基明 committed
462 463
                }
            }
刘基明's avatar
刘基明 committed
464 465 466 467 468 469 470 471 472 473
//            String formerThemeId = themeQo.getFormerThemeId();
//            if (!StringUtils.isEmpty(formerThemeId)) {
//                FormerThemeQo formerTheme = themeQo.getFormerTheme();
//
//                //单个查询详情
////            productService.getAttachDetail(formerTheme);
//
//                FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(formerTheme);
//                themeQo.setFormerTheme(f);
//            }
刘基明's avatar
刘基明 committed
474
        }
刘基明's avatar
刘基明 committed
475

刘基明's avatar
刘基明 committed
476 477
    }

刘基明's avatar
刘基明 committed
478 479 480 481 482 483
    private List<String> setToList(Set<String> set) {
        List<String> l = new ArrayList<>();
        l.addAll(set);
        return l;
    }

刘基明's avatar
刘基明 committed
484 485 486 487 488
    //组装被转发主题
    private void buildFormerTheme(ThemeQo themeQo) {

    }

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