Commit e1d54d59 authored by 刘基明's avatar 刘基明

主题返回添加话题名称

parent ef955a9a
...@@ -18,6 +18,7 @@ public class ThemeQo { ...@@ -18,6 +18,7 @@ public class ThemeQo {
@ApiModelProperty(value = "主题ID") @ApiModelProperty(value = "主题ID")
private String themeId; private String themeId;
@ApiModelProperty(value = "被转发的主题") @ApiModelProperty(value = "被转发的主题")
private String formerThemeId; private String formerThemeId;
...@@ -36,6 +37,9 @@ public class ThemeQo { ...@@ -36,6 +37,9 @@ public class ThemeQo {
@ApiModelProperty(value = "所属的话题") @ApiModelProperty(value = "所属的话题")
private String topicId; private String topicId;
@ApiModelProperty(value = "话题名称")
private String topicTitle;
@ApiModelProperty(value = "昵称") @ApiModelProperty(value = "昵称")
private String nickName; private String nickName;
......
...@@ -109,6 +109,7 @@ public class ThemeManager { ...@@ -109,6 +109,7 @@ public class ThemeManager {
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空"); if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize()); themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize());
} }
//组装详情
return convertEntityToQo(themeEntities, userId); return convertEntityToQo(themeEntities, userId);
} }
...@@ -207,7 +208,9 @@ public class ThemeManager { ...@@ -207,7 +208,9 @@ public class ThemeManager {
//主题Entity转QO //主题Entity转QO
private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) { private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) {
//Entity转Qo
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities); List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
//批量查询附件detail
productService.transferAttachment(themeQos,userId); productService.transferAttachment(themeQos,userId);
for (ThemeQo themeQO : themeQos) { for (ThemeQo themeQO : themeQos) {
buildThemeQoExtraInfo(userId, themeQO); buildThemeQoExtraInfo(userId, themeQO);
......
...@@ -14,6 +14,7 @@ import com.tanpu.community.dao.entity.community.TopicEntity; ...@@ -14,6 +14,7 @@ import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.service.*; import com.tanpu.community.service.*;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.PageUtils; import com.tanpu.community.util.PageUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -77,6 +78,11 @@ public class TopicManager { ...@@ -77,6 +78,11 @@ public class TopicManager {
TopicDetailQo topicDetailQo = new TopicDetailQo(); TopicDetailQo topicDetailQo = new TopicDetailQo();
BeanUtils.copyProperties(topicEntity,topicDetailQo); BeanUtils.copyProperties(topicEntity,topicDetailQo);
List<String> themeIds = themeService.queryThemeIdsByTopic(topicId); List<String> themeIds = themeService.queryThemeIdsByTopic(topicId);
if (CollectionUtils.isEmpty(themeIds)){
topicDetailQo.setViewCount(1000);
topicDetailQo.setDisscussCount(0);
return topicDetailQo;
}
//TODO 浏览量 //TODO 浏览量
topicDetailQo.setViewCount(1000); topicDetailQo.setViewCount(1000);
......
...@@ -13,6 +13,7 @@ import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp; ...@@ -13,6 +13,7 @@ import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.ZhiboListResp; import com.tanpu.community.api.beans.vo.feign.ZhiboListResp;
import com.tanpu.community.api.enums.RelTypeEnum; import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity; import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools; import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts; import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.product.FeignForFund; import com.tanpu.community.feign.product.FeignForFund;
...@@ -20,9 +21,9 @@ import com.tanpu.community.feign.product.FeignForPublicFund; ...@@ -20,9 +21,9 @@ import com.tanpu.community.feign.product.FeignForPublicFund;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom; import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo; import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -52,9 +53,12 @@ public class ProductService { ...@@ -52,9 +53,12 @@ public class ProductService {
@Resource @Resource
private FeignClientForFatools feignClientForFatools; private FeignClientForFatools feignClientForFatools;
@Autowired @Resource
private OSSFileService ossFileService; private OSSFileService ossFileService;
@Resource
private TopicService topicService;
public void transferAttachment(List<ThemeQo> themeQos, String userId) { public void transferAttachment(List<ThemeQo> themeQos, String userId) {
// 短视频信息 // 短视频信息
...@@ -67,10 +71,12 @@ public class ProductService { ...@@ -67,10 +71,12 @@ public class ProductService {
Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap(); Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
// 图片信息 // 图片信息
Map<String, String> imgMap = Maps.newHashMap(); Map<String, String> imgMap = Maps.newHashMap();
// 话题标题
Map<String, String> topicMap = Maps.newHashMap();
// 批量查询资源信息 // 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, themeQos); this.getResInfo(shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, topicMap, themeQos);
//逐个装入 //逐个装入
setResInfo(themeQos,shortVideoMap,curriculumMap,zhiboMap,fundMap,imgMap); setResInfo(themeQos, shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, topicMap);
} }
...@@ -88,8 +94,9 @@ public class ProductService { ...@@ -88,8 +94,9 @@ public class ProductService {
Map<String, ZhiboListResp> zhiboMap, Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap, Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgMap, Map<String, String> imgMap,
Map<String, String> topicMap,
List<ThemeQo> themeQos List<ThemeQo> themeQos
) { ) {
// 白名单基金id // 白名单基金id
List<String> tanpuFundIds = Lists.newArrayList(); List<String> tanpuFundIds = Lists.newArrayList();
// 私募基金id // 私募基金id
...@@ -108,8 +115,11 @@ public class ProductService { ...@@ -108,8 +115,11 @@ public class ProductService {
List<String> curriculumIds = Lists.newArrayList(); List<String> curriculumIds = Lists.newArrayList();
// 图片id // 图片id
List<String> imageIds = Lists.newArrayList(); List<String> imageIds = Lists.newArrayList();
// 话题id
List<String> topicIds = Lists.newArrayList();
// 获取关联资源id // 获取关联资源id
if (themeQos != null) { if (themeQos != null) {
themeQos.stream().forEach(o -> o.getContent().stream().forEach(c -> { themeQos.stream().forEach(o -> o.getContent().stream().forEach(c -> {
if (c.getType().equals(RelTypeEnum.LIVE.type)) { if (c.getType().equals(RelTypeEnum.LIVE.type)) {
zhiboIds.add(c.getValue()); zhiboIds.add(c.getValue());
...@@ -133,10 +143,12 @@ public class ProductService { ...@@ -133,10 +143,12 @@ public class ProductService {
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) { } else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue()); imageIds.add(c.getValue());
} }
})); }));
themeQos.stream().forEach(o -> {
if (o.getTopicId() != null) {
topicIds.add(o.getTopicId());
}
});
} }
if (!CollectionUtils.isEmpty(shortVideoIds)) { if (!CollectionUtils.isEmpty(shortVideoIds)) {
// 短视频列表 // 短视频列表
...@@ -160,13 +172,21 @@ public class ProductService { ...@@ -160,13 +172,21 @@ public class ProductService {
} }
} }
if (!CollectionUtils.isEmpty(imageIds)) { if (!CollectionUtils.isEmpty(imageIds)) {
// 直播列表 // 查询文件
List<FileRecordEntity> fileRecordEntities = ossFileService.queryByIds(imageIds); List<FileRecordEntity> fileRecordEntities = ossFileService.queryByIds(imageIds);
if (!CollectionUtils.isEmpty(fileRecordEntities)) { if (!CollectionUtils.isEmpty(fileRecordEntities)) {
imgMap.putAll(fileRecordEntities.stream().collect(Collectors imgMap.putAll(fileRecordEntities.stream().collect(Collectors
.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl))); .toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl)));
} }
} }
if (!CollectionUtils.isEmpty(topicIds)) {
// 查询话题标题
List<TopicEntity> topicEntities = topicService.queryByIds(topicIds);
if (!CollectionUtils.isEmpty(topicEntities)) {
topicMap.putAll(topicEntities.stream().collect(Collectors
.toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle)));
}
}
this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap); this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
} }
...@@ -284,8 +304,12 @@ public class ProductService { ...@@ -284,8 +304,12 @@ public class ProductService {
Map<String, ShortVideoBaseInfoResp> curriculumMap, Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, ZhiboListResp> zhiboMap, Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap, Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgUrlMap) { Map<String, String> imgUrlMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) { for (ThemeQo themeQo : themeQos) {
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())){
themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
}
for (ThemeContentQo themeContent : themeQo.getContent()) { for (ThemeContentQo themeContent : themeQo.getContent()) {
if (themeContent.getType().equals(RelTypeEnum.LIVE.type)) { if (themeContent.getType().equals(RelTypeEnum.LIVE.type)) {
if (zhiboMap.containsKey(themeContent.getValue())) { if (zhiboMap.containsKey(themeContent.getValue())) {
...@@ -313,6 +337,10 @@ public class ProductService { ...@@ -313,6 +337,10 @@ public class ProductService {
themeContent.setDetail(AttachmentDetailVo.builder() themeContent.setDetail(AttachmentDetailVo.builder()
.product(product).build()); .product(product).build());
} }
}else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
if (imgUrlMap.containsKey(themeContent.getValue())) {
themeContent.setValue(imgUrlMap.get(themeContent.getValue()));
}
} }
} }
} }
......
...@@ -81,6 +81,10 @@ public class TopicService { ...@@ -81,6 +81,10 @@ public class TopicService {
return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId,topicId)); return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId,topicId));
} }
public List<TopicEntity> queryByIds(List<String> topicIds) {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId,topicIds));
}
public void modifyViewCount(String topicId, long Count) { public void modifyViewCount(String topicId, long Count) {
TopicEntity topicEntity = topicMapper.selectById(topicId); TopicEntity topicEntity = topicMapper.selectById(topicId);
Long oldCount = topicEntity.getviewCntAdjust(); Long oldCount = topicEntity.getviewCntAdjust();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment