From 686ce02535bcaf1e3f58a6f13b2ff2b81a1642c6 Mon Sep 17 00:00:00 2001 From: liujiming <liujm@wealthgrow.cn> Date: Mon, 21 Feb 2022 10:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/beans/qo/TopicAttachement.java | 4 +-- .../community/api/beans/qo/TopicFollowQo.java | 7 ++++ .../api/beans/qo/TopicPageDetailQo.java | 6 ++++ .../community/controller/TopicController.java | 7 ++-- .../community/manager/CommentManager.java | 12 ++++--- .../tanpu/community/manager/TopicManager.java | 30 ++++++++++++++--- .../tanpu/community/service/TopicService.java | 32 ++++++++++++++++--- 7 files changed, 79 insertions(+), 19 deletions(-) diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicAttachement.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicAttachement.java index db1d53d..4d588f9 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicAttachement.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicAttachement.java @@ -8,13 +8,13 @@ import lombok.Data; import lombok.NoArgsConstructor; @Data -@ApiModel(value = "主题关è”产å“") +@ApiModel(value = "主题关è”äº§å“ RelTypeEnum") @Builder @AllArgsConstructor @NoArgsConstructor public class TopicAttachement { - @ApiModelProperty(value = "RelTypeEnum类型,108:文本,88:äº§å“ 3ï¼šç›´æ’ 6:çŸè§†é¢‘ 303:新版课程-音频,304: 新版课程-视频,109:å•图(长文) 110:多图(讨论)") + @ApiModelProperty(value = " 88:äº§å“ 300:课程包 323: 线下活动 未定:资管人") private String type; @ApiModelProperty(value = "对象详情") diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java index b7b80d1..3b4fb34 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; @Data @Builder @@ -47,4 +48,10 @@ public class TopicFollowQo { @ApiModelProperty(value = "最近一æ¡è®¨è®ºå‘表时间-æ ¼å¼åŒ–") public String lastThemeTime; + public boolean checkTopicName(String keyword) { + if (StringUtils.isBlank(keyword)) { + return true; + } + return this.topicTitle.contains(keyword); + } } diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java index 61e46cc..1851646 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java @@ -40,6 +40,12 @@ public class TopicPageDetailQo { @ApiModelProperty(value = "æ˜¯å¦æœ‰æƒé™") private boolean hasPermission; + @ApiModelProperty(value = "是å¦å…³æ³¨ï¼Œéžä¸“属è¯é¢˜æ—¶æœ‰æ•ˆ") + private boolean hasFollow; + + @ApiModelProperty(value = "管ç†å‘˜") + private String managers; + @ApiModelProperty(value = "å…³è”产å“") private List<TopicAttachement> attachments; } diff --git a/community-service/src/main/java/com/tanpu/community/controller/TopicController.java b/community-service/src/main/java/com/tanpu/community/controller/TopicController.java index cf406ef..ee6bdbc 100644 --- a/community-service/src/main/java/com/tanpu/community/controller/TopicController.java +++ b/community-service/src/main/java/com/tanpu/community/controller/TopicController.java @@ -4,6 +4,7 @@ import com.tanpu.common.api.CommonResp; import com.tanpu.common.auth.AuthLogin; import com.tanpu.common.auth.UserHolder; import com.tanpu.community.api.beans.qo.TopicFollowQo; +import com.tanpu.community.api.beans.qo.TopicPageDetailQo; import com.tanpu.community.api.beans.qo.TopicRankQo; import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.topic.FollowTopicReq; @@ -38,9 +39,9 @@ public class TopicController { @AuthLogin @GetMapping(value = "/followList") @ApiOperation("关注è¯é¢˜åˆ—表") - public CommonResp<List<TopicFollowQo>> getFollowList() { + public CommonResp<List<TopicFollowQo>> getFollowList(@RequestParam(required = false,value = "keyword") String keyword) { - return CommonResp.success(topicManager.getFollowTopicList()); + return CommonResp.success(topicManager.getFollowTopicList(keyword)); } @@ -52,7 +53,7 @@ public class TopicController { @GetMapping(value = "/detailPage") @ApiOperation("è¯é¢˜è¯¦æƒ…页") - public CommonResp<TopicRankQo> getDetail(@RequestParam String topicId) { + public CommonResp<TopicPageDetailQo> getDetail(@RequestParam String topicId) { return topicManager.getDetail(topicId); } diff --git a/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java b/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java index f244b80..9fb31d7 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java @@ -157,12 +157,14 @@ public class CommentManager { commentQo.setBelongUserOrgName(userInfo.getBelongUserOrgName()); } // 回å¤ç”¨æˆ·å - String replyUserId = commentQo.getReplyUserId(); - UserInfoResp replyUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId), - 60, () -> this.getUserInfo(replyUserId), UserInfoResp.class); - if (replyUser != null) { - commentQo.setReplyUserName(replyUser.getNickName()); + if (StringUtils.isNotBlank(commentQo.getReplyUserId())){ + UserInfoResp replyUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId), + 60, () -> this.getUserInfo(commentQo.getReplyUserId()), UserInfoResp.class); + if (replyUser != null) { + commentQo.setReplyUserName(replyUser.getNickName()); + } } + commentQo.setHasLiked(false); commentQo.setLikeCount(0); } diff --git a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java index 5e51c72..3a38ab5 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java @@ -4,6 +4,7 @@ import com.tanpu.common.api.CommonResp; import com.tanpu.common.auth.UserHolder; import com.tanpu.common.constant.ErrorCodeConstant; import com.tanpu.community.api.beans.qo.TopicFollowQo; +import com.tanpu.community.api.beans.qo.TopicPageDetailQo; import com.tanpu.community.api.beans.qo.TopicRankQo; import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.topic.FollowTopicReq; @@ -60,13 +61,15 @@ public class TopicManager { /** * 关注è¯é¢˜ï¼ˆè®¨è®ºåŒºï¼‰åˆ—表 + * + * @param keyword */ - public List<TopicFollowQo> getFollowTopicList() { + public List<TopicFollowQo> getFollowTopicList(String keyword) { String userId = userHolder.getUserId(); // 查库 - List<TopicFollowQo> topicFollowQos = topicService.queryFollowTopic(userId); + List<TopicFollowQo> topicFollowQos = topicService.queryFollowTopic(keyword, userId); // 先从缓å˜ä¸èŽ·å–æµè§ˆé‡ Map<String, TopicRankQo> topicMap = rankService.getRankTopicList(null).stream().collect(Collectors.toMap(TopicRankQo::getTopicId, o -> o, (a, b) -> a)); @@ -80,7 +83,7 @@ public class TopicManager { themeService.queryCommentForTopic(topicFollowQos, userId); // æŽ’åº - topicFollowQos.stream().sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()). + topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()). thenComparing(TopicFollowQo::getLastThemeTime, Comparator.nullsFirst(String::compareTo).reversed())) .collect(Collectors.toList()); @@ -93,7 +96,7 @@ public class TopicManager { * @param topicId * @return */ - public CommonResp<TopicRankQo> getDetail(String topicId) { + public CommonResp<TopicPageDetailQo> getDetail(String topicId) { TopicEntity topicEntity = topicService.queryOnlineTopicById(topicId); @@ -107,7 +110,20 @@ public class TopicManager { return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), topicService.getPermissionToast(topicId)); } - return CommonResp.success(rankService.getTopicDetail(topicId)); + // DATA Transform + TopicRankQo topicDetail = rankService.getTopicDetail(topicId); + TopicPageDetailQo result = new TopicPageDetailQo(); + BeanUtils.copyProperties(topicDetail, result); + + // 查询管ç†å‘˜ + result.setManagers(topicService.queryManagers(result.getTopicId())); + // 查询关è”äº§å“ + topicService.queryAttachments(result); + // 是å¦å…³æ³¨ + result.setHasFollow(topicService.checkFollow(result.getTopicId(), userHolder.getUserId())); + + + return CommonResp.success(result); } @@ -122,6 +138,10 @@ public class TopicManager { // 检验è¯é¢˜æƒé™æ˜¯å¦ä¸“属 TopicEntity topicEntity = topicService.queryOnlineTopicById(req.getTopicId()); + if (topicEntity == null) { + return CommonResp.error(ErrorCodeConstant.TOPIC_NOT_FOUND.getCode(), "抱æ‰ï¼è¯¥è¯é¢˜å·²ä¸‹çº¿ã€‚"); + } + if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission())) { return CommonResp.error(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "专属è¯é¢˜ä¸æ”¯æŒå…³æ³¨"); } diff --git a/community-service/src/main/java/com/tanpu/community/service/TopicService.java b/community-service/src/main/java/com/tanpu/community/service/TopicService.java index 4f44b01..80099bb 100644 --- a/community-service/src/main/java/com/tanpu/community/service/TopicService.java +++ b/community-service/src/main/java/com/tanpu/community/service/TopicService.java @@ -2,7 +2,9 @@ package com.tanpu.community.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tanpu.common.uuid.UuidGenHelper; +import com.tanpu.community.api.beans.qo.TopicAttachement; import com.tanpu.community.api.beans.qo.TopicFollowQo; +import com.tanpu.community.api.beans.qo.TopicPageDetailQo; import com.tanpu.community.api.beans.qo.TopicRankQo; import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.StatusEnum; @@ -20,6 +22,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -79,10 +82,10 @@ public class TopicService { return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds)); } - public List<TopicFollowQo> queryFollowTopic(String userId) { + public List<TopicFollowQo> queryFollowTopic(String keyword, String userId) { // 用户的关注列表(包括专属) List<String> followTopicIds = topicFollowRelMapper.selectTopicIdByUserId(userId); - if (CollectionUtils.isEmpty(followTopicIds)){ + if (CollectionUtils.isEmpty(followTopicIds)) { return Collections.emptyList(); } @@ -114,7 +117,7 @@ public class TopicService { public void deleteFollowTopic(String topicId, String userId) { TopicFollowRelEntity searchResult = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId); - if (searchResult != null){ + if (searchResult != null) { searchResult.setUnfollowTime(LocalDateTime.now()); searchResult.setDeleteTag(DeleteTagEnum.DELETED.getCode()); topicFollowRelMapper.updateById(searchResult); @@ -122,7 +125,7 @@ public class TopicService { } public void batchCheckPermission(List<TopicRankQo> content, String userId) { - if (StringUtils.isBlank(userId)){ + if (StringUtils.isBlank(userId)) { return; } } @@ -156,4 +159,25 @@ public class TopicService { return "æš‚æ— æƒé™å‚与æ¤è¯é¢˜ï½žæ‚¨å¯è”ç³»å®˜æ–¹å®¢æœ 021- 了解详情"; // return "该è¯é¢˜ä»…é™" + permission + "å¯å‚与哦~"; } + + public String queryManagers(String topicId) { + return "å°çŽ‹ã€å°æŽã€å°åˆ˜"; + } + + public void queryAttachments(TopicPageDetailQo topic) { + TopicAttachement a1 = TopicAttachement.builder().type("88").detail(null).build(); + TopicAttachement a2 = TopicAttachement.builder().type("300").detail(null).build(); + TopicAttachement a3 = TopicAttachement.builder().type("323").detail(null).build(); + + + topic.setAttachments(Arrays.asList(a1, a2, a3)); + } + + public boolean checkFollow(String topicId, String userId) { + if (StringUtils.isBlank(userId)) { + return false; + } + TopicFollowRelEntity topicFollowRelEntity = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId); + return topicFollowRelEntity != null; + } } -- 2.18.1