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

删除无用方法

parent 8e4d5c03
...@@ -41,7 +41,7 @@ public class CommentManager { ...@@ -41,7 +41,7 @@ public class CommentManager {
@Resource @Resource
private ReportLogService reportLogService; private ReportLogService reportLogService;
// 评论(对主题) // 发表评论(对主题)
public void comment(CreateCommentReq req, String userId) { public void comment(CreateCommentReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder() CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getThemeId()) .themeId(req.getThemeId())
...@@ -55,16 +55,14 @@ public class CommentManager { ...@@ -55,16 +55,14 @@ public class CommentManager {
commentService.insertComment(commentEntity); commentService.insertComment(commentEntity);
} }
//查询 //查询评论
public List<CommentQo> queryComments(String themeId, String userId) { public List<CommentQo> queryComments(String themeId, String userId) {
List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null); List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities); List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT); Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
for (CommentQo commentQo : commentQos) { for (CommentQo commentQo : commentQos) {
//用户信息 //查询用户信息
String authorId = commentQo.getAuthorId(); String authorId = commentQo.getAuthorId();
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId); CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
...@@ -86,10 +84,6 @@ public class CommentManager { ...@@ -86,10 +84,6 @@ public class CommentManager {
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT); Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId); commentQo.setLikeCount(countByTypeAndId);
//二级评论,本期不上线
// List<CommentEntity> CommentLv2Entities = commentService.selectByThemeIdAndParentId(themeId, commentId);
// List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities);
// commentQo.setCommentLv2Qos(commentLv2Qos);
} }
//排序:点赞降序+时间降序 //排序:点赞降序+时间降序
return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount, Comparator.reverseOrder()). return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount, Comparator.reverseOrder()).
...@@ -111,8 +105,8 @@ public class CommentManager { ...@@ -111,8 +105,8 @@ public class CommentManager {
public void report(ReportCommentReq req, String userId) { public void report(ReportCommentReq req, String userId) {
//更改举报状态 //更改举报状态
commentService.updateReportStatus(req.getCommentId()); commentService.updateReportStatus(req.getCommentId());
//写入举报日志 //写入举报记录表
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId()); CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
reportLogService.insert(ReportTypeEnum.COMMENT, userId,req.getCommentId(),commentEntity.getAuthorId(),req.getReason()); reportLogService.insert(ReportTypeEnum.COMMENT, userId, req.getCommentId(), commentEntity.getAuthorId(), req.getReason());
} }
} }
...@@ -38,14 +38,14 @@ public class FileManager { ...@@ -38,14 +38,14 @@ public class FileManager {
String originalName = file.getOriginalFilename(); String originalName = file.getOriginalFilename();
if (data.length == 0 || StringUtils.isEmpty(originalName)){ if (data.length == 0 || StringUtils.isEmpty(originalName)) {
throw new BizException("上传文件为空"); throw new BizException("上传文件为空");
} }
FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName); FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName);
return ConvertUtil.fileRecordEntity2Resp(fileRecordEntity); return ConvertUtil.fileRecordEntity2Resp(fileRecordEntity);
} }
public Map<String,String> getFileUrlByIds(List<String> fileIds){ public Map<String, String> getFileUrlByIds(List<String> fileIds) {
return ossFileService.queryByIds(fileIds).stream() return ossFileService.queryByIds(fileIds).stream()
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl)); .collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
} }
......
...@@ -69,13 +69,13 @@ public class HomePageManager { ...@@ -69,13 +69,13 @@ public class HomePageManager {
//查询 个人中心 相关信息 //查询 个人中心 相关信息
public UserInfoNew queryUsersListNew(String userIdMyself, String userId) { public UserInfoNew queryUsersListNew(String userIdMyself, String userId) {
CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself); CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败"); if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = queryUsersListNew.getData(); UserInfoNew userInfoNew = queryUsersListNew.getData();
if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页 if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页
// 关注 按钮的显示逻辑 // 关注 按钮的显示逻辑
FollowRelEntity followRelEntity = followRelService.queryRecord(userId, userIdMyself); FollowRelEntity followRelEntity = followRelService.queryRecord(userId, userIdMyself);
if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()){ if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()) {
userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.FOLLOWED.getCode()); // 已关注 userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.FOLLOWED.getCode()); // 已关注
} else { } else {
userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.NOT_FOLLOWED.getCode()); // 未关注 userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.NOT_FOLLOWED.getCode()); // 未关注
...@@ -89,7 +89,7 @@ public class HomePageManager { ...@@ -89,7 +89,7 @@ public class HomePageManager {
getFansNUmAndFollowNum(userInfoNew); getFansNUmAndFollowNum(userInfoNew);
// 主页类型 显示逻辑 // 主页类型 显示逻辑
if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfoNew.getLevelGrade()){ if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfoNew.getLevelGrade()) {
// 首席投顾 // 首席投顾
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.CHIEF.getCode()); userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.CHIEF.getCode());
// 成功案例客户 // 成功案例客户
...@@ -103,10 +103,10 @@ public class HomePageManager { ...@@ -103,10 +103,10 @@ public class HomePageManager {
userInfoNew.getUserInfoNewChief().setClientId(null); userInfoNew.getUserInfoNewChief().setClientId(null);
} }
} }
} else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()){ } else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()) {
// 机构账号 // 机构账号
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.ORG.getCode()); userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.ORG.getCode());
if (FundCompanyTypeEnum.PUBLIC.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 公募 if (FundCompanyTypeEnum.PUBLIC.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())) { // 公募
//设置 基金数 //设置 基金数
MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>() MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId()) .eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
...@@ -118,7 +118,7 @@ public class HomePageManager { ...@@ -118,7 +118,7 @@ public class HomePageManager {
.last("limit 1")); .last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null); userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null);
} }
if(FundCompanyTypeEnum.PRIVATE.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 私募 if (FundCompanyTypeEnum.PRIVATE.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())) { // 私募
//设置 基金数 //设置 基金数
Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getUserInfoNewOrg().getBelongOrgId())); Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getUserInfoNewOrg().getBelongOrgId()));
userInfoNew.setFundNumber(integer); userInfoNew.setFundNumber(integer);
...@@ -132,7 +132,7 @@ public class HomePageManager { ...@@ -132,7 +132,7 @@ public class HomePageManager {
} }
//设置团队成员 //设置团队成员
CommonResp<List<UserInfoOrg>> usetInfoByOrgUserId = feignClientForFatools.getUsetInfoByOrgUserId(userId); CommonResp<List<UserInfoOrg>> usetInfoByOrgUserId = feignClientForFatools.getUsetInfoByOrgUserId(userId);
if (usetInfoByOrgUserId.isSuccess()){ if (usetInfoByOrgUserId.isSuccess()) {
List<UserInfoOrg> userInfoOrgs = usetInfoByOrgUserId.getData(); List<UserInfoOrg> userInfoOrgs = usetInfoByOrgUserId.getData();
// 设置关注列表 // 设置关注列表
List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList()); List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList());
...@@ -142,7 +142,8 @@ public class HomePageManager { ...@@ -142,7 +142,8 @@ public class HomePageManager {
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)); .eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity())); Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity()));
userInfoOrgs.forEach(userInfoOrg -> { userInfoOrgs.forEach(userInfoOrg -> {
if (collect1.containsKey(userInfoOrg.getUserId())) userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注 if (collect1.containsKey(userInfoOrg.getUserId()))
userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注
}); });
userInfoNew.setUserInfoOrgList(userInfoOrgs); userInfoNew.setUserInfoOrgList(userInfoOrgs);
} }
...@@ -165,6 +166,7 @@ public class HomePageManager { ...@@ -165,6 +166,7 @@ public class HomePageManager {
userInfoNew.setFollowNumber(followNumber); userInfoNew.setFollowNumber(followNumber);
userInfoNew.setFansNumber(fansNumber); userInfoNew.setFansNumber(fansNumber);
} }
public List<Customer> queryUserCustomerList(String userId) { public List<Customer> queryUserCustomerList(String userId) {
CommonResp<List<Customer>> ifaCustomerList = feignClientForDiagnose.getIfaCustomerList(userId); CommonResp<List<Customer>> ifaCustomerList = feignClientForDiagnose.getIfaCustomerList(userId);
if (ifaCustomerList.isSuccess()) return ifaCustomerList.getData(); if (ifaCustomerList.isSuccess()) return ifaCustomerList.getData();
...@@ -208,5 +210,4 @@ public class HomePageManager { ...@@ -208,5 +210,4 @@ public class HomePageManager {
} }
} }
...@@ -138,20 +138,35 @@ public class ThemeManager { ...@@ -138,20 +138,35 @@ public class ThemeManager {
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build(); return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
} }
//转发主题
public CreateThemeResp forward(ForwardThemeReq req, String userId) {
ThemeEntity targetTheme = themeService.queryByThemeId(req.getFormerThemeId());
ThemeEntity themeEntity = ThemeEntity.builder()
.content(JsonUtil.toJson(req.getContent()))
.topicId(req.getTopicId())
.formerThemeId(req.getFormerThemeId())
.authorId(userId)
.themeType(ThemeTypeEnum.FORWARD.getCode())
.build();
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId() == req.getFormerThemeId()) {
//新建
themeService.insertTheme(themeEntity);
} else {
//修改
themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId());
/** }
* 返回主题列表 return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
* }
* @param req
* @param userId
* @return //查询主题列表:推荐/关注/热门/最新
*/
public List<ThemeQo> queryThemes(ThemeListReq req, String userId) { public List<ThemeQo> queryThemes(ThemeListReq req, String userId) {
List<ThemeEntity> themeEntities = new ArrayList<>(); List<ThemeEntity> themeEntities = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐 //推荐
// themeEntities = themeService.selectExcludeUser(userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100); List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, userId, req.getLastId(), req.getPageSize()); themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, userId, req.getLastId(), req.getPageSize());
...@@ -163,7 +178,7 @@ public class ThemeManager { ...@@ -163,7 +178,7 @@ public class ThemeManager {
} else if (ThemeListTypeEnum.TOPIC_HOT.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.TOPIC_HOT.getCode().equals(req.getType())) {
//根据话题查询热门 //根据话题查询热门
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空"); if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
List<ThemeAnalysDO> rankThemeList = rankService.getRankThemeList(req.getTopicId()); List<ThemeAnalysDO> rankThemeListByTopic = rankService.getRankThemeList(req.getTopicId());
themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize()); themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize());
} else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) {
//根据话题查询最新 //根据话题查询最新
...@@ -181,20 +196,8 @@ public class ThemeManager { ...@@ -181,20 +196,8 @@ public class ThemeManager {
} }
/**
* 举报主题
* @param req
* @param userId
*/
public void report(ReportThemeReq req, String userId) {
//更改举报状态
themeService.updateReportStatus(req.getThemeId());
//写入举报日志
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
reportLogService.insert(ReportTypeEnum.THEME, userId,req.getThemeId(),themeEntity.getAuthorId(),req.getReason());
}
// 返回用户发布、回复、收藏的主题列表 // 返回用户发布、回复、点赞、收藏的主题列表
public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) { public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) {
List<ThemeEntity> themeEntities = Collections.emptyList(); List<ThemeEntity> themeEntities = Collections.emptyList();
...@@ -219,51 +222,6 @@ public class ThemeManager { ...@@ -219,51 +222,6 @@ public class ThemeManager {
return themeQos; return themeQos;
} }
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return null;
}
//查询正文 //查询正文
public ThemeQo getDetail(String themeId, String userId) { public ThemeQo getDetail(String themeId, String userId) {
...@@ -296,27 +254,23 @@ public class ThemeManager { ...@@ -296,27 +254,23 @@ public class ThemeManager {
} }
} }
//转发 //举报主题
public CreateThemeResp forward(ForwardThemeReq req, String userId) { public void report(ReportThemeReq req, String userId) {
ThemeEntity targetTheme = themeService.queryByThemeId(req.getFormerThemeId()); //更改举报状态
ThemeEntity themeEntity = ThemeEntity.builder() themeService.updateReportStatus(req.getThemeId());
.content(JsonUtil.toJson(req.getContent())) //写入举报记录表
.topicId(req.getTopicId()) ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
.formerThemeId(req.getFormerThemeId()) reportLogService.insert(ReportTypeEnum.THEME, userId, req.getThemeId(), themeEntity.getAuthorId(), req.getReason());
.authorId(userId) }
.themeType(ThemeTypeEnum.FORWARD.getCode())
.build();
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId() == req.getFormerThemeId()) {
//新建
themeService.insertTheme(themeEntity);
} else {
//修改
themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId());
}
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
//关注用户是否有更新
public Integer getFollowUpdateCount(String userId) {
LocalDateTime lastViewTime = visitSummaryService.queryLatestViewFollow(userId);
List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime);
} }
// 屏蔽(用户) // 屏蔽(用户)
...@@ -342,6 +296,8 @@ public class ThemeManager { ...@@ -342,6 +296,8 @@ 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 //Entity转Qo
...@@ -364,7 +320,6 @@ public class ThemeManager { ...@@ -364,7 +320,6 @@ public class ThemeManager {
buildFormerTheme(themeQo); buildFormerTheme(themeQo);
//是否关注作者 //是否关注作者
String authorId = themeQo.getAuthorId(); String authorId = themeQo.getAuthorId();
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId)); Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
...@@ -411,14 +366,10 @@ public class ThemeManager { ...@@ -411,14 +366,10 @@ public class ThemeManager {
} }
public Integer getFollowUpdateCount(String userId) {
LocalDateTime lastViewTime = visitSummaryService.queryLatestViewFollow(userId);
List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime);
}
/** /**
* 腾讯云-内容检测 * 腾讯云-内容检测
*
* @param content * @param content
*/ */
private void checkContent(String content) { private void checkContent(String content) {
...@@ -434,12 +385,13 @@ public class ThemeManager { ...@@ -434,12 +385,13 @@ public class ThemeManager {
throw new BizException("内容校验失败,请检查内容后重新发送"); throw new BizException("内容校验失败,请检查内容后重新发送");
} }
} }
return ; return;
} }
/** /**
* 直播类型做转播检查 * 直播类型做转播检查
*
* @param userId * @param userId
* @param contents * @param contents
*/ */
...@@ -458,4 +410,56 @@ public class ThemeManager { ...@@ -458,4 +410,56 @@ public class ThemeManager {
} }
/**
* 查询用户评论过的主题,并封装成转发主题结构
*
* @param req
* @param userId 当前用户
* @return
*/
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return null;
}
} }
...@@ -43,7 +43,7 @@ public class TopicManager { ...@@ -43,7 +43,7 @@ public class TopicManager {
//新增话题 //新增话题
public void insertTopic(String topicTitle, String userId) { public void insertTopic(String topicTitle, String userId) {
if (topicService.queryByTitile(topicTitle) == null) { if (topicService.queryByTitile(topicTitle) == null) {
throw new BizException("话题名称已存在:"+topicTitle); throw new BizException("话题名称已存在:" + topicTitle);
} }
topicService.addTopic(topicTitle, userId); topicService.addTopic(topicTitle, userId);
...@@ -66,7 +66,6 @@ public class TopicManager { ...@@ -66,7 +66,6 @@ public class TopicManager {
} }
public void refreshRedisCache() { public void refreshRedisCache() {
List<TopicEntity> topicEntities = topicService.queryAll(); List<TopicEntity> topicEntities = topicService.queryAll();
for (TopicEntity topic : topicEntities) { for (TopicEntity topic : topicEntities) {
......
...@@ -40,10 +40,6 @@ public class VisitSummaryManager { ...@@ -40,10 +40,6 @@ public class VisitSummaryManager {
} }
public void addTopicPageView(String topicId) { public void addTopicPageView(String topicId) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
visitSummaryService.addPageView(userId, topicId, VisitTypeEnum.TOPIC_PAGE_VIEW); visitSummaryService.addPageView(userId, topicId, VisitTypeEnum.TOPIC_PAGE_VIEW);
......
...@@ -38,7 +38,7 @@ public class RankService { ...@@ -38,7 +38,7 @@ public class RankService {
* 计算主题热度排行 * 计算主题热度排行
*/ */
public void rankThemes() { public void rankThemes() {
List<ThemeEntity> themeEntities = themeService.queryAll(); List<ThemeEntity> themeEntities = themeService.queryRecent14days();
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities); List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) { for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId(); String themeId = theme.getThemeId();
......
...@@ -8,6 +8,7 @@ import com.tanpu.community.api.enums.DeleteTagEnum; ...@@ -8,6 +8,7 @@ import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ReportStatusEnum; import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -41,14 +42,11 @@ public class ThemeService { ...@@ -41,14 +42,11 @@ public class ThemeService {
themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId)); themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId));
} }
/** //14天内所有主题
* 根据主题Id查询列表 public List<ThemeEntity> queryRecent14days() {
*
* @return
*/
public List<ThemeEntity> queryAll() {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()); .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.gt(ThemeEntity::getCreateTime, TimeUtils.getDaysBefore(14));
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
......
...@@ -15,7 +15,6 @@ import com.tanpu.community.api.enums.RelTypeEnum; ...@@ -15,7 +15,6 @@ import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum; import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -38,9 +37,9 @@ public class ConvertUtil { ...@@ -38,9 +37,9 @@ public class ConvertUtil {
} }
ThemeQo themeQO = new ThemeQo(); ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO); BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime())); themeQO.setUpdateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime())); themeQO.setCreateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime())); themeQO.setUpToNowTime(TimeUtils.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() { List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
}); });
themeQO.setContent(themeContentQos); themeQO.setContent(themeContentQos);
...@@ -53,7 +52,7 @@ public class ConvertUtil { ...@@ -53,7 +52,7 @@ public class ConvertUtil {
} }
ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO(); ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeAnalysDO); BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeAnalysDO.setMinuteTillNow(TimeUtil.calMinuteTillNow(themeEntity.getCreateTime())); themeAnalysDO.setMinuteTillNow(TimeUtils.calMinuteTillNow(themeEntity.getCreateTime()));
return themeAnalysDO; return themeAnalysDO;
} }
...@@ -106,7 +105,7 @@ public class ConvertUtil { ...@@ -106,7 +105,7 @@ public class ConvertUtil {
TopicRankQo topicRankQo = new TopicRankQo(); TopicRankQo topicRankQo = new TopicRankQo();
BeanUtils.copyProperties(topicEntity, topicRankQo); BeanUtils.copyProperties(topicEntity, topicRankQo);
//2小时内发帖,添加新话题标签 //2小时内发帖,添加新话题标签
if(TimeUtil.calMinuteTillNow(topicEntity.getCreateTime())<120){ if(TimeUtils.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicRankQo.setType(TopicStatusEnum.NEWEST.getCode()); topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
} }
return topicRankQo; return topicRankQo;
...@@ -128,7 +127,7 @@ public class ConvertUtil { ...@@ -128,7 +127,7 @@ public class ConvertUtil {
public static CommentQo commentEntity2Qo(CommentEntity entity) { public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo(); CommentQo qo = new CommentQo();
BeanUtils.copyProperties(entity, qo); BeanUtils.copyProperties(entity, qo);
qo.setUpdateTime(TimeUtil.getTimestampOfDateTime(entity.getUpdateTime())); qo.setUpdateTime(TimeUtils.getTimestampOfDateTime(entity.getUpdateTime()));
return qo; return qo;
} }
......
package com.tanpu.community.util;
public class RankUtils {
}
package com.tanpu.community.util; package com.tanpu.community.util;
import java.text.SimpleDateFormat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Calendar;
public class TimeUtil { public class TimeUtils {
public static long getTimestampOfDateTime(LocalDateTime localDateTime) { public static long getTimestampOfDateTime(LocalDateTime localDateTime) {
ZoneId zone = ZoneId.systemDefault(); ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant(); Instant instant = localDateTime.atZone(zone).toInstant();
...@@ -41,4 +43,16 @@ public class TimeUtil { ...@@ -41,4 +43,16 @@ public class TimeUtil {
return between.toMinutes(); return between.toMinutes();
} }
//计算n天前的时间
public static LocalDateTime getDaysBefore(Integer number){
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
calendar.add(Calendar.DATE, number);
String three_days_after = sdf.format(calendar.getTime());
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime ldt = LocalDateTime.parse(three_days_after,df);
return ldt;
}
} }
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