Commit 4d4a16b8 authored by 刘基明's avatar 刘基明

删除直播转播校验

parent c438acd8
package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 话题列表页
*/
@Data
@ApiModel("话题列表对象")
public class TopicTitileQo {
@ApiModelProperty("话题ID")
private String topicId;
@ApiModelProperty("话题名称")
private String topicTitle;
@ApiModelProperty("讨论数")
private String discussionCount;
@ApiModelProperty("浏览量")
private String viewCount;
}
package com.tanpu.community.api.beans.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@ApiModel(value="TopicDTO对象", description="话题")
public class TopicDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "话题名称")
private String topicTitle;
@ApiModelProperty(value = "是否置顶")
private Integer isTop;
@ApiModelProperty(value = "是否隐藏")
private Integer isConceal;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer deleteTag;
@ApiModelProperty(value = "帖子量")
private Integer themeCount;
@ApiModelProperty(value = "浏览量")
private Integer viewCount;
@ApiModelProperty(value = "点赞量")
private Integer likeCount;
@ApiModelProperty(value = "总用户数")
private Integer UserCount;
@ApiModelProperty
@Override
public String toString() {
return "TopicEntity{" +
"id=" + id +
", topicTitle=" + topicTitle +
", isTop=" + isTop +
", isConceal=" + isConceal +
", createTime=" + createTime +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
}
......@@ -102,6 +102,7 @@ public class HomePageManager {
} else {
userInfoNew.getUserInfoNewChief().setClientId(null);
}
}
} else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()) {
// 机构账号
......
......@@ -16,6 +16,7 @@ import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.*;
import com.tanpu.community.service.base.ESService;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.RankUtils;
import com.tanpu.community.util.TencentcloudUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -100,9 +101,6 @@ public class ThemeManager {
* 发表主题(可修改)
*/
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
//直播类型做转播检查
List<ThemeContentReq> contents = req.getContent();
liveRelayCheck(userId, contents);
//保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -167,9 +165,9 @@ public class ThemeManager {
List<ThemeEntity> themeEntities = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100,userId);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, null, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, recommendThemeIds);
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询
List<String> fansList = followRelService.queryFansByFollowerId(userId);
......@@ -178,8 +176,9 @@ public class ThemeManager {
} else if (ThemeListTypeEnum.TOPIC_HOT.getCode().equals(req.getType())) {
//根据话题查询热门
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
List<ThemeAnalysDO> rankThemeListByTopic = rankService.getRankThemeList(req.getTopicId());
themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize());
List<String> rankThemeIds = rankService.getRankThemeListByTopic(req.getTopicId());
themeEntities = themeService.queryByThemeIdsExcludeUser(rankThemeIds, null, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities,rankThemeIds);
} else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) {
//根据话题查询最新
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
......
......@@ -101,8 +101,11 @@ public class RankService {
* @param newCount
* @return
*/
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount).map(ThemeAnalysDO::getThemeId).collect(Collectors.toSet());
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount,String userId) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount)
.filter(o->!userId.equals(o.getAuthorId()))
.map(ThemeAnalysDO::getThemeId)
.collect(Collectors.toSet());
Set<String> newThemeIds = themeService.selectExcludeUser(null, null, newCount)
.stream().map(ThemeEntity::getThemeId).collect(Collectors.toSet());
hotThemeIds.addAll(newThemeIds);
......@@ -124,7 +127,7 @@ public class RankService {
}
public List<ThemeAnalysDO> getRankThemeList() {
public List<ThemeAnalysDO> getRankThemeListByTopic() {
if (this.rankThemeList.size()==0){
rankThemes();
}
......@@ -145,10 +148,12 @@ public class RankService {
return rankTopicListTop4;
}
public List<ThemeAnalysDO> getRankThemeList(String topicId) {
public List<String> getRankThemeListByTopic(String topicId) {
if (this.rankThemeList.size()==0){
this.rankThemes();
}
return rankThemeList.stream().filter(o->topicId.equals(o.getTopicId())).collect(Collectors.toList());
return rankThemeList.stream().filter(o->topicId.equals(o.getTopicId()))
.map(ThemeAnalysDO::getThemeId)
.collect(Collectors.toList());
}
}
......@@ -2,19 +2,17 @@ package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.TopicDTO;
import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
......@@ -28,9 +26,6 @@ import java.util.stream.Collectors;
public class ConvertUtil {
/**
* THEME
*/
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
if (themeEntity == null) {
return null;
......@@ -92,15 +87,6 @@ public class ConvertUtil {
}
/**
* TOPIC
*/
public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) {
TopicDTO topicDTO = new TopicDTO();
BeanUtils.copyProperties(topicEntity, topicDTO);
return topicDTO;
}
public static TopicRankQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicRankQo topicRankQo = new TopicRankQo();
BeanUtils.copyProperties(topicEntity, topicRankQo);
......@@ -118,11 +104,6 @@ public class ConvertUtil {
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
}
public static TopicTitileQo topicToBriefInfoDTO(TopicEntity topicEntity) {
TopicTitileQo topicTitileQo = new TopicTitileQo();
BeanUtils.copyProperties(topicEntity, topicTitileQo);
return topicTitileQo;
}
public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo();
......@@ -135,40 +116,6 @@ public class ConvertUtil {
return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList());
}
public static CommentLv2Qo commentLv2Entity2Qo(CommentEntity entity) {
CommentLv2Qo qo = new CommentLv2Qo();
BeanUtils.copyProperties(entity, qo);
return qo;
}
public static List<CommentLv2Qo> commentLv2Entity2Qos(List<CommentEntity> entities) {
return entities.stream().map(ConvertUtil::commentLv2Entity2Qo).collect(Collectors.toList());
}
public static List<TopicDTO> topicEntitiesToDTOs(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicEntityToDTO).collect(Collectors.toList());
}
public static List<TopicTitileQo> topicEntitiesToBriefDTOs(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicToBriefInfoDTO).collect(Collectors.toList());
}
public static DeleteTagEnum deleteTagShift(DeleteTagEnum deleteTagEnum) {
if (deleteTagEnum.getCode().equals(DeleteTagEnum.NOT_DELETED.getCode())) {
return DeleteTagEnum.DELETED;
} else {
return DeleteTagEnum.NOT_DELETED;
}
}
public static Integer deleteTagShift(Integer deleteTag) {
if (deleteTag.equals(DeleteTagEnum.NOT_DELETED.getCode())) {
return DeleteTagEnum.DELETED.getCode();
} else {
return DeleteTagEnum.NOT_DELETED.getCode();
}
}
/**
* VISIT_SUMMARY
......@@ -235,16 +182,6 @@ public class ConvertUtil {
return list;
}
public static FollowQo userInfoEntity2FollowQo(UserInfoEntity entity) {
if (entity == null) {
return null;
}
return FollowQo.builder().userId(entity.getId())
.nickName(entity.getUiUsernameMp())
.headImg(entity.getUiHeadimgMp())
.introduction(entity.getUiIntroductionMp())
.build();
}
public static FollowQo userInfoNew2FollowQo(UserInfoNew entity) {
if (entity == null) {
......
package com.tanpu.community.util;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
public class RankUtils {
public static List<ThemeQo> rankByIds(List<ThemeQo> list, List<String> ids){
public static List<ThemeEntity> sortThemeEntityByIds(List<ThemeEntity> list, List<String> ids){
int count=0;
HashMap<String, Integer> indexMap = new HashMap<>();
for (String id : ids) {
indexMap.put(id,count++);
}
return list;
List<ThemeEntity> collect = list.stream().filter(o -> indexMap.containsKey(o.getThemeId()))
.sorted(Comparator.comparingInt(o -> indexMap.get(o.getThemeId())))
.collect(Collectors.toList());
return collect;
}
}
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